2 // StrongName.cs: Strong Name
5 // Sebastien Pouliot (spouliot@motus.com)
7 // (C) 2002 Motus Technologies Inc. (http://www.motus.com)
11 using System.Security.Permissions;
14 namespace System.Security.Policy {
17 public sealed class StrongName : IIdentityPermissionFactory, IBuiltInEvidence {
19 private StrongNamePublicKeyBlob publickey;
21 private Version version;
23 public StrongName (StrongNamePublicKeyBlob blob, string name, Version version)
26 throw new ArgumentNullException ("blob");
28 throw new ArgumentNullException ("name");
30 throw new ArgumentNullException ("version");
34 this.version = version;
41 public StrongNamePublicKeyBlob PublicKey {
42 get { return publickey; }
45 public Version Version {
46 get { return version; }
51 return (object) new StrongName (publickey, name, version);
54 public IPermission CreateIdentityPermission (Evidence evidence)
56 return new StrongNameIdentityPermission (publickey, name, version);
59 public override bool Equals (object o)
61 if (!(o is StrongName))
63 StrongName sn = (o as StrongName);
66 if (!Version.Equals (sn.Version))
68 return PublicKey.Equals (sn.PublicKey);
71 public override int GetHashCode ()
73 return publickey.GetHashCode ();
76 public override string ToString ()
78 SecurityElement element = new SecurityElement (typeof (System.Security.Policy.StrongName).Name);
79 element.AddAttribute ("version", "1");
80 element.AddAttribute ("Key", publickey.ToString ());
81 element.AddAttribute ("Name", name);
82 element.AddAttribute ("Version", version.ToString ());
83 return element.ToString ();
86 // interface IBuiltInEvidence
89 int IBuiltInEvidence.GetRequiredSize (bool verbose)
95 int IBuiltInEvidence.InitFromBuffer (char [] buffer, int position)
101 int IBuiltInEvidence.OutputToBuffer (char [] buffer, int position, bool verbose)