本文整理汇总了C#中System.Security.Policy.Evidence.MergeWithNoDuplicates方法的典型用法代码示例。如果您正苦于以下问题:C# Evidence.MergeWithNoDuplicates方法的具体用法?C# Evidence.MergeWithNoDuplicates怎么用?C# Evidence.MergeWithNoDuplicates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Policy.Evidence
的用法示例。
在下文中一共展示了Evidence.MergeWithNoDuplicates方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSecurityIdentity
private static Evidence CreateSecurityIdentity(SafePEFileHandle peFile, Evidence hostProvidedEvidence)
{
PEFileEvidenceFactory target = new PEFileEvidenceFactory(peFile);
Evidence evidence = new Evidence(target);
if (hostProvidedEvidence != null)
{
evidence.MergeWithNoDuplicates(hostProvidedEvidence);
}
return evidence;
}
示例2: CreateSecurityIdentity
private static Evidence CreateSecurityIdentity(SafePEFileHandle peFile,
Evidence hostProvidedEvidence)
{
PEFileEvidenceFactory evidenceFactory = new PEFileEvidenceFactory(peFile);
Evidence evidence = new Evidence(evidenceFactory);
// If the host (caller of Assembly.Load) provided evidence, merge it with the evidence we've just
// created. The host evidence takes priority.
if (hostProvidedEvidence != null)
{
evidence.MergeWithNoDuplicates(hostProvidedEvidence);
}
return evidence;
}
示例3: CreateSecurityIdentity
private Evidence CreateSecurityIdentity(String url,
byte[] uniqueID,
int zone,
byte[] cert,
byte[] serializedEvidence,
Evidence additionalEvidence)
{
Evidence evidence = new Evidence();
if (zone != -1)
evidence.AddHost( new Zone((SecurityZone)zone) );
if (url != null)
{
evidence.AddHost( new Url(url, true) );
// Only create a site piece of evidence if we are not loading from a file.
if (String.Compare( url, 0, s_localFilePrefix, 0, 5, true, CultureInfo.InvariantCulture) != 0)
evidence.AddHost( Site.CreateFromUrl( url ) );
}
// This code was moved to a different function because:
// 1) it is rarely called so we should only JIT it if we need it.
// 2) it references lots of classes that otherwise aren't loaded.
if (serializedEvidence != null)
DecodeSerializedEvidence( evidence, serializedEvidence );
byte[] blob = nGetPublicKey();
if ((blob != null) &&
(blob.Length != 0))
AddStrongName( evidence, blob );
// If the host (caller of Assembly.Load) provided evidence, merge it
// with the evidence we've just created. The host evidence takes
// priority.
if (additionalEvidence != null)
evidence.MergeWithNoDuplicates(additionalEvidence);
return evidence;
}
示例4: MergeApplicationEvidence
internal static Evidence MergeApplicationEvidence(Evidence evidence,
ApplicationIdentity applicationIdentity,
ActivationContext activationContext,
string[] activationData,
ApplicationTrust applicationTrust)
{
Evidence appEvidence = new Evidence();
ActivationArguments activationArgs = (activationContext == null ? new ActivationArguments(applicationIdentity, activationData) : new ActivationArguments(activationContext, activationData));
appEvidence = new Evidence();
appEvidence.AddHostEvidence(activationArgs);
if (applicationTrust != null)
appEvidence.AddHostEvidence(applicationTrust);
if (activationContext != null)
{
Evidence asiEvidence = new ApplicationSecurityInfo(activationContext).ApplicationEvidence;
if (asiEvidence != null)
appEvidence.MergeWithNoDuplicates(asiEvidence);
}
if (evidence != null)
appEvidence.MergeWithNoDuplicates(evidence);
return appEvidence;
}
示例5: CreateSecurityIdentity
private static System.Security.Policy.Evidence CreateSecurityIdentity(Assembly asm, string strUrl, int zone, byte[] cert, byte[] publicKeyBlob, string strSimpleName, int major, int minor, int build, int revision, byte[] serializedEvidence, System.Security.Policy.Evidence additionalEvidence)
{
System.Security.Policy.Evidence evidence = new System.Security.Policy.Evidence();
if (zone != -1)
{
evidence.AddHost(new Zone((SecurityZone) zone));
}
if (strUrl != null)
{
evidence.AddHost(new Url(strUrl, true));
if (string.Compare(strUrl, 0, "file:", 0, 5, StringComparison.OrdinalIgnoreCase) != 0)
{
evidence.AddHost(Site.CreateFromUrl(strUrl));
}
}
if (cert != null)
{
AddX509Certificate(evidence, cert);
}
if ((asm != null) && RuntimeEnvironment.FromGlobalAccessCache(asm))
{
evidence.AddHost(new GacInstalled());
}
if (serializedEvidence != null)
{
DecodeSerializedEvidence(evidence, serializedEvidence);
}
if ((publicKeyBlob != null) && (publicKeyBlob.Length != 0))
{
AddStrongName(evidence, publicKeyBlob, strSimpleName, major, minor, build, revision, asm);
}
if ((asm != null) && !asm.nIsDynamic())
{
evidence.AddHost(new Hash(asm));
}
if (additionalEvidence != null)
{
evidence.MergeWithNoDuplicates(additionalEvidence);
}
if (asm != null)
{
HostSecurityManager hostSecurityManager = AppDomain.CurrentDomain.HostSecurityManager;
if ((hostSecurityManager.Flags & HostSecurityManagerOptions.HostAssemblyEvidence) == HostSecurityManagerOptions.HostAssemblyEvidence)
{
return hostSecurityManager.ProvideAssemblyEvidence(asm, evidence);
}
}
return evidence;
}
示例6: MergeApplicationEvidence
internal static Evidence MergeApplicationEvidence(Evidence evidence, ApplicationIdentity applicationIdentity, ActivationContext activationContext, string[] activationData, ApplicationTrust applicationTrust)
{
Evidence evidence2 = new Evidence();
ActivationArguments id = (activationContext == null) ? new ActivationArguments(applicationIdentity, activationData) : new ActivationArguments(activationContext, activationData);
evidence2 = new Evidence();
evidence2.AddHost(id);
if (applicationTrust != null)
{
evidence2.AddHost(applicationTrust);
}
if (activationContext != null)
{
Evidence applicationEvidence = new ApplicationSecurityInfo(activationContext).ApplicationEvidence;
if (applicationEvidence != null)
{
evidence2.MergeWithNoDuplicates(applicationEvidence);
}
}
if (evidence != null)
{
evidence2.MergeWithNoDuplicates(evidence);
}
return evidence2;
}
示例7: CreateSecurityIdentity
private static Evidence CreateSecurityIdentity(Assembly asm,
String strUrl,
int zone,
byte[] cert,
byte[] publicKeyBlob,
String strSimpleName,
int major,
int minor,
int build,
int revision,
byte[] serializedEvidence,
Evidence additionalEvidence)
{
Evidence evidence = new Evidence();
if (zone != -1)
evidence.AddHost( new Zone((SecurityZone)zone) );
if (strUrl != null)
{
evidence.AddHost( new Url(strUrl, true) );
// Only create a site piece of evidence if we are not loading from a file.
if (String.Compare( strUrl, 0, s_localFilePrefix, 0, 5, StringComparison.OrdinalIgnoreCase) != 0)
evidence.AddHost( Site.CreateFromUrl( strUrl ) );
}
// Determine if it's in the GAC and add some evidence about it
if(asm != null && System.Runtime.InteropServices.RuntimeEnvironment.FromGlobalAccessCache(asm))
evidence.AddHost( new GacInstalled() );
// This code was moved to a different function because:
// 1) it is rarely called so we should only JIT it if we need it.
// 2) it references lots of classes that otherwise aren't loaded.
if (serializedEvidence != null)
DecodeSerializedEvidence( evidence, serializedEvidence );
if ((publicKeyBlob != null) &&
(publicKeyBlob.Length != 0))
AddStrongName( evidence, publicKeyBlob, strSimpleName, major, minor, build, revision );
// If the host (caller of Assembly.Load) provided evidence, merge it
// with the evidence we've just created. The host evidence takes
// priority.
if (additionalEvidence != null)
evidence.MergeWithNoDuplicates(additionalEvidence);
if (asm != null) {
// The host might want to modify the evidence of the assembly through
// the HostSecurityManager provided in AppDomainManager, so take that into account.
HostSecurityManager securityManager = AppDomain.CurrentDomain.HostSecurityManager;
if ((securityManager.Flags & HostSecurityManagerOptions.HostAssemblyEvidence) == HostSecurityManagerOptions.HostAssemblyEvidence)
return securityManager.ProvideAssemblyEvidence(asm, evidence);
}
return evidence;
}