本文整理汇总了C#中System.Security.SecurityElement类的典型用法代码示例。如果您正苦于以下问题:C# SecurityElement类的具体用法?C# SecurityElement怎么用?C# SecurityElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SecurityElement类属于System.Security命名空间,在下文中一共展示了SecurityElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FromXml
// Convert an XML element into a permission object.
public override void FromXml(SecurityElement securityElement)
{
String value;
if(securityElement == null)
{
throw new ArgumentNullException("securityElement");
}
if(securityElement.Attribute("version") != "1")
{
throw new ArgumentException
(S._("Arg_PermissionVersion"));
}
value = securityElement.Attribute("Unrestricted");
if(value != null && Boolean.Parse(value))
{
level = AspNetHostingPermissionLevel.Unrestricted;
}
else
{
value = securityElement.Attribute("Level");
if(value != null)
{
level = (AspNetHostingPermissionLevel)
Enum.Parse(typeof(AspNetHostingPermissionLevel),
value);
}
else
{
level = AspNetHostingPermissionLevel.None;
}
}
}
示例2: PrincipalInfo
public PrincipalInfo(SecurityElement elem)
{
name = elem.Attribute("ID");
role = elem.Attribute("Role");
String value = elem.Attribute("Authenticated");
isAuthenticated = (value != null && Boolean.Parse(value));
}
示例3: FromXml
public override void FromXml(SecurityElement esd)
{
if (esd == null)
{
throw new ArgumentNullException("esd");
}
string str = esd.Attribute("class");
if ((str == null) || (str.IndexOf(base.GetType().FullName) == -1))
{
throw new ArgumentException(System.Drawing.SR.GetString("InvalidClassName"));
}
string a = esd.Attribute("Unrestricted");
if ((a != null) && string.Equals(a, "true", StringComparison.OrdinalIgnoreCase))
{
this.printingLevel = PrintingPermissionLevel.AllPrinting;
}
else
{
this.printingLevel = PrintingPermissionLevel.NoPrinting;
string str3 = esd.Attribute("Level");
if (str3 != null)
{
this.printingLevel = (PrintingPermissionLevel) Enum.Parse(typeof(PrintingPermissionLevel), str3);
}
}
}
示例4: FromXml
// Convert an XML value into a permissions value.
public override void FromXml(SecurityElement esd)
{
String value;
if(esd == null)
{
throw new ArgumentNullException("esd");
}
if(esd.Attribute("version") != "1")
{
throw new ArgumentException(_("Arg_PermissionVersion"));
}
value = esd.Attribute("Unrestricted");
if(value != null && Boolean.Parse(value))
{
state = PermissionState.Unrestricted;
}
else
{
state = PermissionState.None;
}
value = esd.Attribute("Access");
if(value != null)
{
flags = (FileDialogPermissionAccess)
Enum.Parse(typeof(FileDialogPermissionAccess), value);
}
else
{
flags = FileDialogPermissionAccess.None;
}
}
示例5: FromXml
public override void FromXml(SecurityElement esd)
{
CodeAccessPermission.ValidateElement(esd, this);
this.m_allowed = IsolatedStorageContainment.None;
if (XMLUtil.IsUnrestricted(esd))
{
this.m_allowed = IsolatedStorageContainment.UnrestrictedIsolatedStorage;
}
else
{
string str = esd.Attribute("Allowed");
if (str != null)
{
this.m_allowed = (IsolatedStorageContainment) Enum.Parse(typeof(IsolatedStorageContainment), str);
}
}
if (this.m_allowed == IsolatedStorageContainment.UnrestrictedIsolatedStorage)
{
this.m_userQuota = 0x7fffffffffffffffL;
this.m_machineQuota = 0x7fffffffffffffffL;
this.m_expirationDays = 0x7fffffffffffffffL;
this.m_permanentData = true;
}
else
{
string s = esd.Attribute("UserQuota");
this.m_userQuota = (s != null) ? long.Parse(s, CultureInfo.InvariantCulture) : 0L;
s = esd.Attribute("MachineQuota");
this.m_machineQuota = (s != null) ? long.Parse(s, CultureInfo.InvariantCulture) : 0L;
s = esd.Attribute("Expiry");
this.m_expirationDays = (s != null) ? long.Parse(s, CultureInfo.InvariantCulture) : 0L;
s = esd.Attribute("Permanent");
this.m_permanentData = (s != null) ? bool.Parse(s) : false;
}
}
示例6: ToXml
private SecurityElement ToXml()
{
SecurityElement root = new SecurityElement("System.Xml.XmlSecureResolver");
root.AddAttribute("version", "1");
root.AddChild(new SecurityElement("UncDirectory", _uncDir));
return root;
}
示例7: getXmlNodeList
public override ArrayList getXmlNodeList(SecurityElement config, string itemNode)
{
ArrayList itemNodeList = new ArrayList();
UtilXml.getXmlChildList(config, itemNode, ref itemNodeList);
return itemNodeList;
}
示例8: OnStartElement
public void OnStartElement(string name, SmallXmlParser.IAttrList attrs)
{
SecurityElement newel = new SecurityElement(name);
if (root == null)
{
root = newel;
current = newel;
}
else
{
SecurityElement parent = (SecurityElement)stack.Peek();
parent.AddChild(newel);
}
stack.Push(newel);
current = newel;
// attributes
int n = attrs.Length;
for (int i = 0; i < n; i++)
{
string attrName = SecurityElement.Escape(attrs.GetName(i));
string attrValue = SecurityElement.Escape(attrs.GetValue(i));
current.AddAttribute(attrName, attrValue);
}
}
示例9: Element
// snippet moved from FileIOPermission (nickd) to be reused in all derived classes
internal static SecurityElement Element (Type type, int version)
{
SecurityElement se = new SecurityElement ("IPermission");
se.AddAttribute ("class", type.FullName + ", " + type.Assembly.ToString ().Replace ('\"', '\''));
se.AddAttribute ("version", version.ToString ());
return se;
}
示例10: ToXml
internal SecurityElement ToXml()
{
SecurityElement element2;
SecurityElement element = new SecurityElement("System.Security.Policy.PermissionRequestEvidence");
element.AddAttribute("version", "1");
if (this.m_request != null)
{
element2 = new SecurityElement("Request");
element2.AddChild(this.m_request.ToXml());
element.AddChild(element2);
}
if (this.m_optional != null)
{
element2 = new SecurityElement("Optional");
element2.AddChild(this.m_optional.ToXml());
element.AddChild(element2);
}
if (this.m_denied != null)
{
element2 = new SecurityElement("Denied");
element2.AddChild(this.m_denied.ToXml());
element.AddChild(element2);
}
return element;
}
示例11: ToXml
public SecurityElement ToXml ()
{
SecurityElement se = new SecurityElement (tag);
se.AddAttribute ("class", typeof (MonoTrustManager).AssemblyQualifiedName);
se.AddAttribute ("version", "1");
return se;
}
示例12: FromXml
// Convert an XML value into a permissions value.
public override void FromXml(SecurityElement esd)
{
if(esd == null)
{
throw new ArgumentNullException("esd");
}
if(esd.Attribute("version") != "1")
{
throw new ArgumentException(_("Arg_PermissionVersion"));
}
name = esd.Attribute("Name");
String value = esd.Attribute("Version");
if(value != null)
{
version = new Version(value);
}
else
{
version = null;
}
value = esd.Attribute("PublicKeyBlob");
if(value != null)
{
blob = new StrongNamePublicKeyBlob(value);
}
else
{
blob = null;
}
}
示例13: FromXml
// Convert an XML value into a permissions value.
public override void FromXml(SecurityElement esd)
{
String value;
if(esd == null)
{
throw new ArgumentNullException("esd");
}
if(esd.Attribute("version") != "1")
{
throw new ArgumentException(_("Arg_PermissionVersion"));
}
value = esd.Attribute("Unrestricted");
if(value != null && Boolean.Parse(value))
{
state = PermissionState.Unrestricted;
}
else
{
state = PermissionState.None;
}
if(state != PermissionState.Unrestricted)
{
readList = EnvironmentPermission.SplitPath
(esd.Attribute("Read"), ';');
writeList = EnvironmentPermission.SplitPath
(esd.Attribute("Write"), ';');
createList = EnvironmentPermission.SplitPath
(esd.Attribute("Create"), ';');
}
}
示例14: FromXml
public override void FromXml(SecurityElement securityElement)
{
if (securityElement == null)
{
throw new ArgumentNullException(SR.GetString("AspNetHostingPermissionBadXml", new object[] { "securityElement" }));
}
if (!securityElement.Tag.Equals("IPermission"))
{
throw new ArgumentException(SR.GetString("AspNetHostingPermissionBadXml", new object[] { "securityElement" }));
}
string str = securityElement.Attribute("class");
if (str == null)
{
throw new ArgumentException(SR.GetString("AspNetHostingPermissionBadXml", new object[] { "securityElement" }));
}
if (str.IndexOf(base.GetType().FullName, StringComparison.Ordinal) < 0)
{
throw new ArgumentException(SR.GetString("AspNetHostingPermissionBadXml", new object[] { "securityElement" }));
}
if (string.Compare(securityElement.Attribute("version"), "1", StringComparison.OrdinalIgnoreCase) != 0)
{
throw new ArgumentException(SR.GetString("AspNetHostingPermissionBadXml", new object[] { "version" }));
}
string str3 = securityElement.Attribute("Level");
if (str3 == null)
{
this._level = AspNetHostingPermissionLevel.None;
}
else
{
this._level = (AspNetHostingPermissionLevel) Enum.Parse(typeof(AspNetHostingPermissionLevel), str3);
}
}
示例15: FromXml
public override void FromXml(SecurityElement securityElement)
{
if (securityElement == null)
{
throw new ArgumentNullException("securityElement");
}
string str = securityElement.Attribute("class");
if ((str == null) || (str.IndexOf(base.GetType().FullName, StringComparison.Ordinal) == -1))
{
throw new ArgumentException(SecurityResources.GetResourceString("Argument_InvalidClassAttribute"), "securityElement");
}
string strA = securityElement.Attribute("Unrestricted");
if ((strA != null) && (string.Compare(strA, "true", StringComparison.OrdinalIgnoreCase) == 0))
{
this.m_flags = DataProtectionPermissionFlags.AllFlags;
}
else
{
this.m_flags = DataProtectionPermissionFlags.NoFlags;
string str3 = securityElement.Attribute("Flags");
if (str3 != null)
{
DataProtectionPermissionFlags flags = (DataProtectionPermissionFlags) Enum.Parse(typeof(DataProtectionPermissionFlags), str3);
VerifyFlags(flags);
this.m_flags = flags;
}
}
}