13 private bool m_unrestricted;
15 private StrongName2[] m_strongNames;
25 if (m_strongNames ==
null || m_strongNames.Length == 0)
29 if (m_strongNames.Length > 1)
33 return m_strongNames[0].m_publicKeyBlob;
41 m_unrestricted =
false;
42 if (m_strongNames !=
null && m_strongNames.Length == 1)
44 m_strongNames[0].m_publicKeyBlob = value;
47 m_strongNames =
new StrongName2[1];
48 m_strongNames[0] =
new StrongName2(value,
"",
new Version());
60 if (m_strongNames ==
null || m_strongNames.Length == 0)
64 if (m_strongNames.Length > 1)
68 return m_strongNames[0].m_name;
72 if (value !=
null && value.Length == 0)
76 m_unrestricted =
false;
77 if (m_strongNames !=
null && m_strongNames.Length == 1)
79 m_strongNames[0].m_name = value;
82 m_strongNames =
new StrongName2[1];
83 m_strongNames[0] =
new StrongName2(
null, value,
new Version());
94 if (m_strongNames ==
null || m_strongNames.Length == 0)
98 if (m_strongNames.Length > 1)
102 return m_strongNames[0].m_version;
106 m_unrestricted =
false;
107 if (m_strongNames !=
null && m_strongNames.Length == 1)
109 m_strongNames[0].m_version = value;
112 m_strongNames =
new StrongName2[1];
113 m_strongNames[0] =
new StrongName2(
null,
"", value);
125 m_unrestricted =
true;
128 m_unrestricted =
false;
147 if (name !=
null && name.Equals(
""))
151 m_unrestricted =
false;
152 m_strongNames =
new StrongName2[1];
153 m_strongNames[0] =
new StrongName2(blob, name, version);
161 strongNameIdentityPermission.m_unrestricted = m_unrestricted;
162 if (m_strongNames !=
null)
164 strongNameIdentityPermission.m_strongNames =
new StrongName2[m_strongNames.Length];
165 for (
int i = 0; i < m_strongNames.Length; i++)
167 strongNameIdentityPermission.m_strongNames[i] = m_strongNames[i].Copy();
170 return strongNameIdentityPermission;
186 if (m_strongNames ==
null)
190 if (m_strongNames.Length == 0)
197 if (strongNameIdentityPermission ==
null)
201 if (strongNameIdentityPermission.m_unrestricted)
209 if (m_strongNames !=
null)
211 StrongName2[] strongNames = m_strongNames;
212 foreach (StrongName2 strongName
in strongNames)
215 if (strongNameIdentityPermission.m_strongNames !=
null)
217 StrongName2[] strongNames2 = strongNameIdentityPermission.m_strongNames;
218 foreach (StrongName2 target2
in strongNames2)
220 if (strongName.IsSubsetOf(target2))
247 if (strongNameIdentityPermission ==
null)
251 if (m_unrestricted && strongNameIdentityPermission.m_unrestricted)
254 strongNameIdentityPermission2.m_unrestricted =
true;
255 return strongNameIdentityPermission2;
259 return strongNameIdentityPermission.
Copy();
261 if (strongNameIdentityPermission.m_unrestricted)
265 if (m_strongNames ==
null || strongNameIdentityPermission.m_strongNames ==
null || m_strongNames.Length == 0 || strongNameIdentityPermission.m_strongNames.Length == 0)
270 StrongName2[] strongNames = m_strongNames;
271 foreach (StrongName2 strongName
in strongNames)
273 StrongName2[] strongNames2 = strongNameIdentityPermission.m_strongNames;
274 foreach (StrongName2 target2
in strongNames2)
276 StrongName2 strongName2 = strongName.Intersect(target2);
277 if (strongName2 !=
null)
279 list.Add(strongName2);
288 strongNameIdentityPermission3.m_strongNames = list.ToArray();
289 return strongNameIdentityPermission3;
300 if ((m_strongNames ==
null || m_strongNames.Length == 0) && !m_unrestricted)
307 if (strongNameIdentityPermission ==
null)
311 if (m_unrestricted || strongNameIdentityPermission.m_unrestricted)
314 strongNameIdentityPermission2.m_unrestricted =
true;
315 return strongNameIdentityPermission2;
317 if (m_strongNames ==
null || m_strongNames.Length == 0)
319 if (strongNameIdentityPermission.m_strongNames ==
null || strongNameIdentityPermission.m_strongNames.Length == 0)
323 return strongNameIdentityPermission.
Copy();
325 if (strongNameIdentityPermission.m_strongNames ==
null || strongNameIdentityPermission.m_strongNames.Length == 0)
330 StrongName2[] strongNames = m_strongNames;
331 foreach (StrongName2 item
in strongNames)
335 StrongName2[] strongNames2 = strongNameIdentityPermission.m_strongNames;
336 foreach (StrongName2 strongName
in strongNames2)
339 foreach (StrongName2 item2
in list)
341 if (strongName.Equals(item2))
349 list.Add(strongName);
353 strongNameIdentityPermission3.m_strongNames = list.ToArray();
354 return strongNameIdentityPermission3;
363 m_unrestricted =
false;
364 m_strongNames =
null;
366 string text = e.Attribute(
"Unrestricted");
367 if (text !=
null &&
string.Compare(text,
"true",
StringComparison.OrdinalIgnoreCase) == 0)
369 m_unrestricted =
true;
372 string text2 = e.Attribute(
"PublicKeyBlob");
373 string text3 = e.Attribute(
"Name");
374 string text4 = e.Attribute(
"AssemblyVersion");
376 if (text2 !=
null || text3 !=
null || text4 !=
null)
378 StrongName2 item =
new StrongName2((text2 ==
null) ?
null :
new StrongNamePublicKeyBlob(text2), text3, (text4 ==
null) ?
null :
new Version(text4));
382 if (children !=
null)
386 text2 = item2.Attribute(
"PublicKeyBlob");
387 text3 = item2.Attribute(
"Name");
388 text4 = item2.Attribute(
"AssemblyVersion");
389 if (text2 !=
null || text3 !=
null || text4 !=
null)
391 StrongName2 item =
new StrongName2((text2 ==
null) ?
null :
new StrongNamePublicKeyBlob(text2), text3, (text4 ==
null) ?
null :
new Version(text4));
398 m_strongNames = list.ToArray();
411 else if (m_strongNames !=
null)
413 if (m_strongNames.Length == 1)
415 if (m_strongNames[0].m_publicKeyBlob !=
null)
417 securityElement.
AddAttribute(
"PublicKeyBlob", Hex.EncodeHexString(m_strongNames[0].m_publicKeyBlob.PublicKey));
419 if (m_strongNames[0].m_name !=
null)
421 securityElement.
AddAttribute(
"Name", m_strongNames[0].m_name);
423 if ((
object)m_strongNames[0].m_version !=
null)
425 securityElement.
AddAttribute(
"AssemblyVersion", m_strongNames[0].m_version.ToString());
430 for (
int i = 0; i < m_strongNames.Length; i++)
433 if (m_strongNames[i].m_publicKeyBlob !=
null)
435 securityElement2.
AddAttribute(
"PublicKeyBlob", Hex.EncodeHexString(m_strongNames[i].m_publicKeyBlob.PublicKey));
437 if (m_strongNames[i].m_name !=
null)
439 securityElement2.
AddAttribute(
"Name", m_strongNames[i].m_name);
441 if ((
object)m_strongNames[i].m_version !=
null)
443 securityElement2.
AddAttribute(
"AssemblyVersion", m_strongNames[i].m_version.ToString());
445 securityElement.
AddChild(securityElement2);
449 return securityElement;
452 int IBuiltInPermission.GetTokenIndex()
454 return GetTokenIndex();
457 internal static int GetTokenIndex()
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
override bool IsSubsetOf(IPermission target)
Determines whether the current permission is a subset of the specified permission.
override IPermission Copy()
Creates and returns an identical copy of the current permission.
override IPermission Intersect(IPermission target)
Creates and returns a permission that is the intersection of the current permission and the specified...
StrongNamePublicKeyBlob PublicKey
Gets or sets the public key blob that defines the strong name identity namespace.
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
override SecurityElement ToXml()
Creates an XML encoding of the permission and its current state.
override IPermission Union(IPermission target)
Creates a permission that is the union of the current permission and the specified permission.
string Name
Gets or sets the simple name portion of the strong name identity.
void AddChild(SecurityElement child)
Adds a child element to the XML element.
Provides information about, and means to manipulate, the current environment and platform....
StrongNameIdentityPermission(StrongNamePublicKeyBlob blob, string name, Version version)
Initializes a new instance of the T:System.Security.Permissions.StrongNameIdentityPermission class fo...
Represents the XML object model for encoding security objects. This class cannot be inherited.
Defines the underlying structure of all code access permissions.
Represents the version number of an assembly, operating system, or the common language runtime....
Defines methods implemented by permission types.
Defines the identity permission for strong names. This class cannot be inherited.
The exception that is thrown when one of the arguments provided to a method is not valid.
Version Version
Gets or sets the version number of the identity.
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
PermissionState
Specifies whether a permission should have all or no access to resources at creation.
void AddAttribute(string name, string value)
Adds a name/value attribute to an XML element.
Specifies that the class can be serialized.
ArrayList Children
Gets or sets the array of child elements of the XML element.
The exception that is thrown when an invoked method is not supported, or when there is an attempt to ...
override void FromXml(SecurityElement e)
Reconstructs a permission with a specified state from an XML encoding.
Represents the public key information (called a blob) for a strong name. This class cannot be inherit...
StrongNameIdentityPermission(PermissionState state)
Initializes a new instance of the T:System.Security.Permissions.StrongNameIdentityPermission class wi...
Implements the T:System.Collections.IList interface using an array whose size is dynamically increase...