summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Security/Permissions/keycontainerpermission.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Security/Permissions/keycontainerpermission.cs')
-rw-r--r--src/mscorlib/src/System/Security/Permissions/keycontainerpermission.cs72
1 files changed, 9 insertions, 63 deletions
diff --git a/src/mscorlib/src/System/Security/Permissions/keycontainerpermission.cs b/src/mscorlib/src/System/Security/Permissions/keycontainerpermission.cs
index 9691c03da3..d4f1c273c6 100644
--- a/src/mscorlib/src/System/Security/Permissions/keycontainerpermission.cs
+++ b/src/mscorlib/src/System/Security/Permissions/keycontainerpermission.cs
@@ -11,6 +11,7 @@ namespace System.Security.Permissions {
#endif
using System.Security.Util;
using System.Globalization;
+ using System.Diagnostics;
using System.Diagnostics.Contracts;
[Serializable]
@@ -88,7 +89,7 @@ namespace System.Security.Permissions {
m_keyStore = "*";
} else {
if (value != "User" && value != "Machine" && value != "*")
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidKeyStore", value), "value");
+ throw new ArgumentException(Environment.GetResourceString("Argument_InvalidKeyStore", value), nameof(value));
m_keyStore = value;
}
}
@@ -232,7 +233,7 @@ namespace System.Security.Permissions {
if (index < 0)
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumNotStarted"));
if (index >= Count)
- throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
Contract.EndContractBlock();
return (KeyContainerPermissionAccessEntry)m_list[index];
@@ -247,7 +248,7 @@ namespace System.Security.Permissions {
public int Add (KeyContainerPermissionAccessEntry accessEntry) {
if (accessEntry == null)
- throw new ArgumentNullException("accessEntry");
+ throw new ArgumentNullException(nameof(accessEntry));
Contract.EndContractBlock();
int index = m_list.IndexOf(accessEntry);
@@ -275,7 +276,7 @@ namespace System.Security.Permissions {
public void Remove (KeyContainerPermissionAccessEntry accessEntry) {
if (accessEntry == null)
- throw new ArgumentNullException("accessEntry");
+ throw new ArgumentNullException(nameof(accessEntry));
Contract.EndContractBlock();
m_list.Remove(accessEntry);
}
@@ -292,11 +293,11 @@ namespace System.Security.Permissions {
/// <internalonly/>
void ICollection.CopyTo (Array array, int index) {
if (array == null)
- throw new ArgumentNullException("array");
+ throw new ArgumentNullException(nameof(array));
if (array.Rank != 1)
throw new ArgumentException(Environment.GetResourceString("Arg_RankMultiDimNotSupported"));
if (index < 0 || index >= array.Length)
- throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
+ throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index"));
if (index + this.Count > array.Length)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
Contract.EndContractBlock();
@@ -385,7 +386,7 @@ namespace System.Security.Permissions {
public KeyContainerPermission (KeyContainerPermissionFlags flags, KeyContainerPermissionAccessEntry[] accessList) {
if (accessList == null)
- throw new ArgumentNullException("accessList");
+ throw new ArgumentNullException(nameof(accessList));
Contract.EndContractBlock();
VerifyFlags(flags);
@@ -525,61 +526,6 @@ namespace System.Security.Permissions {
return cp;
}
-#if FEATURE_CAS_POLICY
- public override SecurityElement ToXml () {
- SecurityElement securityElement = CodeAccessPermission.CreatePermissionElement(this, "System.Security.Permissions.KeyContainerPermission");
- if (!IsUnrestricted()) {
- securityElement.AddAttribute("Flags", m_flags.ToString());
- if (AccessEntries.Count > 0) {
- SecurityElement al = new SecurityElement("AccessList");
- foreach (KeyContainerPermissionAccessEntry accessEntry in AccessEntries) {
- SecurityElement entryElem = new SecurityElement("AccessEntry");
- entryElem.AddAttribute("KeyStore", accessEntry.KeyStore);
- entryElem.AddAttribute("ProviderName", accessEntry.ProviderName);
- entryElem.AddAttribute("ProviderType", accessEntry.ProviderType.ToString(null, null));
- entryElem.AddAttribute("KeyContainerName", accessEntry.KeyContainerName);
- entryElem.AddAttribute("KeySpec", accessEntry.KeySpec.ToString(null, null));
- entryElem.AddAttribute("Flags", accessEntry.Flags.ToString());
- al.AddChild(entryElem);
- }
- securityElement.AddChild(al);
- }
- } else
- securityElement.AddAttribute("Unrestricted", "true");
-
- return securityElement;
- }
-
- public override void FromXml (SecurityElement securityElement) {
- CodeAccessPermission.ValidateElement(securityElement, this);
- if (XMLUtil.IsUnrestricted(securityElement)) {
- m_flags = KeyContainerPermissionFlags.AllFlags;
- m_accessEntries = new KeyContainerPermissionAccessEntryCollection(m_flags);
- return;
- }
-
- m_flags = KeyContainerPermissionFlags.NoFlags;
- string strFlags = securityElement.Attribute("Flags");
- if (strFlags != null) {
- KeyContainerPermissionFlags flags = (KeyContainerPermissionFlags) Enum.Parse(typeof(KeyContainerPermissionFlags), strFlags);
- VerifyFlags(flags);
- m_flags = flags;
- }
- m_accessEntries = new KeyContainerPermissionAccessEntryCollection(m_flags);
-
- if (securityElement.InternalChildren != null && securityElement.InternalChildren.Count != 0) {
- IEnumerator enumerator = securityElement.Children.GetEnumerator();
- while (enumerator.MoveNext()) {
- SecurityElement current = (SecurityElement) enumerator.Current;
- if (current != null) {
- if (String.Equals(current.Tag, "AccessList"))
- AddAccessEntries(current);
- }
- }
- }
- }
-#endif // FEATURE_CAS_POLICY
-
/// <internalonly/>
int IBuiltInPermission.GetTokenIndex () {
return KeyContainerPermission.GetTokenIndex();
@@ -597,7 +543,7 @@ namespace System.Security.Permissions {
if (current != null) {
if (String.Equals(current.Tag, "AccessEntry")) {
int iMax = current.m_lAttributes.Count;
- Contract.Assert(iMax % 2 == 0, "Odd number of strings means the attr/value pairs were not added correctly");
+ Debug.Assert(iMax % 2 == 0, "Odd number of strings means the attr/value pairs were not added correctly");
string keyStore = null;
string providerName = null;
int providerType = -1;