本文整理汇总了C#中System.Security.Policy.Evidence.AddAssembly方法的典型用法代码示例。如果您正苦于以下问题:C# Evidence.AddAssembly方法的具体用法?C# Evidence.AddAssembly怎么用?C# Evidence.AddAssembly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Policy.Evidence
的用法示例。
在下文中一共展示了Evidence.AddAssembly方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Check
public void Check ()
{
ApplicationDirectoryMembershipCondition ad = new ApplicationDirectoryMembershipCondition ();
Evidence e = null;
Assert.IsFalse (ad.Check (e), "Check (null)");
e = new Evidence ();
Assert.IsFalse (ad.Check (e), "Check (empty)");
e.AddHost (new Zone (SecurityZone.MyComputer));
Assert.IsFalse (ad.Check (e), "Check (zone)");
string codebase = Assembly.GetExecutingAssembly ().CodeBase;
Url u = new Url (codebase);
ApplicationDirectory adir = new ApplicationDirectory (codebase);
e.AddHost (u);
Assert.IsFalse (ad.Check (e), "Check (url-host)"); // not enough
e.AddAssembly (adir);
Assert.IsFalse (ad.Check (e), "Check (url-host+adir-assembly)");
e = new Evidence ();
e.AddHost (adir);
Assert.IsFalse (ad.Check (e), "Check (adir-host)"); // not enough
e.AddAssembly (u);
Assert.IsFalse (ad.Check (e), "Check (url-assembly+adir-host)");
e = new Evidence ();
e.AddHost (u);
e.AddHost (adir);
Assert.IsTrue (ad.Check (e), "Check (url+adir host)"); // both!!
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:30,代码来源:ApplicationDirectoryMembershipConditionTest.cs
示例2: Check
public void Check ()
{
GacMembershipCondition gac = new GacMembershipCondition ();
Evidence e = null;
Assert.IsFalse (gac.Check (e), "Check (null)");
e = new Evidence ();
Assert.IsFalse (gac.Check (e), "Check (empty)");
e.AddHost (new Zone (SecurityZone.MyComputer));
Assert.IsFalse (gac.Check (e), "Check (zone)");
GacInstalled g = new GacInstalled ();
e.AddAssembly (g);
Assert.IsFalse (gac.Check (e), "Check (gac-assembly)");
e.AddHost (g);
Assert.IsTrue (gac.Check (e), "Check (gac-host)");
}
示例3: Check
public void Check ()
{
AllMembershipCondition all = new AllMembershipCondition ();
Evidence e = null;
Assert.IsTrue (all.Check (e), "Check (null)");
e = new Evidence ();
Assert.IsTrue (all.Check (e), "Check (empty)");
e.AddHost (new Zone (SecurityZone.MyComputer));
Assert.IsTrue (all.Check (e), "Check (zone)");
Url u = new Url ("http://www.go-mono.com/");
e.AddAssembly (u);
Assert.IsTrue (all.Check (e), "Check (all-assembly)");
Site s = new Site ("www.go-mono.com");
e.AddHost (s);
Assert.IsTrue (all.Check (e), "Check (all-host)");
}
示例4: AddAssembly
public void AddAssembly ()
{
Evidence evidence = new Evidence ();
object[] comparray = new object[100];
string obj;
for (int i=0; i<100; i++) {
obj = String.Format ("asmb-{0}", i+1);
comparray[i] = obj;
evidence.AddAssembly (obj);
Assert.AreEqual (evidence.Count, i+1);
}
int index = 0;
foreach (object compobj in evidence) {
Assert.AreEqual (comparray[index++], compobj, "Comparison object does not equal evidence assembly object");
}
}
示例5: Check
public void Check ()
{
SiteMembershipCondition smc = new SiteMembershipCondition ("*.go-mono.com");
Evidence e = null;
Assert.IsFalse (smc.Check (e), "Check(null)");
e = new Evidence ();
Assert.IsFalse (smc.Check (e), "Check (empty)");
e.AddHost (new Zone (SecurityZone.MyComputer));
Assert.IsFalse (smc.Check (e), "Check (zone)");
Site s = new Site ("*.go-mono.com");
e.AddAssembly (s);
Assert.IsFalse (smc.Check (e), "Check (site-assembly)");
e.AddHost (s);
Assert.IsTrue (smc.Check (e), "Check (site-host)");
e = new Evidence ();
e.AddHost (new Site ("www.go-mono.com"));
Assert.IsTrue (smc.Check (e), "Check(+-)");
e = new Evidence ();
e.AddHost (new Site ("*.go-mono.org"));
Assert.IsFalse (smc.Check (e), "Check(-)");
}
示例6: Clear
public void Clear ()
{
Evidence e = new Evidence ();
Assert.AreEqual (0, e.Count, "Count-Empty");
e.AddAssembly (new object ());
Assert.AreEqual (1, e.Count, "Count+Assembly");
e.AddHost (new object ());
Assert.AreEqual (2, e.Count, "Count+Host");
e.Clear ();
Assert.AreEqual (0, e.Count, "Count-Cleared");
}
示例7: RemoveType
public void RemoveType ()
{
Evidence e = new Evidence ();
Assert.AreEqual (0, e.Count, "Count-Empty");
e.AddAssembly (new object ());
e.AddHost (new object ());
Assert.AreEqual (2, e.Count, "Count");
e.RemoveType (typeof (object));
Assert.AreEqual (0, e.Count, "Count-RemoveType(object)");
}
示例8: DecodeSerializedEvidence
private static void DecodeSerializedEvidence( Evidence evidence,
byte[] serializedEvidence )
{
BinaryFormatter formatter = new BinaryFormatter();
Evidence asmEvidence = null;
PermissionSet permSet = new PermissionSet( false );
permSet.SetPermission( new SecurityPermission( SecurityPermissionFlag.SerializationFormatter ) );
permSet.PermitOnly();
permSet.Assert();
try {
using(MemoryStream ms = new MemoryStream( serializedEvidence ))
asmEvidence = (Evidence)formatter.Deserialize( ms );
}
catch
{
}
if (asmEvidence != null)
{
IEnumerator enumerator = asmEvidence.GetAssemblyEnumerator();
while (enumerator.MoveNext())
{
Object obj = enumerator.Current;
evidence.AddAssembly( obj );
}
}
}
示例9: Equals_GetHashCode
public void Equals_GetHashCode ()
{
Evidence e1 = new Evidence ();
Evidence e2 = new Evidence ();
Assert.AreEqual (e1.GetHashCode (), e2.GetHashCode (), "GetHashCode-1");
Assert.IsTrue (e1.Equals (e2), "e1.Equals(e2)");
e1.AddAssembly (String.Empty);
e2.AddAssembly (String.Empty);
Assert.AreEqual (e1.GetHashCode (), e2.GetHashCode (), "GetHashCode-2");
e1.AddHost (String.Empty);
e2.AddHost (String.Empty);
Assert.AreEqual (e1.GetHashCode (), e2.GetHashCode (), "GetHashCode-3");
Assert.IsTrue (e2.Equals (e1), "e2.Equals(e1)");
}
示例10: DecodeSerializedEvidence
private void DecodeSerializedEvidence( Evidence evidence,
byte[] serializedEvidence )
{
MemoryStream ms = new MemoryStream( serializedEvidence );
BinaryFormatter formatter = new BinaryFormatter();
Evidence asmEvidence = null;
PermissionSet permSet = new PermissionSet( false );
permSet.SetPermission( new SecurityPermission( SecurityPermissionFlag.SerializationFormatter ) );
permSet.PermitOnly();
permSet.Assert();
try
{
asmEvidence = (Evidence)formatter.Deserialize( ms );
}
catch (Exception)
{
}
if (asmEvidence != null)
{
// Any evidence from the serialized input must:
// 1. be placed in the assembly list since it is unverifiable.
// 2. not be a built in class used as evidence (e.g. Zone, Site, URL, etc.)
IEnumerator enumerator = asmEvidence.GetAssemblyEnumerator();
while (enumerator.MoveNext())
{
Object obj = enumerator.Current;
if (!(obj is Zone || obj is Site || obj is Url || obj is StrongName || obj is PermissionRequestEvidence))
evidence.AddAssembly( obj );
}
}
}
示例11: GetDefaultDomainIdentity
private static Evidence GetDefaultDomainIdentity()
{
Evidence evidence = new Evidence();
bool zoneEvidence = false;
IEnumerator hostEnumerator = AppDomain.CurrentDomain.Evidence.GetHostEnumerator();
while (hostEnumerator.MoveNext())
{
if (hostEnumerator.Current is Zone)
zoneEvidence = true;
evidence.AddHost(hostEnumerator.Current);
}
hostEnumerator = AppDomain.CurrentDomain.Evidence.GetAssemblyEnumerator();
while (hostEnumerator.MoveNext())
{
evidence.AddAssembly(hostEnumerator.Current);
}
if (!zoneEvidence)
evidence.AddHost(new Zone(SecurityZone.MyComputer));
return evidence;
}
示例12: Check
public void Check ()
{
HashMembershipCondition hash = new HashMembershipCondition (md5, digestMd5);
Evidence e = null;
Assert.IsFalse (hash.Check (e), "Check (null)");
e = new Evidence ();
Assert.IsFalse (hash.Check (e), "Check (empty)");
e.AddHost (new Zone (SecurityZone.MyComputer));
Assert.IsFalse (hash.Check (e), "Check (zone)");
e.AddAssembly (hashEvidence);
Assert.IsFalse (hash.Check (e), "Check (hash-assembly)");
e = new Evidence ();
e.AddHost (hashEvidence);
Assert.IsTrue (hash.Check (e), "Check (MD5-host)");
hash = new HashMembershipCondition (sha1, digestSha1);
Assert.IsTrue (hash.Check (e), "Check (SHA1-host)");
}
示例13: ResolveEvidenceAssembly
private void ResolveEvidenceAssembly (SecurityZone zone)
{
string prefix = zone.ToString () + "-";
Evidence e = new Evidence ();
e.AddAssembly (new Zone (zone));
PermissionSet ps = SecurityManager.ResolvePolicy (e);
Assert.AreEqual (0, ps.Count, prefix + "Count");
Assert.IsTrue (ps.IsEmpty (), prefix + "IsEmpty");
Assert.IsFalse (ps.IsUnrestricted (), prefix + "IsUnrestricted");
}
示例14: Check
public void Check ()
{
UrlMembershipCondition umc = new UrlMembershipCondition ("http://www.go-mono.com");
Evidence e = null;
Assert.IsFalse (umc.Check (e), "Check(null)");
e = new Evidence ();
Assert.IsFalse (umc.Check (e), "Check(empty)");
e.AddHost (new Zone (SecurityZone.MyComputer));
Assert.IsFalse (umc.Check (e), "Check(zone)");
Url u = new Url ("http://www.go-mono.com");
e.AddAssembly (u);
Assert.IsFalse (umc.Check (e), "Check(url-assembly)");
e.AddHost (u);
Assert.IsTrue (umc.Check (e), "Check(url-host)");
}
示例15: MakeResourceAssemblyEvidence
internal static void MakeResourceAssemblyEvidence( Evidence input, out Evidence output, out StrongName outputSn )
{
IEnumerator eviEnumerator = input.GetHostEnumerator();
output = new Evidence();
outputSn = null;
while (eviEnumerator.MoveNext())
{
if (eviEnumerator.Current is StrongName)
{
StrongName inputSn = (StrongName)eviEnumerator.Current;
outputSn = new StrongName( inputSn.PublicKey, inputSn.Name + ".resource", inputSn.Version );
output.AddHost( outputSn );
}
else
{
output.AddHost( eviEnumerator.Current );
}
}
eviEnumerator = input.GetAssemblyEnumerator();
while (eviEnumerator.MoveNext())
{
output.AddAssembly( eviEnumerator.Current );
}
}