本文整理汇总了C#中System.Security.Policy.Evidence.GetHostEnumerator方法的典型用法代码示例。如果您正苦于以下问题:C# Evidence.GetHostEnumerator方法的具体用法?C# Evidence.GetHostEnumerator怎么用?C# Evidence.GetHostEnumerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Policy.Evidence
的用法示例。
在下文中一共展示了Evidence.GetHostEnumerator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Check
// Implement the IMembership interface.
public bool Check(Evidence evidence)
{
if(evidence == null)
{
return false;
}
IEnumerator e = evidence.GetHostEnumerator();
IEnumerator e2;
while(e.MoveNext())
{
ApplicationDirectory appDir =
(e.Current as ApplicationDirectory);
if(appDir != null)
{
e2 = evidence.GetHostEnumerator();
while(e2.MoveNext())
{
Url url = (e2.Current as Url);
if(url != null)
{
if(Match(url.parser, appDir.Directory))
{
return true;
}
}
}
}
}
return false;
}
示例2: Check
//------------------------------------------------------
//
// IMEMBERSHIPCONDITION IMPLEMENTATION
//
//------------------------------------------------------
/// <include file='doc\ApplicationDirectoryMembershipCondition.uex' path='docs/doc[@for="ApplicationDirectoryMembershipCondition.Check"]/*' />
public bool Check( Evidence evidence )
{
if (evidence == null)
return false;
IEnumerator enumerator = evidence.GetHostEnumerator();
while (enumerator.MoveNext())
{
Object obj = enumerator.Current;
if (obj is ApplicationDirectory)
{
ApplicationDirectory dir = (ApplicationDirectory)obj;
IEnumerator innerEnumerator = evidence.GetHostEnumerator();
while (innerEnumerator.MoveNext())
{
Object innerObj = innerEnumerator.Current;
if (innerObj is Url)
{
// We need to add a wildcard at the end because IsSubsetOf
// keys off of it.
String appDir = dir.Directory;
if (appDir != null && appDir.Length > 1)
{
if (appDir[appDir.Length-1] == '/')
appDir += "*";
else
appDir += "/*";
URLString appDirString = new URLString( appDir );
if (((Url)innerObj).GetURLString().IsSubsetOf( appDirString ))
{
return true;
}
}
}
}
}
}
return false;
}
示例3: Check
// Methods
public bool Check (Evidence evidence)
{
if (evidence == null)
return false;
string codebase = Assembly.GetCallingAssembly ().CodeBase;
Uri local = new Uri (codebase);
Url ucode = new Url (codebase);
// *both* ApplicationDirectory and Url must be in *Host* evidences
bool adir = false;
bool url = false;
IEnumerator e = evidence.GetHostEnumerator ();
while (e.MoveNext ()) {
object o = e.Current;
if (!adir && (o is ApplicationDirectory)) {
ApplicationDirectory ad = (o as ApplicationDirectory);
string s = ad.Directory;
adir = (String.Compare (s, 0, local.ToString (), 0, s.Length, true, CultureInfo.InvariantCulture) == 0);
}
else if (!url && (o is Url)) {
url = ucode.Equals (o);
}
// got both ?
if (adir && url)
return true;
}
return false;
}
示例4: Resolve
/// <include file='doc\NetCodeGroup.uex' path='docs/doc[@for="NetCodeGroup.Resolve"]/*' />
public override PolicyStatement Resolve( Evidence evidence )
{
if (evidence == null)
throw new ArgumentNullException("evidence");
if (this.MembershipCondition.Check( evidence ))
{
PolicyStatement thisPolicy = null;
IEnumerator evidenceEnumerator = evidence.GetHostEnumerator();
Site site = null;
while (evidenceEnumerator.MoveNext())
{
Url url = evidenceEnumerator.Current as Url;
if (url != null)
{
thisPolicy = CalculatePolicy( url.GetURLString().Host, url.GetURLString().Scheme );
}
else
{
if (site == null)
site = evidenceEnumerator.Current as Site;
}
}
if (thisPolicy == null && site != null)
thisPolicy = CalculatePolicy( site.Name, null );
if (thisPolicy == null)
thisPolicy = new PolicyStatement( new PermissionSet( false ), PolicyStatementAttribute.Nothing );
IEnumerator enumerator = this.Children.GetEnumerator();
while (enumerator.MoveNext())
{
PolicyStatement childPolicy = ((CodeGroup)enumerator.Current).Resolve( evidence );
if (childPolicy != null)
{
if (((thisPolicy.Attributes & childPolicy.Attributes) & PolicyStatementAttribute.Exclusive) == PolicyStatementAttribute.Exclusive)
{
throw new PolicyException( Environment.GetResourceString( "Policy_MultipleExclusive" ) );
}
thisPolicy.GetPermissionSetNoCopy().InplaceUnion( childPolicy.GetPermissionSetNoCopy() );
thisPolicy.Attributes = thisPolicy.Attributes | childPolicy.Attributes;
}
}
return thisPolicy;
}
else
{
return null;
}
}
示例5: EvidenceCallMethods
public static void EvidenceCallMethods()
{
Evidence e = new Evidence();
e = new Evidence(new Evidence());
e.Clear();
Evidence e2 = e.Clone();
System.Collections.IEnumerator ie = e.GetAssemblyEnumerator();
ie = e.GetHostEnumerator();
e.Merge(e2);
}
示例6: Check
public bool Check (Evidence evidence)
{
if (evidence == null)
return false;
IEnumerator e = evidence.GetHostEnumerator ();
while (e.MoveNext ()) {
// TODO: from samples it seems related to IApplicationDescription and HostContext
// but some are obsoleted - so this should be moving to ApplicationIdentity ?
}
return false;
}
示例7: DefaultConstructor
public void DefaultConstructor ()
{
Evidence evidence = new Evidence ();
AssertEquals ("Default constructor count should be zero", evidence.Count, 0);
AssertEquals ("Default constructor host enumerator MoveNext() should be false",
evidence.GetHostEnumerator().MoveNext(), false);
AssertEquals ("Default constructor assembly enumerator MoveNext() should be false",
evidence.GetAssemblyEnumerator().MoveNext(), false);
AssertEquals ("Default constructor enumerator MoveNext() should be false",
evidence.GetEnumerator().MoveNext(), false);
}
示例8: Check
public bool Check (Evidence evidence)
{
if (evidence == null)
return false;
// true only if Gac is in host-supplied evidences
IEnumerator e = evidence.GetHostEnumerator ();
while (e.MoveNext ()) {
if (e.Current is GacInstalled)
return true;
}
return false;
}
示例9: Check
public bool Check (Evidence evidence)
{
if (evidence == null)
return false;
IEnumerator e = evidence.GetHostEnumerator ();
while (e.MoveNext ()) {
if (e.Current is Publisher) {
if (x509.Equals ((e.Current as Publisher).Certificate))
return true;
}
}
return false;
}
示例10: Check
//------------------------------------------------------
//
// IMEMBERSHIPCONDITION IMPLEMENTATION
//
//------------------------------------------------------
public bool Check( Evidence evidence )
{
if (evidence == null)
return false;
IEnumerator enumerator = evidence.GetHostEnumerator();
while (enumerator.MoveNext())
{
Object obj = enumerator.Current;
if (obj is GacInstalled)
return true;
}
return false;
}
示例11: Check
public bool Check (Evidence evidence)
{
if (evidence == null)
return false;
IEnumerator e = evidence.GetHostEnumerator ();
while (e.MoveNext ()) {
Zone z = (e.Current as Zone);
if (z != null) {
if (z.SecurityZone == zone)
return true;
}
}
return false;
}
示例12: Check
// Implement the IMembership interface.
public bool Check(Evidence evidence)
{
if(evidence == null)
{
return false;
}
IEnumerator e = evidence.GetHostEnumerator();
while(e.MoveNext())
{
Publisher publisher = (e.Current as Publisher);
if(publisher != null &&
publisher.Certificate.Equals(certificate))
{
return true;
}
}
return false;
}
示例13: Check
// Implement the IMembership interface.
public bool Check(Evidence evidence)
{
if(evidence == null)
{
return false;
}
IEnumerator e = evidence.GetHostEnumerator();
while(e.MoveNext())
{
Site s = (e.Current as Site);
if(s != null)
{
if(UrlParser.HostMatches(site, s.Name))
{
return true;
}
}
}
return false;
}
示例14: Check
// Implement the IMembership interface.
public bool Check(Evidence evidence)
{
if(evidence == null)
{
return false;
}
IEnumerator e = evidence.GetHostEnumerator();
while(e.MoveNext())
{
Url url = (e.Current as Url);
if(url != null)
{
if(parser.Matches(url.parser))
{
return true;
}
}
}
return false;
}
示例15: Check
// methods
public bool Check (Evidence evidence)
{
if (evidence == null)
return false;
IEnumerator e = evidence.GetHostEnumerator ();
while (e.MoveNext ()) {
if (e.Current is Site) {
string[] s1 = _site.Split ('.');
string[] s2 = (e.Current as Site).origin_site.Split ('.');
for (int i = s1.Length - 1, j = s2.Length - 1; i>=0; i--, j--) {
if (i == 0) {
// special * case
return (String.Compare (s1 [0], "*", true, CultureInfo.InvariantCulture) == 0);
}
if (String.Compare (s1 [i], s2 [j], true, CultureInfo.InvariantCulture) != 0)
return false;
}
return true;
}
}
return false;
}