private EvidenceBase GenerateHostEvidence(Type type, bool hostCanGenerate)
 {
     if (hostCanGenerate)
     {
         AppDomain    target   = this.m_target.Target as AppDomain;
         Assembly     assembly = this.m_target.Target as Assembly;
         EvidenceBase base2    = null;
         if (target != null)
         {
             base2 = AppDomain.CurrentDomain.HostSecurityManager.GenerateAppDomainEvidence(type);
         }
         else if (assembly != null)
         {
             base2 = AppDomain.CurrentDomain.HostSecurityManager.GenerateAssemblyEvidence(type, assembly);
         }
         if (base2 != null)
         {
             if (!type.IsAssignableFrom(base2.GetType()))
             {
                 string fullName = AppDomain.CurrentDomain.HostSecurityManager.GetType().FullName;
                 string str2     = base2.GetType().FullName;
                 string str3     = type.FullName;
                 throw new InvalidOperationException(Environment.GetResourceString("Policy_IncorrectHostEvidence", new object[] { fullName, str2, str3 }));
             }
             return(base2);
         }
     }
     return(this.m_target.GenerateEvidence(type));
 }
        /// <summary>
        ///     Verify that evidence being stored in this descriptor is of the correct type
        /// </summary>
        private bool CheckEvidenceType(EvidenceBase evidence)
        {
            Contract.Assert(evidence != null);

            ILegacyEvidenceAdapter legacyAdapter = evidence as ILegacyEvidenceAdapter;
            Type storedType = legacyAdapter == null?evidence.GetType() : legacyAdapter.EvidenceType;

            return(m_evidenceType == null || m_evidenceType.IsAssignableFrom(storedType));
        }
        private static Type GetEvidenceIndexType(EvidenceBase evidence)
        {
            ILegacyEvidenceAdapter adapter = evidence as ILegacyEvidenceAdapter;

            if (adapter != null)
            {
                return(adapter.EvidenceType);
            }
            return(evidence.GetType());
        }
        /// <summary>
        ///     Verify that evidence being stored in this descriptor is of the correct type
        /// </summary>
        private bool CheckEvidenceType(EvidenceBase evidence)
        {
            Contract.Assert(evidence != null);

            ILegacyEvidenceAdapter legacyAdapter = evidence as ILegacyEvidenceAdapter;
            Type storedType = legacyAdapter == null ? evidence.GetType() : legacyAdapter.EvidenceType;

            return m_evidenceType == null || m_evidenceType.IsAssignableFrom(storedType);
        }
        private static EvidenceBase HandleDuplicateEvidence(EvidenceBase original, EvidenceBase duplicate, DuplicateEvidenceAction action)
        {
            switch (action)
            {
            case DuplicateEvidenceAction.Throw:
                throw new InvalidOperationException(Environment.GetResourceString("Policy_DuplicateEvidence", new object[] { duplicate.GetType().FullName }));

            case DuplicateEvidenceAction.Merge:
            {
                LegacyEvidenceList list = original as LegacyEvidenceList;
                if (list == null)
                {
                    list = new LegacyEvidenceList();
                    list.Add(original);
                }
                list.Add(duplicate);
                return(list);
            }

            case DuplicateEvidenceAction.SelectNewObject:
                return(duplicate);
            }
            return(null);
        }