System.Configuration.ConfigurationPermission.FromXml C# (CSharp) Метод

FromXml() публичный Метод

public FromXml ( SecurityElement securityElement ) : void
securityElement System.Security.SecurityElement
Результат void
        public override void FromXml(SecurityElement securityElement) {
            if (securityElement == null) {
                throw new ArgumentNullException(SR.GetString(SR.ConfigurationPermissionBadXml,"securityElement"));
            }

            if (!securityElement.Tag.Equals("IPermission")) {
                throw new ArgumentException(SR.GetString(SR.ConfigurationPermissionBadXml,"securityElement"));
            }

            string className = securityElement.Attribute("class");
            if (className == null) {
                throw new ArgumentException(SR.GetString(SR.ConfigurationPermissionBadXml,"securityElement"));
            }

            if (className.IndexOf(this.GetType().FullName, StringComparison.Ordinal ) < 0) {
                throw new ArgumentException(SR.GetString(SR.ConfigurationPermissionBadXml,"securityElement"));
            }

            string version = securityElement.Attribute("version");
            if (version != "1") {
                throw new ArgumentException(SR.GetString(SR.ConfigurationPermissionBadXml,"version"));
            }

            string unrestricted = securityElement.Attribute("Unrestricted");
            if (unrestricted == null) {
                _permissionState = PermissionState.None;
            }
            else {
                switch (unrestricted) {
                    case "true":
                        _permissionState = PermissionState.Unrestricted;
                        break;

                    case "false":
                        _permissionState = PermissionState.None;
                        break;

                    default:
                        throw new ArgumentException(SR.GetString(SR.ConfigurationPermissionBadXml,"Unrestricted"));
                }
            }
        }