本文整理汇总了C#中SecurityElement.Attribute方法的典型用法代码示例。如果您正苦于以下问题:C# SecurityElement.Attribute方法的具体用法?C# SecurityElement.Attribute怎么用?C# SecurityElement.Attribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SecurityElement
的用法示例。
在下文中一共展示了SecurityElement.Attribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IDRole
internal IDRole(SecurityElement e)
{
string elAuth = e.Attribute("Authenticated");
Authenticated = elAuth == null ? false : string.Equals(elAuth, "true", StringComparison.OrdinalIgnoreCase);
ID = e.Attribute("ID");
Role = e.Attribute("Role");
}
示例2: CheckSecurityElement
internal static int CheckSecurityElement (SecurityElement se, string parameterName, int minimumVersion, int maximumVersion)
{
if (se == null)
throw new ArgumentNullException (parameterName);
if (se.Attribute ("class") == null) {
string msg = Locale.GetText ("Missing 'class' attribute.");
throw new ArgumentException (msg, parameterName);
}
// we assume minimum version if no version number is supplied
int version = minimumVersion;
string v = se.Attribute ("version");
if (v != null) {
try {
version = Int32.Parse (v);
}
catch (Exception e) {
string msg = Locale.GetText ("Couldn't parse version from '{0}'.");
msg = String.Format (msg, v);
throw new ArgumentException (msg, parameterName, e);
}
}
if ((version < minimumVersion) || (version > maximumVersion)) {
string msg = Locale.GetText ("Unknown version '{0}', expected versions between ['{1}','{2}'].");
msg = String.Format (msg, version, minimumVersion, maximumVersion);
throw new ArgumentException (msg, parameterName);
}
return version;
}
示例3: FromXml
public void FromXml (SecurityElement e, PolicyLevel level)
{
MembershipConditionHelper.CheckSecurityElement (e, "e", version, version);
if (!Boolean.TryParse (e.Attribute ("LookAtDir"), out _lookAtDir))
_lookAtDir = false;
// PolicyLevel isn't used as there's no need to resolve NamedPermissionSet references
}
示例4: 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");
Clear();
if(value != null && Boolean.Parse(value))
{
state = PermissionState.Unrestricted;
}
else
{
// TODO: read the children
}
}
示例5: FromXml
public override void FromXml (SecurityElement esd)
{
// General validation in CodeAccessPermission
CheckSecurityElement (esd, "esd", 1, 1);
// Note: we do not (yet) care about the return value
// as we only accept version 1 (min/max values)
string u = esd.Attribute ("Url");
if (u == null)
url = String.Empty;
else
Url = u;
}
示例6: FromXml
// Implement the ISecurityPolicyEncodable interface.
public void FromXml(SecurityElement et, PolicyLevel level)
{
if(et == null)
{
throw new ArgumentNullException("et");
}
if(et.Tag != "IMembershipCondition")
{
throw new ArgumentException
(_("Security_PolicyName"));
}
if(et.Attribute("version") != "1")
{
throw new ArgumentException
(_("Security_PolicyVersion"));
}
}
示例7: CheckSecurityElement
internal static int CheckSecurityElement (SecurityElement se, string parameterName, int minimumVersion, int maximumVersion)
{
if (se == null)
throw new ArgumentNullException (parameterName);
// Tag is case-sensitive
if (se.Tag != XmlTag) {
string msg = String.Format (Locale.GetText ("Invalid tag {0}, expected {1}."), se.Tag, XmlTag);
throw new ArgumentException (msg, parameterName);
}
// Note: we do not care about the class attribute at
// this stage (in fact we don't even if the class
// attribute is present or not). Anyway the object has
// already be created, with success, if we're loading it
// we assume minimum version if no version number is supplied
int version = minimumVersion;
string v = se.Attribute ("version");
if (v != null) {
try {
version = Int32.Parse (v);
}
catch (Exception e) {
string msg = Locale.GetText ("Couldn't parse version from '{0}'.");
msg = String.Format (msg, v);
throw new ArgumentException (msg, parameterName, e);
}
}
/* if ((version < minimumVersion) || (version > maximumVersion)) {
string msg = Locale.GetText ("Unknown version '{0}', expected versions between ['{1}','{2}'].");
msg = String.Format (msg, version, minimumVersion, maximumVersion);
throw new ArgumentException (msg, parameterName);
}*/
return version;
}
示例8: FromSecurityElement
private SNIP FromSecurityElement (SecurityElement se)
{
string name = se.Attribute ("Name");
StrongNamePublicKeyBlob publickey = StrongNamePublicKeyBlob.FromString (se.Attribute ("PublicKeyBlob"));
string v = se.Attribute ("AssemblyVersion");
Version assemblyVersion = (v == null) ? null : new Version (v);
return new SNIP (publickey, name, assemblyVersion);
}
示例9: FromXml
public void FromXml (SecurityElement e, PolicyLevel level)
{
MembershipConditionHelper.CheckSecurityElement (e, "e", version, version);
_site = e.Attribute ("Site");
// PolicyLevel isn't used as there's no need to resolve NamedPermissionSet references
}
示例10: FromXml
internal void FromXml (SecurityElement element)
{
if (element == null)
throw new ArgumentNullException(nameof(element));
if (String.Compare(element.Tag, "StrongName", StringComparison.Ordinal) != 0)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidXML"));
Contract.EndContractBlock();
m_publicKeyBlob = null;
m_version = null;
string key = element.Attribute("Key");
if (key != null)
m_publicKeyBlob = new StrongNamePublicKeyBlob(System.Security.Util.Hex.DecodeHexString(key));
m_name = element.Attribute("Name");
string version = element.Attribute("Version");
if (version != null)
m_version = new Version(version);
}
示例11: FromXml
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);
}
}
}
}
示例12: FromXml
public void FromXml (SecurityElement element) {
if (element == null)
throw new ArgumentNullException("element");
if (String.Compare(element.Tag, "ApplicationTrust", StringComparison.Ordinal) != 0)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidXML"));
#if FEATURE_CLICKONCE
m_appTrustedToRun = false;
string isAppTrustedToRun = element.Attribute("TrustedToRun");
if (isAppTrustedToRun != null && String.Compare(isAppTrustedToRun, "true", StringComparison.Ordinal) == 0) {
m_appTrustedToRun = true;
}
m_persist = false;
string persist = element.Attribute("Persist");
if (persist != null && String.Compare(persist, "true", StringComparison.Ordinal) == 0) {
m_persist = true;
}
m_appId = null;
string fullName = element.Attribute("FullName");
if (fullName != null && fullName.Length > 0) {
m_appId = new ApplicationIdentity(fullName);
}
#endif // FEATURE_CLICKONCE
m_psDefaultGrant = null;
m_grantSetSpecialFlags = 0;
SecurityElement elDefaultGrant = element.SearchForChildByTag("DefaultGrant");
if (elDefaultGrant != null) {
SecurityElement elDefaultGrantPS = elDefaultGrant.SearchForChildByTag("PolicyStatement");
if (elDefaultGrantPS != null) {
PolicyStatement ps = new PolicyStatement(null);
ps.FromXml(elDefaultGrantPS);
m_psDefaultGrant = ps;
m_grantSetSpecialFlags = SecurityManager.GetSpecialFlags(ps.PermissionSet, null);
}
}
List<StrongName> fullTrustAssemblies = new List<StrongName>();
SecurityElement elFullTrustAssemblies = element.SearchForChildByTag("FullTrustAssemblies");
if (elFullTrustAssemblies != null && elFullTrustAssemblies.InternalChildren != null) {
IEnumerator enumerator = elFullTrustAssemblies.Children.GetEnumerator();
while (enumerator.MoveNext()) {
StrongName fullTrustAssembly = new StrongName();
fullTrustAssembly.FromXml(enumerator.Current as SecurityElement);
fullTrustAssemblies.Add(fullTrustAssembly);
}
}
m_fullTrustAssemblies = fullTrustAssemblies.AsReadOnly();
#if FEATURE_CLICKONCE
m_elExtraInfo = element.SearchForChildByTag("ExtraInfo");
#endif // FEATURE_CLICKONCE
}
示例13: FromXml
public override void FromXml (SecurityElement esd)
{
// General validation in CodeAccessPermission
CheckSecurityElement (esd, "esd", version, version);
// Note: we do not (yet) care about the return value
// as we only accept version 1 (min/max values)
if (IsUnrestricted (esd)) {
flags = SecurityPermissionFlag.AllFlags;
}
else {
string f = esd.Attribute ("Flags");
if (f == null) {
flags = SecurityPermissionFlag.NoFlags;
}
else {
flags = (SecurityPermissionFlag) Enum.Parse (
typeof (SecurityPermissionFlag), f);
}
}
}
示例14: FromXml
public override void FromXml (SecurityElement esd)
{
// General validation in CodeAccessPermission
CheckSecurityElement (esd, "esd", version, version);
// Note: we do not (yet) care about the return value
// as we only accept version 1 (min/max values)
if (IsUnrestricted (esd)) {
_window = UIPermissionWindow.AllWindows;
_clipboard = UIPermissionClipboard.AllClipboard;
}
else {
string w = esd.Attribute ("Window");
if (w == null)
_window = UIPermissionWindow.NoWindows;
else
_window = (UIPermissionWindow) Enum.Parse (typeof (UIPermissionWindow), w);
string c = esd.Attribute ("Clipboard");
if (c == null)
_clipboard = UIPermissionClipboard.NoClipboard;
else
_clipboard = (UIPermissionClipboard) Enum.Parse (typeof (UIPermissionClipboard), c);
}
}
示例15: FromXml
public override void FromXml (SecurityElement securityElement) {
if (securityElement == null)
throw new ArgumentNullException("securityElement");
string className = securityElement.Attribute("class");
if (className == null || className.IndexOf(this.GetType().FullName, StringComparison.Ordinal) == -1)
throw new ArgumentException(SR.GetString(SR.Argument_InvalidClassAttribute), "securityElement");
string unrestricted = securityElement.Attribute("Unrestricted");
if (unrestricted != null && String.Compare(unrestricted, "true", StringComparison.OrdinalIgnoreCase) == 0) {
m_flags = StorePermissionFlags.AllFlags;
return;
}
m_flags = StorePermissionFlags.NoFlags;
String strFlags = securityElement.Attribute("Flags");
if (strFlags != null) {
StorePermissionFlags flags = (StorePermissionFlags) Enum.Parse(typeof(StorePermissionFlags), strFlags);
VerifyFlags(flags);
m_flags = flags;
}
}