本文整理汇总了C#中System.Security.Policy.Evidence.GetAssemblyEnumerator方法的典型用法代码示例。如果您正苦于以下问题:C# Evidence.GetAssemblyEnumerator方法的具体用法?C# Evidence.GetAssemblyEnumerator怎么用?C# Evidence.GetAssemblyEnumerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Policy.Evidence
的用法示例。
在下文中一共展示了Evidence.GetAssemblyEnumerator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: GetFactorySuppliedEvidence
public IEnumerable<EvidenceBase> GetFactorySuppliedEvidence()
{
if (this.m_assemblyProvidedEvidence == null)
{
byte[] o = null;
GetAssemblySuppliedEvidence(this.m_peFile, JitHelpers.GetObjectHandleOnStack<byte[]>(ref o));
this.m_assemblyProvidedEvidence = new List<EvidenceBase>();
if (o != null)
{
Evidence evidence = new Evidence();
new SecurityPermission(SecurityPermissionFlag.SerializationFormatter).Assert();
try
{
BinaryFormatter formatter = new BinaryFormatter();
using (MemoryStream stream = new MemoryStream(o))
{
evidence = (Evidence) formatter.Deserialize(stream);
}
}
catch
{
}
CodeAccessPermission.RevertAssert();
if (evidence != null)
{
IEnumerator assemblyEnumerator = evidence.GetAssemblyEnumerator();
while (assemblyEnumerator.MoveNext())
{
if (assemblyEnumerator.Current != null)
{
EvidenceBase current = assemblyEnumerator.Current as EvidenceBase;
if (current == null)
{
current = new LegacyEvidenceWrapper(assemblyEnumerator.Current);
}
this.m_assemblyProvidedEvidence.Add(current);
}
}
}
}
}
return this.m_assemblyProvidedEvidence;
}
示例4: GetFactorySuppliedEvidence
public IEnumerable<EvidenceBase> GetFactorySuppliedEvidence()
{
if (m_assemblyProvidedEvidence == null)
{
byte[] serializedEvidence = null;
GetAssemblySuppliedEvidence(m_peFile, JitHelpers.GetObjectHandleOnStack(ref serializedEvidence));
m_assemblyProvidedEvidence = new List<EvidenceBase>();
if (serializedEvidence != null)
{
Evidence deserializedEvidence = new Evidence();
// Partial trust assemblies can provide their own evidence, so make sure that we have
// permission to deserialize it
new SecurityPermission(SecurityPermissionFlag.SerializationFormatter).Assert();
try
{
BinaryFormatter formatter = new BinaryFormatter();
using (MemoryStream ms = new MemoryStream(serializedEvidence))
{
deserializedEvidence = (Evidence)formatter.Deserialize(ms);
}
}
catch { /* Ignore any errors deserializing */ }
CodeAccessPermission.RevertAssert();
// Enumerate the assembly evidence, ignoring any host evidence supplied. Since we
// could be loading a Whidbey assembly, we need to use the old GetAssemblyEnumerator
// API and deal with objects instead of EvidenceBases.
if (deserializedEvidence != null)
{
IEnumerator enumerator = deserializedEvidence.GetAssemblyEnumerator();
while (enumerator.MoveNext())
{
if (enumerator.Current != null)
{
// If this is a legacy evidence object, we need to wrap it before
// returning it.
EvidenceBase currentEvidence = enumerator.Current as EvidenceBase;
if (currentEvidence == null)
{
currentEvidence = new LegacyEvidenceWrapper(enumerator.Current);
}
m_assemblyProvidedEvidence.Add(currentEvidence);
}
}
}
}
}
return m_assemblyProvidedEvidence;
}
示例5: GetHostAssemblyEnumerator
public void GetHostAssemblyEnumerator ()
{
object[] hostarray = { "host-1", "host-2", "host-3", "host-4" };
object[] asmbarray = { "asmb-1", "asmb-2", "asmb-3", "asmb-4" };
Evidence evidence;
IEnumerator enumerator;
int i;
evidence = new Evidence (hostarray, asmbarray);
enumerator = evidence.GetAssemblyEnumerator ();
i = 0;
while (enumerator.MoveNext()) {
Assert.AreEqual (enumerator.Current, asmbarray[i++]);
}
}
示例6: 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 );
}
}