System.Security.Policy.Evidence Class

Assembly: Mscorlib.dll
Namespace: System.Security.Policy
Summary
Defines the set of information that constitutes input to security policy decisions. This class cannot be inherited.
C# Syntax:
[Serializable]
public sealed class Evidence : ICollection, IEnumerable
Remarks
Common forms of evidence include signatures and location of origin of code, but can potentially be anything. Objects of any type that are recognized by security policy represent evidence.

Security policy is composed of code groups; a particular assembly (the basic unit of code for granting security permissions) is a member of a code group if it satisfies the code group's membership condition. Evidence is the set of inputs to policy that membership conditions use to determine to which code groups an assembly belongs.

The Evidence class is a collection (see ICollection) that holds a set of objects that represent evidence. This class holds two sets that correspond to the source of the evidence: host evidence and assembly evidence.

Policy can get evidence from two different sources when evaluating permissions for code.

See also:
System.Security.Policy Namespace

System.Security.Policy.Evidence Member List:

Public Constructors
ctor #1 Overloaded:
.ctor()

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Initializes a new empty instance of the Evidence class.
ctor #2 Overloaded:
.ctor(Evidence evidence)

Initializes a new instance of the Evidence class from a shallow copy of an existing one.
ctor #3 Overloaded:
.ctor(object[] hostEvidence, object[] assemblyEvidence)

Initializes a new instance of the Evidence class from multiple sets of host and assembly evidence.
Public Properties
Count Read-only

Gets the number of evidence objects in the evidence set.
IsReadOnly Read-only

Gets a value indicating whether the evidence set is read-only.
IsSynchronized Read-only

Gets a value indicating whether the evidence set is thread-safe.
Locked Read-write

Gets or sets a value indicating whether the evidence is locked.
SyncRoot Read-only

Gets the synchronization root.
Public Methods
AddAssembly Adds the specified assembly evidence to the evidence set.
AddHost Adds the specified evidence supplied by the host to the evidence set.
CopyTo Copies evidence objects to an Array.
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetAssemblyEnumerator Enumerates evidence provided by the assembly.
GetEnumerator Enumerates all evidence in the set, both that provided by the host and that provided by the assembly.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetHostEnumerator Enumerates evidence supplied by the host.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
Merge Merges the specified evidence set into the current evidence set.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.Security.Policy.Evidence Member Details

Overloaded ctor #1
Summary
Initializes a new empty instance of the Evidence class.

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
public Evidence();

Return to top


Overloaded ctor #2
Summary
Initializes a new instance of the Evidence class from a shallow copy of an existing one.
C# Syntax:
public Evidence(Evidence(
   Evidence evidence
);
Parameters:

evidence

The Evidence instance from which to create the new instance. This instance is not deep copied.

Exceptions
Exception Type Condition
ArgumentException The evidence parameter is not a valid instance of Evidence.

Return to top


Overloaded ctor #3
Summary
Initializes a new instance of the Evidence class from multiple sets of host and assembly evidence.
C# Syntax:
public Evidence(object[] hostEvidence, object[] assemblyEvidence(
   object[] hostEvidence,
   object[] assemblyEvidence
);
Parameters:

hostEvidence

The host evidence from which to create the new instance.

assemblyEvidence

The assembly evidence from which to create the new instance.

Return to top


Property: Count (read-only)
Summary
Gets the number of evidence objects in the evidence set.
C# Syntax:
public int Count {get;}
Implements:
ICollection.Count

Return to top


Property: IsReadOnly (read-only)
Summary
Gets a value indicating whether the evidence set is read-only.
C# Syntax:
public bool IsReadOnly {get;}
Remarks
Application code does not normally use this property.

Return to top


Property: IsSynchronized (read-only)
Summary
Gets a value indicating whether the evidence set is thread-safe.
C# Syntax:
public bool IsSynchronized {get;}
Implements:
ICollection.IsSynchronized
Remarks
Application code does not normally use this property.

Return to top


Property: Locked (read-write)
Summary
Gets or sets a value indicating whether the evidence is locked.
C# Syntax:
public bool Locked {get; set;}
.NET Framework Security:
SecurityPermission for the ability to set this property. Associated enumeration: SecurityPermissionFlag.ControlEvidence

Return to top


Property: SyncRoot (read-only)
Summary
Gets the synchronization root.
C# Syntax:
public object SyncRoot {get;}
Implements:
ICollection.SyncRoot
Remarks
This property is not normally used by application code.

Return to top


Method: AddAssembly(
   object id
)
Summary
Adds the specified assembly evidence to the evidence set.
C# Syntax:
public void AddAssembly(
   object id
);
Parameters:

id

Any evidence object.

Remarks
Use this method for evidence derived from the assembly.

Note This method does not perform a check to prevent adding duplicate types of evidence. Many assembly evidence objects can exist at the same time.

Return to top


Method: AddHost(
   object id
)
Summary
Adds the specified evidence supplied by the host to the evidence set.
C# Syntax:
public void AddHost(
   object id
);
Parameters:

id

Any evidence object.

Exceptions
Exception Type Condition
SecurityException Evidence.Locked is true and the code that calls this method does not have SecurityPermissionFlag.ControlEvidence.
Remarks
Use this method for evidence supplied by the host.

Note This method does not perform a check to prevent adding duplicate types of evidence. Many host evidence objects can exist at the same time.
.NET Framework Security:
SecurityPermission for the ability to manipulate evidence when Evidence.Locked is true. Associated enumeration: SecurityPermissionFlag.ControlEvidence

Return to top


Method: CopyTo(
   Array array,
   int index
)
Summary
Copies evidence objects to an Array.
C# Syntax:
public void CopyTo(
   Array array,
   int index
);
Parameters:

array

The target array to which to copy evidence objects.

index

The zero-based position in the array to which to begin copying evidence objects.

Implements:
ICollection.CopyTo

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~Evidence();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetAssemblyEnumerator()
Summary
Enumerates evidence provided by the assembly.
C# Syntax:
public IEnumerator GetAssemblyEnumerator();
Return Value:
An enumerator for evidence added by the Evidence.AddAssembly method.

Return to top


Method: GetEnumerator()
Summary
Enumerates all evidence in the set, both that provided by the host and that provided by the assembly.
C# Syntax:
public IEnumerator GetEnumerator();
Return Value:
An enumerator for evidence added by both the Evidence.AddHost method and the Evidence.AddAssembly method.
Implements:
IEnumerable.GetEnumerator

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetHostEnumerator()
Summary
Enumerates evidence supplied by the host.
C# Syntax:
public IEnumerator GetHostEnumerator();
Return Value:
An enumerator for evidence added by the Evidence.AddHost method.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Merge(
   Evidence evidence
)
Summary
Merges the specified evidence set into the current evidence set.
C# Syntax:
public void Merge(
   Evidence evidence
);
Parameters:

evidence

The evidence set to be merged into the current evidence set.

Exceptions
Exception Type Condition
ArgumentException The evidence parameter is not a valid instance of Evidence.
SecurityException Evidence.Locked is true, the code that calls this method does not have SecurityPermissionFlag.ControlEvidence, and the evidence parameter has a host list that is not empty.
Remarks
Each evidence object in the specified evidence set is added to the assembly and host sets of the current evidence set, according to the sets from which it came.

Note This method does not perform a check to prevent adding duplicate types of evidence. Many assembly and host evidence objects can exist at the same time.
.NET Framework Security:
SecurityPermission for the ability to manipulate evidence when Evidence.Locked is true and the evidence parameter has a host list that is not empty. Associated enumeration: SecurityPermissionFlag.ControlEvidence

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.