The Labs \ Source Viewer \ SSCLI \ System.Security.Policy \ GacInstalled

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. //
  16. // GacInstalled is an IIdentity representing whether or not an assembly is installed in the Gac
  17. //
  18. namespace System.Security.Policy
  19. {
  20.     using System.Runtime.Remoting;
  21.     using System;
  22.     using System.Security;
  23.     using System.Security.Util;
  24.     using System.IO;
  25.     using System.Collections;
  26.     using GacIdentityPermission = System.Security.Permissions.GacIdentityPermission;
  27.     using System.Runtime.CompilerServices;
  28.    
  29.     [Serializable()]
  30.     [System.Runtime.InteropServices.ComVisible(true)]
  31.     public sealed class GacInstalled : IIdentityPermissionFactory, IBuiltInEvidence
  32.     {
  33.         public GacInstalled()
  34.         {
  35.         }
  36.        
  37.         public IPermission CreateIdentityPermission(Evidence evidence)
  38.         {
  39.             return new GacIdentityPermission();
  40.         }
  41.        
  42.         public override bool Equals(object o)
  43.         {
  44.             if (o is GacInstalled)
  45.                 return true;
  46.             return false;
  47.         }
  48.        
  49.         public override int GetHashCode()
  50.         {
  51.             return 0;
  52.         }
  53.        
  54.         public object Copy()
  55.         {
  56.             return new GacInstalled();
  57.         }
  58.        
  59.         internal SecurityElement ToXml()
  60.         {
  61.             SecurityElement elem = new SecurityElement(this.GetType().FullName);
  62.             elem.AddAttribute("version", "1");
  63.             return elem;
  64.         }
  65.        
  66.         /// <internalonly/>
  67.         int IBuiltInEvidence.OutputToBuffer(char[] buffer, int position, bool verbose)
  68.         {
  69.             buffer[position] = BuiltInEvidenceHelper.idGac;
  70.             return position + 1;
  71.         }
  72.        
  73.         /// <internalonly/>
  74.         int IBuiltInEvidence.GetRequiredSize(bool verbose)
  75.         {
  76.             return 1;
  77.         }
  78.        
  79.         /// <internalonly/>
  80.         int IBuiltInEvidence.InitFromBuffer(char[] buffer, int position)
  81.         {
  82.             return position;
  83.         }
  84.        
  85.         public override string ToString()
  86.         {
  87.             return ToXml().ToString();
  88.         }
  89.     }
  90. }

Developer Fusion