19 private enum DuplicateEvidenceAction
36 private LockType m_lockType;
38 public EvidenceLockHolder(
Evidence target, LockType lockType)
41 m_lockType = lockType;
42 if (m_lockType == LockType.Reader)
44 m_target.AcquireReaderLock();
48 m_target.AcquireWriterlock();
54 if (m_lockType == LockType.Reader && m_target.IsReaderLockHeld)
56 m_target.ReleaseReaderLock();
58 else if (m_lockType == LockType.Writer && m_target.IsWriterLockHeld)
60 m_target.ReleaseWriterLock();
65 private class EvidenceUpgradeLockHolder :
IDisposable 71 public EvidenceUpgradeLockHolder(
Evidence target)
74 m_cookie = m_target.UpgradeToWriterLock();
79 if (m_target.IsWriterLockHeld)
81 m_target.DowngradeFromWriterLock(ref m_cookie);
90 private bool m_hostEnumerator;
92 private uint m_evidenceVersion;
94 private Type[] m_evidenceTypes;
96 private int m_typeIndex;
100 private static volatile List<Type> s_expensiveEvidence;
106 if (m_evidence.m_version != m_evidenceVersion)
110 return m_currentEvidence;
118 if (m_evidence.m_version != m_evidenceVersion)
122 return m_currentEvidence;
130 if (s_expensiveEvidence ==
null)
133 list.Add(typeof(
Hash));
135 s_expensiveEvidence = list;
137 return s_expensiveEvidence;
143 m_evidence = evidence;
144 m_hostEnumerator = hostEnumerator;
145 m_evidenceTypes = GenerateEvidenceTypes(evidence, evidenceTypes, hostEnumerator);
146 m_evidenceVersion = evidence.m_version;
150 public void Dispose()
159 foreach (
Type evidenceType
in evidenceTypes)
161 EvidenceTypeDescriptor evidenceTypeDescriptor = evidence.GetEvidenceTypeDescriptor(evidenceType);
162 if ((hostEvidence && evidenceTypeDescriptor.HostEvidence !=
null) || (!hostEvidence && evidenceTypeDescriptor.AssemblyEvidence !=
null))
164 list.Add(evidenceType);
166 else if (ExpensiveEvidence.Contains(evidenceType))
168 list3.Add(evidenceType);
172 list2.Add(evidenceType);
175 Type[] array =
new Type[list.Count + list2.Count + list3.Count];
176 list.CopyTo(array, 0);
177 list2.CopyTo(array, list.Count);
178 list3.CopyTo(array, list.Count + list2.Count);
182 [SecuritySafeCritical]
183 public bool MoveNext()
185 using (
new EvidenceLockHolder(m_evidence, EvidenceLockHolder.LockType.Reader))
187 if (m_evidence.m_version != m_evidenceVersion)
191 m_currentEvidence =
null;
195 if (m_typeIndex < m_evidenceTypes.Length)
197 if (m_hostEnumerator)
199 m_currentEvidence = m_evidence.GetHostEvidenceNoLock(m_evidenceTypes[m_typeIndex]);
203 m_currentEvidence = m_evidence.GetAssemblyEvidenceNoLock(m_evidenceTypes[m_typeIndex]);
207 while (m_typeIndex < m_evidenceTypes.Length && m_currentEvidence ==
null);
209 return m_currentEvidence !=
null;
214 if (m_evidence.m_version != m_evidenceVersion)
219 m_currentEvidence =
null;
223 private sealed
class EvidenceEnumerator :
IEnumerator 226 internal enum Category
234 private Category m_category;
236 private Stack m_enumerators;
238 private object m_currentEvidence;
240 public object Current => m_currentEvidence;
246 if (m_enumerators.
Count <= 0)
254 internal EvidenceEnumerator(
Evidence evidence, Category category)
256 m_evidence = evidence;
257 m_category = category;
261 public bool MoveNext()
264 if (currentEnumerator ==
null)
266 m_currentEvidence =
null;
271 LegacyEvidenceWrapper legacyEvidenceWrapper = currentEnumerator.
Current as LegacyEvidenceWrapper;
272 LegacyEvidenceList legacyEvidenceList = currentEnumerator.
Current as LegacyEvidenceList;
273 if (legacyEvidenceWrapper !=
null)
275 m_currentEvidence = legacyEvidenceWrapper.EvidenceObject;
277 else if (legacyEvidenceList !=
null)
279 IEnumerator enumerator = legacyEvidenceList.GetEnumerator();
280 m_enumerators.
Push(enumerator);
285 m_currentEvidence = currentEnumerator.
Current;
295 using (
new EvidenceLockHolder(m_evidence, EvidenceLockHolder.LockType.Reader))
301 private void ResetNoLock()
303 m_currentEvidence =
null;
304 m_enumerators =
new Stack();
305 if ((m_category & Category.Host) == Category.Host)
307 m_enumerators.
Push(m_evidence.GetRawHostEvidenceEnumerator());
309 if ((m_category & Category.Assembly) == Category.Assembly)
311 m_enumerators.
Push(m_evidence.GetRawAssemblyEvidenceEnumerator());
316 [OptionalField(VersionAdded = 4)]
319 [OptionalField(VersionAdded = 4)]
320 private bool m_deserializedTargetEvidence;
324 private volatile ArrayList m_assemblyList;
330 private uint m_version;
333 private IRuntimeEvidenceFactory m_target;
335 private bool m_locked;
340 private static volatile Type[] s_runtimeEvidenceTypes;
342 private const int LockTimeout = 5000;
344 internal static Type[] RuntimeEvidenceTypes
348 if (s_runtimeEvidenceTypes ==
null)
365 int num = array.Length;
366 Array.Resize(ref array, num + 1);
369 s_runtimeEvidenceTypes = array;
371 return s_runtimeEvidenceTypes;
375 private bool IsReaderLockHeld
379 if (m_evidenceLock !=
null)
387 private bool IsWriterLockHeld
391 if (m_evidenceLock !=
null)
399 internal bool IsUnmodified => m_version == 0;
410 [SecuritySafeCritical]
425 internal IRuntimeEvidenceFactory Target
434 using (
new EvidenceLockHolder(
this, EvidenceLockHolder.LockType.Writer))
437 QueryHostForPossibleEvidenceTypes();
444 [Obsolete(
"Evidence should not be treated as an ICollection. Please use GetHostEnumerator and GetAssemblyEnumerator to iterate over the evidence to collect a count.")]
456 while (assemblyEnumerator.
MoveNext())
465 internal int RawCount
470 using (
new EvidenceLockHolder(
this, EvidenceLockHolder.LockType.Reader))
474 EvidenceTypeDescriptor evidenceTypeDescriptor = GetEvidenceTypeDescriptor(item);
475 if (evidenceTypeDescriptor !=
null)
477 if (evidenceTypeDescriptor.AssemblyEvidence !=
null)
481 if (evidenceTypeDescriptor.HostEvidence !=
null)
517 if (evidence !=
null)
519 using (
new EvidenceLockHolder(evidence, EvidenceLockHolder.LockType.Reader))
523 EvidenceTypeDescriptor evidenceTypeDescriptor = item.Value;
524 if (evidenceTypeDescriptor !=
null)
526 evidenceTypeDescriptor = evidenceTypeDescriptor.Clone();
528 m_evidence[item.Key] = evidenceTypeDescriptor;
530 m_target = evidence.m_target;
531 m_locked = evidence.m_locked;
532 m_deserializedTargetEvidence = evidence.m_deserializedTargetEvidence;
533 if (evidence.Target !=
null)
545 [Obsolete(
"This constructor is obsolete. Please use the constructor which takes arrays of EvidenceBase instead.")]
546 public Evidence(
object[] hostEvidence,
object[] assemblyEvidence)
549 if (hostEvidence !=
null)
551 foreach (
object id in hostEvidence)
556 if (assemblyEvidence !=
null)
558 foreach (
object id2
in assemblyEvidence)
572 if (hostEvidence !=
null)
576 AddHostEvidence(evidence, GetEvidenceIndexType(evidence), DuplicateEvidenceAction.Throw);
579 if (assemblyEvidence !=
null)
583 AddAssemblyEvidence(evidence2, GetEvidenceIndexType(evidence2), DuplicateEvidenceAction.Throw);
589 [SecuritySafeCritical]
590 internal Evidence(IRuntimeEvidenceFactory target)
594 Type[] runtimeEvidenceTypes = RuntimeEvidenceTypes;
595 foreach (
Type key
in runtimeEvidenceTypes)
597 m_evidence[key] =
null;
599 QueryHostForPossibleEvidenceTypes();
603 private void AcquireReaderLock()
605 if (m_evidenceLock !=
null)
611 private void AcquireWriterlock()
613 if (m_evidenceLock !=
null)
619 private void DowngradeFromWriterLock(ref
LockCookie lockCookie)
621 if (m_evidenceLock !=
null)
629 if (m_evidenceLock ==
null)
636 private void ReleaseReaderLock()
638 if (m_evidenceLock !=
null)
644 private void ReleaseWriterLock()
646 if (m_evidenceLock !=
null)
658 [Obsolete(
"This method is obsolete. Please use AddHostEvidence instead.")]
659 [SecuritySafeCritical]
666 if (!
id.GetType().IsSerializable)
675 Type evidenceIndexType = GetEvidenceIndexType(evidence);
676 AddHostEvidence(evidence, evidenceIndexType, DuplicateEvidenceAction.Merge);
685 [Obsolete(
"This method is obsolete. Please use AddAssemblyEvidence instead.")]
692 if (!
id.GetType().IsSerializable)
697 Type evidenceIndexType = GetEvidenceIndexType(evidence);
698 AddAssemblyEvidence(evidence, evidenceIndexType, DuplicateEvidenceAction.Merge);
712 if (evidence ==
null)
716 Type evidenceType = typeof(
T);
717 if (typeof(
T) == typeof(
EvidenceBase) || evidence is ILegacyEvidenceAdapter)
719 evidenceType = GetEvidenceIndexType(evidence);
721 AddAssemblyEvidence(evidence, evidenceType, DuplicateEvidenceAction.Throw);
724 private void AddAssemblyEvidence(
EvidenceBase evidence,
Type evidenceType, DuplicateEvidenceAction duplicateAction)
726 using (
new EvidenceLockHolder(
this, EvidenceLockHolder.LockType.Writer))
728 AddAssemblyEvidenceNoLock(evidence, evidenceType, duplicateAction);
732 private void AddAssemblyEvidenceNoLock(EvidenceBase evidence,
Type evidenceType, DuplicateEvidenceAction duplicateAction)
734 DeserializeTargetEvidence();
735 EvidenceTypeDescriptor evidenceTypeDescriptor = GetEvidenceTypeDescriptor(evidenceType, addIfNotExist:
true);
737 if (evidenceTypeDescriptor.AssemblyEvidence ==
null)
739 evidenceTypeDescriptor.AssemblyEvidence = evidence;
743 evidenceTypeDescriptor.AssemblyEvidence = HandleDuplicateEvidence(evidenceTypeDescriptor.AssemblyEvidence, evidence, duplicateAction);
756 if (evidence ==
null)
760 Type evidenceType = typeof(
T);
761 if (typeof(
T) == typeof(
EvidenceBase) || evidence is ILegacyEvidenceAdapter)
763 evidenceType = GetEvidenceIndexType(evidence);
765 AddHostEvidence(evidence, evidenceType, DuplicateEvidenceAction.Throw);
768 [SecuritySafeCritical]
769 private void AddHostEvidence(
EvidenceBase evidence,
Type evidenceType, DuplicateEvidenceAction duplicateAction)
775 using (
new EvidenceLockHolder(
this, EvidenceLockHolder.LockType.Writer))
777 AddHostEvidenceNoLock(evidence, evidenceType, duplicateAction);
781 private void AddHostEvidenceNoLock(EvidenceBase evidence, Type evidenceType, DuplicateEvidenceAction duplicateAction)
783 EvidenceTypeDescriptor evidenceTypeDescriptor = GetEvidenceTypeDescriptor(evidenceType, addIfNotExist:
true);
785 if (evidenceTypeDescriptor.HostEvidence ==
null)
787 evidenceTypeDescriptor.HostEvidence = evidence;
791 evidenceTypeDescriptor.HostEvidence = HandleDuplicateEvidence(evidenceTypeDescriptor.HostEvidence, evidence, duplicateAction);
796 private void QueryHostForPossibleEvidenceTypes()
798 if (
AppDomain.CurrentDomain.DomainManager ==
null)
802 HostSecurityManager hostSecurityManager =
AppDomain.CurrentDomain.DomainManager.HostSecurityManager;
803 if (hostSecurityManager ==
null)
812 array = hostSecurityManager.GetHostSuppliedAssemblyEvidenceTypes(assembly);
816 array = hostSecurityManager.GetHostSuppliedAppDomainEvidenceTypes();
820 Type[] array2 = array;
821 foreach (Type evidenceType
in array2)
823 EvidenceTypeDescriptor evidenceTypeDescriptor = GetEvidenceTypeDescriptor(evidenceType, addIfNotExist:
true);
824 evidenceTypeDescriptor.HostCanGenerate =
true;
829 private static Type GetEvidenceIndexType(EvidenceBase evidence)
831 ILegacyEvidenceAdapter legacyEvidenceAdapter = evidence as ILegacyEvidenceAdapter;
832 if (legacyEvidenceAdapter !=
null)
834 return legacyEvidenceAdapter.EvidenceType;
836 return evidence.GetType();
839 internal EvidenceTypeDescriptor GetEvidenceTypeDescriptor(Type evidenceType)
841 return GetEvidenceTypeDescriptor(evidenceType, addIfNotExist:
false);
844 private EvidenceTypeDescriptor GetEvidenceTypeDescriptor(Type evidenceType,
bool addIfNotExist)
846 EvidenceTypeDescriptor value =
null;
847 if (!m_evidence.
TryGetValue(evidenceType, out value) && !addIfNotExist)
853 value =
new EvidenceTypeDescriptor();
858 if (!IsWriterLockHeld)
860 lockCookie = UpgradeToWriterLock();
863 m_evidence[evidenceType] = value;
870 DowngradeFromWriterLock(ref lockCookie);
877 private static EvidenceBase HandleDuplicateEvidence(EvidenceBase original, EvidenceBase duplicate, DuplicateEvidenceAction action)
881 case DuplicateEvidenceAction.Throw:
882 throw new InvalidOperationException(Environment.GetResourceString(
"Policy_DuplicateEvidence", duplicate.GetType().FullName));
883 case DuplicateEvidenceAction.SelectNewObject:
885 case DuplicateEvidenceAction.Merge:
887 LegacyEvidenceList legacyEvidenceList = original as LegacyEvidenceList;
888 if (legacyEvidenceList ==
null)
890 legacyEvidenceList =
new LegacyEvidenceList();
891 legacyEvidenceList.Add(original);
893 legacyEvidenceList.Add(duplicate);
894 return legacyEvidenceList;
901 private static EvidenceBase WrapLegacyEvidence(
object evidence)
903 EvidenceBase evidenceBase = evidence as EvidenceBase;
904 if (evidenceBase ==
null)
906 evidenceBase =
new LegacyEvidenceWrapper(evidence);
911 private static object UnwrapEvidence(EvidenceBase evidence)
913 ILegacyEvidenceAdapter legacyEvidenceAdapter = evidence as ILegacyEvidenceAdapter;
914 if (legacyEvidenceAdapter !=
null)
916 return legacyEvidenceAdapter.EvidenceObject;
926 [SecuritySafeCritical]
929 if (evidence !=
null)
931 using (
new EvidenceLockHolder(
this, EvidenceLockHolder.LockType.Writer))
945 GetHostEvidenceNoLock(type);
948 AddHostEvidenceNoLock(evidence2, GetEvidenceIndexType(evidence2), DuplicateEvidenceAction.Merge);
951 while (assemblyEnumerator.
MoveNext())
954 AddAssemblyEvidenceNoLock(evidence3, GetEvidenceIndexType(evidence3), DuplicateEvidenceAction.Merge);
960 internal void MergeWithNoDuplicates(
Evidence evidence)
962 if (evidence !=
null)
964 using (
new EvidenceLockHolder(
this, EvidenceLockHolder.LockType.Writer))
970 AddHostEvidenceNoLock(evidence2, GetEvidenceIndexType(evidence2), DuplicateEvidenceAction.SelectNewObject);
973 while (assemblyEnumerator.
MoveNext())
975 EvidenceBase evidence3 = WrapLegacyEvidence(assemblyEnumerator.
Current);
976 AddAssemblyEvidenceNoLock(evidence3, GetEvidenceIndexType(evidence3), DuplicateEvidenceAction.SelectNewObject);
988 using (
new EvidenceLockHolder(
this, EvidenceLockHolder.LockType.Reader))
992 GetHostEvidenceNoLock(item);
994 DeserializeTargetEvidence();
1002 m_hostList = arrayList;
1005 while (assemblyEnumerator.
MoveNext())
1009 m_assemblyList = arrayList2;
1017 if (m_evidence ==
null)
1020 if (m_hostList !=
null)
1022 foreach (
object host
in m_hostList)
1031 if (m_assemblyList !=
null)
1033 foreach (
object assembly
in m_assemblyList)
1035 if (assembly !=
null)
1040 m_assemblyList =
null;
1046 private void DeserializeTargetEvidence()
1048 if (m_target !=
null && !m_deserializedTargetEvidence)
1054 if (!IsWriterLockHeld)
1056 lockCookie = UpgradeToWriterLock();
1059 m_deserializedTargetEvidence =
true;
1060 foreach (EvidenceBase item
in m_target.GetFactorySuppliedEvidence())
1062 AddAssemblyEvidenceNoLock(item, GetEvidenceIndexType(item), DuplicateEvidenceAction.Throw);
1069 DowngradeFromWriterLock(ref lockCookie);
1076 internal byte[] RawSerialize()
1080 using (
new EvidenceLockHolder(
this, EvidenceLockHolder.LockType.Reader))
1085 if (item.Value !=
null && item.Value.HostEvidence !=
null)
1087 dictionary[item.Key] = item.Value.HostEvidence;
1093 binaryFormatter.
Serialize(memoryStream, dictionary);
1094 return memoryStream.
ToArray();
1098 catch (SecurityException)
1111 [Obsolete(
"Evidence should not be treated as an ICollection. Please use the GetHostEnumerator and GetAssemblyEnumerator methods rather than using CopyTo.")]
1118 if (index < 0 || index > array.Length -
Count)
1126 array.SetValue(hostEnumerator.
Current, num);
1130 while (assemblyEnumerator.
MoveNext())
1132 array.SetValue(assemblyEnumerator.
Current, num);
1141 using (
new EvidenceLockHolder(
this, EvidenceLockHolder.LockType.Reader))
1143 return new EvidenceEnumerator(
this, EvidenceEnumerator.Category.Host);
1151 using (
new EvidenceLockHolder(
this, EvidenceLockHolder.LockType.Reader))
1153 DeserializeTargetEvidence();
1154 return new EvidenceEnumerator(
this, EvidenceEnumerator.Category.Assembly);
1158 internal RawEvidenceEnumerator GetRawAssemblyEvidenceEnumerator()
1160 DeserializeTargetEvidence();
1161 return new RawEvidenceEnumerator(
this,
new List<Type>(m_evidence.Keys), hostEnumerator:
false);
1164 internal RawEvidenceEnumerator GetRawHostEvidenceEnumerator()
1166 return new RawEvidenceEnumerator(
this,
new List<Type>(m_evidence.Keys), hostEnumerator:
true);
1171 [Obsolete(
"GetEnumerator is obsolete. Please use GetAssemblyEnumerator and GetHostEnumerator instead.")]
1174 using (
new EvidenceLockHolder(
this, EvidenceLockHolder.LockType.Reader))
1176 return new EvidenceEnumerator(
this, EvidenceEnumerator.Category.Host | EvidenceEnumerator.Category.Assembly);
1186 return UnwrapEvidence(GetAssemblyEvidence(typeof(
T))) as
T;
1191 using (
new EvidenceLockHolder(
this, EvidenceLockHolder.LockType.Reader))
1193 return GetAssemblyEvidenceNoLock(type);
1197 private EvidenceBase GetAssemblyEvidenceNoLock(
Type type)
1199 DeserializeTargetEvidence();
1200 return GetEvidenceTypeDescriptor(type)?.AssemblyEvidence;
1209 return UnwrapEvidence(GetHostEvidence(typeof(
T))) as
T;
1212 internal T GetDelayEvaluatedHostEvidence<T>() where T :
EvidenceBase, IDelayEvaluatedEvidence
1214 return UnwrapEvidence(GetHostEvidence(typeof(T), markDelayEvaluatedEvidenceUsed:
false)) as
T;
1217 internal EvidenceBase GetHostEvidence(
Type type)
1219 return GetHostEvidence(type, markDelayEvaluatedEvidenceUsed:
true);
1222 [SecuritySafeCritical]
1223 private EvidenceBase GetHostEvidence(
Type type,
bool markDelayEvaluatedEvidenceUsed)
1225 using (
new EvidenceLockHolder(
this, EvidenceLockHolder.LockType.Reader))
1227 EvidenceBase hostEvidenceNoLock = GetHostEvidenceNoLock(type);
1228 if (markDelayEvaluatedEvidenceUsed)
1230 (hostEvidenceNoLock as IDelayEvaluatedEvidence)?.MarkUsed();
1232 return hostEvidenceNoLock;
1237 private EvidenceBase GetHostEvidenceNoLock(Type type)
1239 EvidenceTypeDescriptor evidenceTypeDescriptor = GetEvidenceTypeDescriptor(type);
1240 if (evidenceTypeDescriptor ==
null)
1244 if (evidenceTypeDescriptor.HostEvidence !=
null)
1246 return evidenceTypeDescriptor.HostEvidence;
1248 if (m_target !=
null && !evidenceTypeDescriptor.Generated)
1250 using (
new EvidenceUpgradeLockHolder(
this))
1252 evidenceTypeDescriptor.Generated =
true;
1253 EvidenceBase evidenceBase = GenerateHostEvidence(type, evidenceTypeDescriptor.HostCanGenerate);
1254 if (evidenceBase !=
null)
1256 evidenceTypeDescriptor.HostEvidence = evidenceBase;
1257 Evidence evidence = (m_cloneOrigin !=
null) ? (m_cloneOrigin.Target as
Evidence) :
null;
1258 if (evidence !=
null)
1260 using (
new EvidenceLockHolder(evidence, EvidenceLockHolder.LockType.Writer))
1262 EvidenceTypeDescriptor evidenceTypeDescriptor2 = evidence.GetEvidenceTypeDescriptor(type);
1263 if (evidenceTypeDescriptor2 !=
null && evidenceTypeDescriptor2.HostEvidence ==
null)
1265 evidenceTypeDescriptor2.HostEvidence = evidenceBase.Clone();
1270 return evidenceBase;
1277 private EvidenceBase GenerateHostEvidence(Type type,
bool hostCanGenerate)
1279 if (hostCanGenerate)
1283 EvidenceBase evidenceBase =
null;
1284 if (appDomain !=
null)
1286 evidenceBase =
AppDomain.CurrentDomain.HostSecurityManager.GenerateAppDomainEvidence(type);
1288 else if (assembly !=
null)
1290 evidenceBase =
AppDomain.CurrentDomain.HostSecurityManager.GenerateAssemblyEvidence(type, assembly);
1292 if (evidenceBase !=
null)
1294 if (!type.IsAssignableFrom(evidenceBase.GetType()))
1296 string fullName =
AppDomain.CurrentDomain.HostSecurityManager.GetType().FullName;
1297 string fullName2 = evidenceBase.GetType().FullName;
1298 string fullName3 = type.FullName;
1299 throw new InvalidOperationException(Environment.GetResourceString(
"Policy_IncorrectHostEvidence", fullName, fullName2, fullName3));
1301 return evidenceBase;
1304 return m_target.GenerateEvidence(type);
1317 [SecuritySafeCritical]
1324 using (
new EvidenceLockHolder(
this, EvidenceLockHolder.LockType.Writer))
1336 [SecuritySafeCritical]
1343 using (
new EvidenceLockHolder(
this, EvidenceLockHolder.LockType.Writer))
1345 EvidenceTypeDescriptor evidenceTypeDescriptor = GetEvidenceTypeDescriptor(t);
1346 if (evidenceTypeDescriptor !=
null)
1349 if (
Locked && (evidenceTypeDescriptor.HostEvidence !=
null || evidenceTypeDescriptor.HostCanGenerate))
1353 m_evidence.Remove(t);
1358 internal void MarkAllEvidenceAsUsed()
1360 using (
new EvidenceLockHolder(
this, EvidenceLockHolder.LockType.Reader))
1364 if (item.Value !=
null)
1366 (item.Value.HostEvidence as IDelayEvaluatedEvidence)?.MarkUsed();
1367 (item.Value.AssemblyEvidence as IDelayEvaluatedEvidence)?.MarkUsed();
1373 private bool WasStrongNameEvidenceUsed()
1375 using (
new EvidenceLockHolder(
this, EvidenceLockHolder.LockType.Reader))
1377 EvidenceTypeDescriptor evidenceTypeDescriptor = GetEvidenceTypeDescriptor(typeof(StrongName));
1378 if (evidenceTypeDescriptor !=
null)
1380 return (evidenceTypeDescriptor.HostEvidence as IDelayEvaluatedEvidence)?.WasUsed ??
false;
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
Encapsulates security decisions about an application. This class cannot be inherited.
Describes a set of security permissions applied to code. This class cannot be inherited.
void ReleaseWriterLock()
Decrements the lock count on the writer lock.
bool MoveNext()
Advances the enumerator to the next element of the collection.
Provides the Authenticode X.509v3 digital signature of a code assembly as evidence for policy evaluat...
void ReleaseReaderLock()
Decrements the lock count.
Represents a simple last-in-first-out (LIFO) non-generic collection of objects.
Provides the strong name of a code assembly as evidence for policy evaluation. This class cannot be i...
int Count
Gets the number of evidence objects in the evidence set.
void AcquireReaderLock(int millisecondsTimeout)
Acquires a reader lock, using an T:System.Int32 value for the time-out.
Provides the security zone of a code assembly as evidence for policy evaluation. This class cannot be...
Defines the lock that implements single-writer/multiple-reader semantics. This is a value type.
void AddAssembly(object id)
Adds the specified assembly evidence to the evidence set.
Provides the application directory as evidence for policy evaluation. This class cannot be inherited.
Provides the Web site from which a code assembly originates as evidence for policy evaluation....
Provides a mechanism for releasing unmanaged resources.To browse the .NET Framework source code for t...
Specifies the current position within a stream.
The exception that is thrown when the value of an argument is outside the allowable range of values a...
HostSecurityManagerOptions
Specifies the security policy components to be used by the host security manager.
Evidence(Evidence evidence)
Initializes a new instance of the T:System.Security.Policy.Evidence class from a shallow copy of an e...
Evidence Clone()
Returns a duplicate copy of this evidence object.
Provides the URL from which a code assembly originates as evidence for policy evaluation....
Describes the source and destination of a given serialized stream, and provides an additional caller-...
Provides a base class from which all objects to be used as evidence must derive.
Evidence()
Initializes a new empty instance of the T:System.Security.Policy.Evidence class.
static AppDomain CurrentDomain
Gets the current application domain for the current T:System.Threading.Thread.
Represents an application domain, which is an isolated environment where applications execute....
Defines a lock that supports single writers and multiple readers.
bool ContainsKey(TKey key)
Determines whether the T:System.Collections.Generic.Dictionary`2 contains the specified key.
void AddAssemblyEvidence< T >(T evidence)
Adds an evidence object of the specified type to the assembly-supplied evidence list.
Represents a weak reference, which references an object while still allowing that object to be reclai...
The P:System.Uri.Host data.
Defines a key/value pair that can be set or retrieved.
void AddHostEvidence< T >(T evidence)
Adds host evidence of the specified type to the host evidence collection.
SecurityAction
Specifies the security actions that can be performed using declarative security.
Exposes an enumerator, which supports a simple iteration over a non-generic collection....
T GetAssemblyEvidence< T >()
Gets assembly evidence of the specified type from the collection.
Provides information about, and means to manipulate, the current environment and platform....
IEnumerator GetAssemblyEnumerator()
Enumerates evidence provided by the assembly.
virtual object Peek()
Returns the object at the top of the T:System.Collections.Stack without removing it.
KeyCollection Keys
Gets a collection containing the keys in the T:System.Collections.Generic.Dictionary`2.
Creates a stream whose backing store is memory.To browse the .NET Framework source code for this type...
Finds or creates a T:System.AppDomain.
LockCookie UpgradeToWriterLock(int millisecondsTimeout)
Upgrades a reader lock to the writer lock, using an Int32 value for the time-out.
virtual byte [] ToArray()
Writes the stream contents to a byte array, regardless of the P:System.IO.MemoryStream....
void CopyTo(Array array, int index)
Copies evidence objects to an T:System.Array.
Provides evidence about the hash value for an assembly. This class cannot be inherited.
object Current
Gets the element in the collection at the current position of the enumerator.
Represents an assembly, which is a reusable, versionable, and self-describing building block of a com...
bool IsSynchronized
Gets a value indicating whether the evidence set is thread-safe.
void AcquireWriterLock(int millisecondsTimeout)
Acquires the writer lock, using an T:System.Int32 value for the time-out.
bool Locked
Gets or sets a value indicating whether the evidence is locked.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Represents type declarations: class types, interface types, array types, value types,...
virtual object Pop()
Removes and returns the object at the top of the T:System.Collections.Stack.
Evidence(EvidenceBase[] hostEvidence, EvidenceBase[] assemblyEvidence)
Initializes a new instance of the T:System.Security.Policy.Evidence class from multiple sets of host ...
void Clear()
Removes the host and assembly evidence from the evidence set.
Provides data for manifest-based activation of an application. This class cannot be inherited.
virtual int Add(object value)
Adds an object to the end of the T:System.Collections.ArrayList.
Represents a collection of keys and values.To browse the .NET Framework source code for this type,...
bool IsWriterLockHeld
Gets a value indicating whether the current thread holds the writer lock.
The exception that is thrown when one of the arguments provided to a method is not valid.
void Demand()
Forces a T:System.Security.SecurityException at run time if all callers higher in the call stack have...
void RemoveType(Type t)
Removes the evidence for a given type from the host and assembly enumerations.
object SyncRoot
Gets the synchronization root.
bool IsReaderLockHeld
Gets a value indicating whether the current thread holds a reader lock.
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
bool IsReadOnly
Gets a value indicating whether the evidence set is read-only.
void Merge(Evidence evidence)
Merges the specified evidence set into the current evidence set.
void DowngradeFromWriterLock(ref LockCookie lockCookie)
Restores the lock status of the thread to what it was before M:System.Threading.ReaderWriterLock....
IEnumerator GetHostEnumerator()
Enumerates evidence supplied by the host.
Defines the set of information that constitutes input to security policy decisions....
Confirms that a code assembly originates in the global assembly cache (GAC) as evidence for policy ev...
Specifies that the class can be serialized.
virtual int Count
Gets the number of elements contained in the T:System.Collections.Stack.
The exception that is thrown when a method call is invalid for the object's current state.
virtual void Push(object obj)
Inserts an object at the top of the T:System.Collections.Stack.
Defines size, enumerators, and synchronization methods for all nongeneric collections.
SecurityPermissionFlag
Specifies access flags for the security permission object.
Evidence(object[] hostEvidence, object[] assemblyEvidence)
Initializes a new instance of the T:System.Security.Policy.Evidence class from multiple sets of host ...
bool TryGetValue(TKey key, out TValue value)
Gets the value associated with the specified key.
Supports a simple iteration over a non-generic collection.
void AddHost(object id)
Adds the specified evidence supplied by the host to the evidence set.
Defines evidence that represents permission requests. This class cannot be inherited.
IEnumerator GetEnumerator()
Enumerates all evidence in the set, both that provided by the host and that provided by the assembly.
T GetHostEvidence< T >()
Gets host evidence of the specified type from the collection.
Implements the T:System.Collections.IList interface using an array whose size is dynamically increase...