mscorlib(4.0.0.0) API with additions
GacMembershipCondition.cs
2 using System.Security.Util;
3 
5 {
8  [ComVisible(true)]
9  public sealed class GacMembershipCondition : IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable, IConstantMembershipCondition, IReportMatchMembershipCondition
10  {
15  public bool Check(Evidence evidence)
16  {
17  object usedEvidence = null;
18  return ((IReportMatchMembershipCondition)this).Check(evidence, out usedEvidence);
19  }
20 
21  bool IReportMatchMembershipCondition.Check(Evidence evidence, out object usedEvidence)
22  {
23  usedEvidence = null;
24  if (evidence == null)
25  {
26  return false;
27  }
28  return evidence.GetHostEvidence<GacInstalled>() != null;
29  }
30 
34  {
35  return new GacMembershipCondition();
36  }
37 
41  {
42  return ToXml(null);
43  }
44 
51  public void FromXml(SecurityElement e)
52  {
53  FromXml(e, null);
54  }
55 
60  {
61  SecurityElement securityElement = new SecurityElement("IMembershipCondition");
62  XMLUtil.AddClassAttribute(securityElement, GetType(), GetType().FullName);
63  securityElement.AddAttribute("version", "1");
64  return securityElement;
65  }
66 
74  public void FromXml(SecurityElement e, PolicyLevel level)
75  {
76  if (e == null)
77  {
78  throw new ArgumentNullException("e");
79  }
80  if (!e.Tag.Equals("IMembershipCondition"))
81  {
82  throw new ArgumentException(Environment.GetResourceString("Argument_MembershipConditionElement"));
83  }
84  }
85 
90  public override bool Equals(object o)
91  {
92  GacMembershipCondition gacMembershipCondition = o as GacMembershipCondition;
93  if (gacMembershipCondition != null)
94  {
95  return true;
96  }
97  return false;
98  }
99 
102  public override int GetHashCode()
103  {
104  return 0;
105  }
106 
109  public override string ToString()
110  {
111  return Environment.GetResourceString("GAC_ToString");
112  }
113  }
114 }
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
override string ToString()
Returns a string representation of the membership condition.
Represents the security policy levels for the common language runtime. This class cannot be inherited...
Definition: PolicyLevel.cs:15
Definition: __Canon.cs:3
void FromXml(SecurityElement e, PolicyLevel level)
Uses the specified XML encoding to reconstruct a security object, using the specified policy level co...
SecurityElement ToXml(PolicyLevel level)
Creates an XML encoding of the security object and its current state, using the specified policy leve...
string Tag
Gets or sets the tag name of an XML element.
IMembershipCondition Copy()
Creates an equivalent copy of the membership condition.
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
Defines the test to determine whether a code assembly is a member of a code group.
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.
void FromXml(SecurityElement e)
Uses the specified XML encoding to reconstruct a security object.
SecurityElement ToXml()
Creates an XML encoding of the security object and its current state.
override bool Equals(object o)
Indicates whether the current object is equivalent to the specified object.
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.
bool Check(Evidence evidence)
Indicates whether the specified evidence satisfies the membership condition.
Defines the set of information that constitutes input to security policy decisions....
Definition: Evidence.cs:17
void AddAttribute(string name, string value)
Adds a name/value attribute to an XML element.
Specifies that the class can be serialized.
Determines whether an assembly belongs to a code group by testing its global assembly cache membershi...
override int GetHashCode()
Gets a hash code for the current membership condition.