15 private string m_name;
21 private const string s_tagName =
"Name";
23 private const string s_tagVersion =
"AssemblyVersion";
25 private const string s_tagPublicKeyBlob =
"PublicKeyBlob";
34 if (m_publicKeyBlob ==
null && m_element !=
null)
38 return m_publicKeyBlob;
46 m_publicKeyBlob = value;
57 if (m_name ==
null && m_element !=
null)
67 if (m_publicKeyBlob ==
null && m_element !=
null)
71 if ((
object)m_version ==
null && m_element !=
null)
77 else if (value.Length == 0)
91 if ((
object)m_version ==
null && m_element !=
null)
101 if (m_name ==
null && m_element !=
null)
105 if (m_publicKeyBlob ==
null && m_element !=
null)
131 if (name !=
null && name.Equals(
""))
135 m_publicKeyBlob = blob;
146 object usedEvidence =
null;
147 return ((IReportMatchMembershipCondition)
this).Check(evidence, out usedEvidence);
150 bool IReportMatchMembershipCondition.Check(
Evidence evidence, out
object usedEvidence)
153 if (evidence ==
null)
157 StrongName delayEvaluatedHostEvidence = evidence.GetDelayEvaluatedHostEvidence<StrongName>();
158 if (delayEvaluatedHostEvidence !=
null)
160 bool flag =
PublicKey !=
null &&
PublicKey.Equals(delayEvaluatedHostEvidence.PublicKey);
161 bool flag2 =
Name ==
null || (delayEvaluatedHostEvidence.Name !=
null && StrongName.CompareNames(delayEvaluatedHostEvidence.Name,
Name));
162 bool flag3 = (object)
Version ==
null || ((
object)delayEvaluatedHostEvidence.Version !=
null && delayEvaluatedHostEvidence.Version.CompareTo(
Version) == 0);
163 if ((flag && flag2) & flag3)
165 usedEvidence = delayEvaluatedHostEvidence;
199 XMLUtil.AddClassAttribute(securityElement, GetType(),
"System.Security.Policy.StrongNameMembershipCondition");
213 return securityElement;
227 if (!e.
Tag.Equals(
"IMembershipCondition"))
234 m_publicKeyBlob =
null;
240 private void ParseName()
244 if (m_element !=
null)
246 string text = m_element.Attribute(
"Name");
247 m_name = ((text ==
null) ?
null : text);
248 if ((
object)m_version !=
null && m_name !=
null && m_publicKeyBlob !=
null)
256 private void ParseKeyBlob()
260 if (m_element !=
null)
262 string text = m_element.Attribute(
"PublicKeyBlob");
266 throw new ArgumentException(Environment.GetResourceString(
"Argument_BlobCannotBeNull"));
268 strongNamePublicKeyBlob.PublicKey = Hex.DecodeHexString(text);
269 m_publicKeyBlob = strongNamePublicKeyBlob;
270 if ((
object)m_version !=
null && m_name !=
null && m_publicKeyBlob !=
null)
278 private void ParseVersion()
282 if (m_element !=
null)
284 string text = m_element.Attribute(
"AssemblyVersion");
285 m_version = ((text ==
null) ?
null :
new Version(text));
286 if ((
object)m_version !=
null && m_name !=
null && m_publicKeyBlob !=
null)
319 if (strongNameMembershipCondition !=
null)
321 if (m_publicKeyBlob ==
null && m_element !=
null)
325 if (strongNameMembershipCondition.m_publicKeyBlob ==
null && strongNameMembershipCondition.m_element !=
null)
327 strongNameMembershipCondition.ParseKeyBlob();
329 if (
object.
Equals(m_publicKeyBlob, strongNameMembershipCondition.m_publicKeyBlob))
331 if (m_name ==
null && m_element !=
null)
335 if (strongNameMembershipCondition.m_name ==
null && strongNameMembershipCondition.m_element !=
null)
337 strongNameMembershipCondition.ParseName();
339 if (
object.
Equals(m_name, strongNameMembershipCondition.m_name))
341 if (m_version ==
null && m_element !=
null)
345 if (strongNameMembershipCondition.m_version ==
null && strongNameMembershipCondition.m_element !=
null)
347 strongNameMembershipCondition.ParseVersion();
349 if (
object.
Equals(m_version, strongNameMembershipCondition.m_version))
364 if (m_publicKeyBlob ==
null && m_element !=
null)
368 if (m_publicKeyBlob !=
null)
370 return m_publicKeyBlob.GetHashCode();
372 if (m_name ==
null && m_element !=
null)
376 if (m_version ==
null && m_element !=
null)
380 if (m_name !=
null || m_version !=
null)
382 return ((m_name !=
null) ? m_name.GetHashCode() : 0) + ((!(m_version ==
null)) ? m_version.
GetHashCode() : 0);
override int GetHashCode()
Returns a hash code for the current T:System.Version object.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
string Name
Gets or sets the simple name of the T:System.Security.Policy.StrongName for which the membership cond...
override int GetHashCode()
Returns the hash code for the current T:System.Security.Policy.StrongNameMembershipCondition.
Represents the security policy levels for the common language runtime. This class cannot be inherited...
SecurityElement ToXml()
Creates an XML encoding of the security object and its current state.
Determines whether an assembly belongs to a code group by testing its strong name....
string Tag
Gets or sets the tag name of an XML element.
IMembershipCondition Copy()
Creates an equivalent copy of the current T:System.Security.Policy.StrongNameMembershipCondition.
override string ToString()
Converts the value of the current T:System.Version object to its equivalent T:System....
Provides information about, and means to manipulate, the current environment and platform....
bool Check(Evidence evidence)
Determines whether the specified evidence satisfies the membership condition.
SecurityElement ToXml(PolicyLevel level)
Creates an XML encoding of the security object and its current state with the specified T:System....
Defines the test to determine whether a code assembly is a member of a code group.
override string ToString()
Creates and returns a string representation of the current T:System.Security.Policy....
void FromXml(SecurityElement e)
Reconstructs a security object with a specified state from an XML encoding.
StrongNamePublicKeyBlob PublicKey
Gets or sets the T:System.Security.Permissions.StrongNamePublicKeyBlob of the T:System....
Represents the XML object model for encoding security objects. This class cannot be inherited.
Defines the methods that convert permission object state to and from XML element representation.
Represents the version number of an assembly, operating system, or the common language runtime....
StrongNameMembershipCondition(StrongNamePublicKeyBlob blob, string name, Version version)
Initializes a new instance of the T:System.Security.Policy.StrongNameMembershipCondition class with t...
static CultureInfo CurrentCulture
Gets or sets the T:System.Globalization.CultureInfo object that represents the culture used by the cu...
The exception that is thrown when one of the arguments provided to a method is not valid.
Supports the methods that convert permission object state to and from an XML element representation.
Defines the set of information that constitutes input to security policy decisions....
void AddAttribute(string name, string value)
Adds a name/value attribute to an XML element.
Specifies that the class can be serialized.
void FromXml(SecurityElement e, PolicyLevel level)
Reconstructs a security object with a specified state from an XML encoding.
Provides information about a specific culture (called a locale for unmanaged code development)....
Version Version
Gets or sets the T:System.Version of the T:System.Security.Policy.StrongName for which the membership...
override bool Equals(object o)
Determines whether the T:System.Security.Policy.StrongName from the specified object is equivalent to...
Represents the public key information (called a blob) for a strong name. This class cannot be inherit...