11 private StringExpressionSet m_read;
13 private StringExpressionSet m_write;
15 private bool m_unrestricted;
25 m_unrestricted =
true;
28 m_unrestricted =
false;
53 m_unrestricted =
false;
70 [SecuritySafeCritical]
78 m_read =
new EnvironmentStringExpressionSet();
80 m_read.AddExpressions(pathList);
86 m_write =
new EnvironmentStringExpressionSet();
88 m_write.AddExpressions(pathList);
108 return m_read.ToString();
116 return m_write.ToString();
135 if ((flag & (flag - 1)) != 0)
137 throw new ArgumentException(Environment.GetResourceString(
"Arg_EnumNotSingleFlag"));
146 private bool IsEmpty()
148 if (!m_unrestricted && (m_read ==
null || m_read.IsEmpty()))
152 return m_write.IsEmpty();
164 return m_unrestricted;
172 [SecuritySafeCritical]
190 return (m_read ==
null || m_read.IsSubsetOf(environmentPermission.m_read)) && (m_write ==
null || m_write.IsSubsetOf(environmentPermission.m_write));
202 [SecuritySafeCritical]
209 if (!VerifyType(target))
215 return target.
Copy();
222 StringExpressionSet stringExpressionSet = (m_read ==
null) ?
null : m_read.Intersect(environmentPermission.m_read);
223 StringExpressionSet stringExpressionSet2 = (m_write ==
null) ?
null : m_write.Intersect(environmentPermission.m_write);
224 if ((stringExpressionSet ==
null || stringExpressionSet.IsEmpty()) && (stringExpressionSet2 ==
null || stringExpressionSet2.IsEmpty()))
229 environmentPermission2.m_unrestricted =
false;
230 environmentPermission2.m_read = stringExpressionSet;
231 environmentPermission2.m_write = stringExpressionSet2;
232 return environmentPermission2;
239 [SecuritySafeCritical]
246 if (!VerifyType(other))
255 StringExpressionSet stringExpressionSet = (m_read ==
null) ? environmentPermission.m_read : m_read.Union(environmentPermission.m_read);
256 StringExpressionSet stringExpressionSet2 = (m_write ==
null) ? environmentPermission.m_write : m_write.Union(environmentPermission.m_write);
257 if ((stringExpressionSet ==
null || stringExpressionSet.IsEmpty()) && (stringExpressionSet2 ==
null || stringExpressionSet2.IsEmpty()))
262 environmentPermission2.m_unrestricted =
false;
263 environmentPermission2.m_read = stringExpressionSet;
264 environmentPermission2.m_write = stringExpressionSet2;
265 return environmentPermission2;
275 environmentPermission.m_unrestricted =
true;
279 environmentPermission.m_unrestricted =
false;
282 environmentPermission.m_read = m_read.Copy();
286 environmentPermission.m_write = m_write.Copy();
289 return environmentPermission;
299 if (m_read !=
null && !m_read.IsEmpty())
303 if (m_write !=
null && !m_write.IsEmpty())
312 return securityElement;
322 if (XMLUtil.IsUnrestricted(esd))
324 m_unrestricted =
true;
327 m_unrestricted =
false;
330 string text = esd.Attribute(
"Read");
333 m_read =
new EnvironmentStringExpressionSet(text);
335 text = esd.Attribute(
"Write");
338 m_write =
new EnvironmentStringExpressionSet(text);
342 int IBuiltInPermission.GetTokenIndex()
344 return GetTokenIndex();
347 internal static int GetTokenIndex()
Allows a permission to expose an unrestricted state.
string GetPathList(EnvironmentPermissionAccess flag)
Gets all environment variables with the specified T:System.Security.Permissions.EnvironmentPermission...
The exception that is thrown for invalid casting or explicit conversion.
IPermission Copy()
Creates and returns an identical copy of the current permission.
bool IsUnrestricted()
Returns a value indicating whether the current permission is unrestricted.
EnvironmentPermissionAccess
Specifies access to environment variables.
static string Escape(string str)
Replaces invalid XML characters in a string with their valid XML equivalent.
override IPermission Intersect(IPermission target)
Creates and returns a permission that is the intersection of the current permission and the specified...
Provides information about, and means to manipulate, the current environment and platform....
void AddPathList(EnvironmentPermissionAccess flag, string pathList)
Adds access for the specified environment variables to the existing state of the permission.
Represents the XML object model for encoding security objects. This class cannot be inherited.
Defines the underlying structure of all code access permissions.
override void FromXml(SecurityElement esd)
Reconstructs a permission with a specified state from an XML encoding.
Defines methods implemented by permission types.
The exception that is thrown when one of the arguments provided to a method is not valid.
override SecurityElement ToXml()
Creates an XML encoding of the permission and its current state.
void SetPathList(EnvironmentPermissionAccess flag, string pathList)
Sets the specified access to the specified environment variables to the existing state of the permiss...
PermissionState
Specifies whether a permission should have all or no access to resources at creation.
void AddAttribute(string name, string value)
Adds a name/value attribute to an XML element.
Specifies that the class can be serialized.
Controls access to system and user environment variables. This class cannot be inherited.
EnvironmentPermission(EnvironmentPermissionAccess flag, string pathList)
Initializes a new instance of the T:System.Security.Permissions.EnvironmentPermission class with the ...
override IPermission Copy()
Creates and returns an identical copy of the current permission.
EnvironmentPermission(PermissionState state)
Initializes a new instance of the T:System.Security.Permissions.EnvironmentPermission class with eith...
override bool IsSubsetOf(IPermission target)
Determines whether the current permission is a subset of the specified permission.
override IPermission Union(IPermission other)
Creates a permission that is the union of the current permission and the specified permission.