Ejemplo n.º 1
0
        /// <summary>Reconstructs a permission with a specified state from an XML encoding.</summary>
        /// <param name="esd">The XML encoding to use to reconstruct the permission. </param>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="esd" /> parameter is <see langword="null" />. </exception>
        /// <exception cref="T:System.ArgumentException">The <paramref name="esd" /> parameter is not a valid permission element.-or- The <paramref name="esd" /> parameter's version number is not valid. </exception>
        // Token: 0x0600252B RID: 9515 RVA: 0x00087450 File Offset: 0x00085650
        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 text = esd.Attribute("Allowed");
                if (text != null)
                {
                    this.m_allowed = (IsolatedStorageContainment)Enum.Parse(typeof(IsolatedStorageContainment), text);
                }
            }
            if (this.m_allowed == IsolatedStorageContainment.UnrestrictedIsolatedStorage)
            {
                this.m_userQuota      = long.MaxValue;
                this.m_machineQuota   = long.MaxValue;
                this.m_expirationDays = long.MaxValue;
                this.m_permanentData  = true;
                return;
            }
            string text2 = esd.Attribute("UserQuota");

            this.m_userQuota      = ((text2 != null) ? long.Parse(text2, CultureInfo.InvariantCulture) : 0L);
            text2                 = esd.Attribute("MachineQuota");
            this.m_machineQuota   = ((text2 != null) ? long.Parse(text2, CultureInfo.InvariantCulture) : 0L);
            text2                 = esd.Attribute("Expiry");
            this.m_expirationDays = ((text2 != null) ? long.Parse(text2, CultureInfo.InvariantCulture) : 0L);
            text2                 = esd.Attribute("Permanent");
            this.m_permanentData  = (text2 != null && bool.Parse(text2));
        }
Ejemplo n.º 2
0
        public override void FromXml(SecurityElement esd)
        {
            CodeAccessPermission.ValidateElement(esd, this);
            if (XMLUtil.IsUnrestricted(esd))
            {
                SetUnrestricted(true);
                return;
            }

            m_windowFlag    = UIPermissionWindow.NoWindows;
            m_clipboardFlag = UIPermissionClipboard.NoClipboard;

            String window = esd.Attribute("Window");

            if (window != null)
            {
                m_windowFlag = (UIPermissionWindow)Enum.Parse(typeof(UIPermissionWindow), window);
            }

            String clipboard = esd.Attribute("Clipboard");

            if (clipboard != null)
            {
                m_clipboardFlag = (UIPermissionClipboard)Enum.Parse(typeof(UIPermissionClipboard), clipboard);
            }
        }
        /// <summary>Reconstructs a permission with a specified state from an XML encoding.</summary>
        /// <param name="securityElement">A <see cref="T:System.Security.SecurityElement" /> that contains the XML encoding used to reconstruct the permission. </param>
        /// <exception cref="T:System.ArgumentNullException">
        ///         <paramref name="securityElement" /> is <see langword="null" />. </exception>
        /// <exception cref="T:System.ArgumentException">
        ///         <paramref name="securityElement" /> is not a valid permission element.-or- The version number of <paramref name="securityElement" /> is not supported. </exception>
        // Token: 0x060026CA RID: 9930 RVA: 0x0008C94C File Offset: 0x0008AB4C
        public override void FromXml(SecurityElement securityElement)
        {
            CodeAccessPermission.ValidateElement(securityElement, this);
            if (XMLUtil.IsUnrestricted(securityElement))
            {
                this.m_flags         = KeyContainerPermissionFlags.AllFlags;
                this.m_accessEntries = new KeyContainerPermissionAccessEntryCollection(this.m_flags);
                return;
            }
            this.m_flags = KeyContainerPermissionFlags.NoFlags;
            string text = securityElement.Attribute("Flags");

            if (text != null)
            {
                KeyContainerPermissionFlags flags = (KeyContainerPermissionFlags)Enum.Parse(typeof(KeyContainerPermissionFlags), text);
                KeyContainerPermission.VerifyFlags(flags);
                this.m_flags = flags;
            }
            this.m_accessEntries = new KeyContainerPermissionAccessEntryCollection(this.m_flags);
            if (securityElement.InternalChildren != null && securityElement.InternalChildren.Count != 0)
            {
                foreach (object obj in securityElement.Children)
                {
                    SecurityElement securityElement2 = (SecurityElement)obj;
                    if (securityElement2 != null && string.Equals(securityElement2.Tag, "AccessList"))
                    {
                        this.AddAccessEntries(securityElement2);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        /// <include file='doc\SiteIdentityPermission.uex' path='docs/doc[@for="SiteIdentityPermission.FromXml"]/*' />
        public override void FromXml(SecurityElement esd)
        {
            CodeAccessPermission.ValidateElement(esd, this);
            String elem = esd.Attribute("Site");

            m_site = elem == null ? null : new SiteString(elem);
        }
 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;
     }
 }
Ejemplo n.º 6
0
        /// <include file='doc\URLIdentityPermission.uex' path='docs/doc[@for="UrlIdentityPermission.FromXml"]/*' />
        public override void FromXml(SecurityElement esd)
        {
            CodeAccessPermission.ValidateElement(esd, this);
            String elem = esd.Attribute("Url");

            m_url = elem == null ? null : new URLString(elem, true);
        }
        /// <include file='doc\PublisherIdentityPermission.uex' path='docs/doc[@for="PublisherIdentityPermission.FromXml"]/*' />
        public override void FromXml(SecurityElement esd)
        {
            CodeAccessPermission.ValidateElement(esd, this);
            String elem = esd.Attribute("X509v3Certificate");

            m_certificate = elem == null ? null : new X509Certificate(System.Security.Util.Hex.DecodeHexString(elem));
        }
Ejemplo n.º 8
0
 /// <summary>从 XML 编码重新构造具有指定状态的权限。</summary>
 /// <param name="securityElement">
 /// <see cref="T:System.Security.SecurityElement" />,包含用于重新构造权限的 XML 编码。</param>
 /// <exception cref="T:System.ArgumentNullException">
 /// <paramref name="securityElement" /> 为 null。</exception>
 /// <exception cref="T:System.ArgumentException">
 /// <paramref name="securityElement" /> 不是一个有效的权限元素。- 或 -不支持 <paramref name="securityElement" /> 的版本号。</exception>
 public override void FromXml(SecurityElement securityElement)
 {
     CodeAccessPermission.ValidateElement(securityElement, (IPermission)this);
     if (XMLUtil.IsUnrestricted(securityElement))
     {
         this.m_flags         = KeyContainerPermissionFlags.AllFlags;
         this.m_accessEntries = new KeyContainerPermissionAccessEntryCollection(this.m_flags);
     }
     else
     {
         this.m_flags = KeyContainerPermissionFlags.NoFlags;
         string str = securityElement.Attribute("Flags");
         if (str != null)
         {
             KeyContainerPermissionFlags flags = (KeyContainerPermissionFlags)Enum.Parse(typeof(KeyContainerPermissionFlags), str);
             KeyContainerPermission.VerifyFlags(flags);
             this.m_flags = flags;
         }
         this.m_accessEntries = new KeyContainerPermissionAccessEntryCollection(this.m_flags);
         if (securityElement.InternalChildren == null || securityElement.InternalChildren.Count == 0)
         {
             return;
         }
         foreach (SecurityElement child in securityElement.Children)
         {
             if (child != null && string.Equals(child.Tag, "AccessList"))
             {
                 this.AddAccessEntries(child);
             }
         }
     }
 }
Ejemplo n.º 9
0
        public override void FromXml(SecurityElement esd)
        {
            CodeAccessPermission.ValidateElement(esd, this);

            String et;

            if (XMLUtil.IsUnrestricted(esd))
            {
                m_unrestricted = true;
                return;
            }

            m_unrestricted = false;
            m_read         = null;
            m_write        = null;

            et = esd.Attribute("Read");
            if (et != null)
            {
                m_read = new EnvironmentStringExpressionSet(et);
            }

            et = esd.Attribute("Write");
            if (et != null)
            {
                m_write = new EnvironmentStringExpressionSet(et);
            }
        }
Ejemplo n.º 10
0
        public void FromXml(SecurityElement elem)
        {
            CodeAccessPermission.ValidateElement(elem, this);

            if (elem.InternalChildren != null && elem.InternalChildren.Count != 0)
            {
                int numChildren = elem.InternalChildren.Count;
                int count       = 0;

                m_array = new IDRole[numChildren];

                IEnumerator enumerator = elem.Children.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    IDRole idrole = new IDRole();

                    idrole.FromXml((SecurityElement)enumerator.Current);

                    m_array[count++] = idrole;
                }
            }
            else
            {
                m_array = new IDRole[0];
            }
        }
Ejemplo n.º 11
0
        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);
                    }
                }
            }
        }
Ejemplo n.º 12
0
 /// <summary>从 XML 编码重新构造具有指定状态的权限。</summary>
 /// <param name="esd">用于重新构造权限的 XML 编码。</param>
 /// <exception cref="T:System.ArgumentNullException">
 /// <paramref name="esd" /> 参数为 null。</exception>
 /// <exception cref="T:System.ArgumentException">
 /// <paramref name="esd" /> 参数不是有效的权限元素。- 或 -<paramref name="esd" /> 参数的版本号无效。</exception>
 public override void FromXml(SecurityElement esd)
 {
     CodeAccessPermission.ValidateElement(esd, (IPermission)this);
     if (XMLUtil.IsUnrestricted(esd))
     {
         this.m_unrestricted = true;
     }
     else
     {
         this.m_unrestricted = false;
         this.m_read         = (StringExpressionSet)null;
         this.m_write        = (StringExpressionSet)null;
         string str1 = esd.Attribute("Read");
         if (str1 != null)
         {
             this.m_read = (StringExpressionSet) new EnvironmentStringExpressionSet(str1);
         }
         string str2 = esd.Attribute("Write");
         if (str2 == null)
         {
             return;
         }
         this.m_write = (StringExpressionSet) new EnvironmentStringExpressionSet(str2);
     }
 }
Ejemplo n.º 13
0
        /// <include file='doc\StrongNameIdentityPermission.uex' path='docs/doc[@for="StrongNameIdentityPermission.FromXml"]/*' />
        public override void FromXml(SecurityElement e)
        {
            CodeAccessPermission.ValidateElement(e, this);
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            String elBlob = e.Attribute("PublicKeyBlob");

            if (elBlob != null)
            {
                m_publicKeyBlob = new StrongNamePublicKeyBlob(Hex.DecodeHexString(elBlob));
            }
            else
            {
                m_publicKeyBlob = null;
            }

            String elName = e.Attribute("Name");

            m_name = elName == null ? null : elName;

            String elVersion = e.Attribute("AssemblyVersion");

            m_version = elVersion == null ? null : new Version(elVersion);
        }
Ejemplo n.º 14
0
        /// <include file='doc\FileIOPermission.uex' path='docs/doc[@for="FileIOPermission.FromXml"]/*' />
        public override void FromXml(SecurityElement esd)
        {
            CodeAccessPermission.ValidateElement(esd, this);
            String et;

            if (XMLUtil.IsUnrestricted(esd))
            {
                m_unrestricted = true;
                return;
            }


            m_unrestricted = false;

            et = esd.Attribute("Read");
            if (et != null)
            {
                m_read = new FileIOAccess(et);
            }
            else
            {
                m_read = null;
            }

            et = esd.Attribute("Write");
            if (et != null)
            {
                m_write = new FileIOAccess(et);
            }
            else
            {
                m_write = null;
            }

            et = esd.Attribute("Append");
            if (et != null)
            {
                m_append = new FileIOAccess(et);
            }
            else
            {
                m_append = null;
            }

            et = esd.Attribute("PathDiscovery");
            if (et != null)
            {
                m_pathDiscovery = new FileIOAccess(et);
                m_pathDiscovery.PathDiscovery = true;
            }
            else
            {
                m_pathDiscovery = null;
            }
        }
        public override void FromXml(SecurityElement e)
        {
            m_unrestricted = false;
            m_strongNames  = null;
            CodeAccessPermission.ValidateElement(e, this);
            String unr = e.Attribute("Unrestricted");

            if (unr != null && String.Compare(unr, "true", StringComparison.OrdinalIgnoreCase) == 0)
            {
                m_unrestricted = true;
                return;
            }
            String             elBlob    = e.Attribute("PublicKeyBlob");
            String             elName    = e.Attribute("Name");
            String             elVersion = e.Attribute("AssemblyVersion");
            StrongName2        sn;
            List <StrongName2> al = new List <StrongName2>();

            if (elBlob != null || elName != null || elVersion != null)
            {
                sn = new StrongName2(
                    (elBlob == null ? null : new StrongNamePublicKeyBlob(elBlob)),
                    elName,
                    (elVersion == null ? null : new Version(elVersion)));
                al.Add(sn);
            }
            ArrayList alChildren = e.Children;

            if (alChildren != null)
            {
                foreach (SecurityElement child in alChildren)
                {
                    elBlob    = child.Attribute("PublicKeyBlob");
                    elName    = child.Attribute("Name");
                    elVersion = child.Attribute("AssemblyVersion");
                    if (elBlob != null || elName != null || elVersion != null)
                    {
                        sn = new StrongName2(
                            (elBlob == null ? null : new StrongNamePublicKeyBlob(elBlob)),
                            elName,
                            (elVersion == null ? null : new Version(elVersion)));
                        al.Add(sn);
                    }
                }
            }
            if (al.Count != 0)
            {
                m_strongNames = al.ToArray();
            }
        }
Ejemplo n.º 16
0
        /// <include file='doc\ZoneIdentityPermission.uex' path='docs/doc[@for="ZoneIdentityPermission.FromXml"]/*' />
        public override void FromXml(SecurityElement esd)
        {
            CodeAccessPermission.ValidateElement(esd, this);
            String eZone = esd.Attribute("Zone");

            if (eZone == null)
            {
                m_zone = SecurityZone.NoZone;
            }
            else
            {
                m_zone = (SecurityZone)Enum.Parse(typeof(SecurityZone), eZone);
            }
        }
Ejemplo n.º 17
0
 public override void FromXml(SecurityElement esd)
 {
     CodeAccessPermission.ValidateElement( esd, this );
     if (XMLUtil.IsUnrestricted( esd ))
         Resources = HostProtectionResource.All;
     else
     {
         String resources = esd.Attribute( "Resources" );
         if (resources == null)
             Resources = HostProtectionResource.None;
         else
             Resources = (HostProtectionResource)Enum.Parse( typeof( HostProtectionResource ), resources );
     }
 }
        /// <summary>Reconstructs a permission with a specified state from an XML encoding.</summary>
        /// <param name="esd">The XML encoding used to reconstruct the permission. </param>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="esd" /> parameter is <see langword="null" />. </exception>
        /// <exception cref="T:System.ArgumentException">The <paramref name="esd" /> parameter is not a valid permission element.-or- The version number of the <paramref name="esd" /> parameter is not supported. </exception>
        // Token: 0x060024AC RID: 9388 RVA: 0x00085214 File Offset: 0x00083414
        public override void FromXml(SecurityElement esd)
        {
            CodeAccessPermission.ValidateElement(esd, this);
            if (XMLUtil.IsUnrestricted(esd))
            {
                this.SetUnrestricted(true);
                return;
            }
            this.access = FileDialogPermissionAccess.None;
            string text = esd.Attribute("Access");

            if (text != null)
            {
                this.access = (FileDialogPermissionAccess)Enum.Parse(typeof(FileDialogPermissionAccess), text);
            }
        }
        /// <summary>从 XML 编码重新构造具有指定状态的权限。</summary>
        /// <param name="e">用于重新构造权限的 XML 编码。</param>
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="e" /> 参数为 null。</exception>
        /// <exception cref="T:System.ArgumentException">
        /// <paramref name="e" /> 参数不是有效的权限元素。- 或 -<paramref name="e" /> 参数的版本号无效。</exception>
        public override void FromXml(SecurityElement e)
        {
            this.m_unrestricted = false;
            this.m_strongNames  = (StrongName2[])null;
            CodeAccessPermission.ValidateElement(e, (IPermission)this);
            string strA = e.Attribute("Unrestricted");

            if (strA != null && string.Compare(strA, "true", StringComparison.OrdinalIgnoreCase) == 0)
            {
                this.m_unrestricted = true;
            }
            else
            {
                string             publicKey1      = e.Attribute("PublicKeyBlob");
                string             name1           = e.Attribute("Name");
                string             version1        = e.Attribute("AssemblyVersion");
                List <StrongName2> strongName2List = new List <StrongName2>();
                if (publicKey1 != null || name1 != null || version1 != null)
                {
                    StrongName2 strongName2 = new StrongName2(publicKey1 == null ? (StrongNamePublicKeyBlob)null : new StrongNamePublicKeyBlob(publicKey1), name1, version1 == null ? (Version)null : new Version(version1));
                    strongName2List.Add(strongName2);
                }
                ArrayList children = e.Children;
                if (children != null)
                {
                    foreach (SecurityElement securityElement in children)
                    {
                        string name2      = "PublicKeyBlob";
                        string publicKey2 = securityElement.Attribute(name2);
                        string name3      = "Name";
                        string name4      = securityElement.Attribute(name3);
                        string name5      = "AssemblyVersion";
                        string version2   = securityElement.Attribute(name5);
                        if (publicKey2 != null || name4 != null || version2 != null)
                        {
                            StrongName2 strongName2 = new StrongName2(publicKey2 == null ? (StrongNamePublicKeyBlob)null : new StrongNamePublicKeyBlob(publicKey2), name4, version2 == null ? (Version)null : new Version(version2));
                            strongName2List.Add(strongName2);
                        }
                    }
                }
                if (strongName2List.Count == 0)
                {
                    return;
                }
                this.m_strongNames = strongName2List.ToArray();
            }
        }
Ejemplo n.º 20
0
        // Token: 0x0600251A RID: 9498 RVA: 0x000871C0 File Offset: 0x000853C0
        public override void FromXml(SecurityElement esd)
        {
            CodeAccessPermission.ValidateElement(esd, this);
            if (XMLUtil.IsUnrestricted(esd))
            {
                this.Resources = HostProtectionResource.All;
                return;
            }
            string text = esd.Attribute("Resources");

            if (text == null)
            {
                this.Resources = HostProtectionResource.None;
                return;
            }
            this.Resources = (HostProtectionResource)Enum.Parse(typeof(HostProtectionResource), text);
        }
        /// <summary>Reconstructs a permission with a specified state from an XML encoding.</summary>
        /// <param name="esd">The XML encoding to use to reconstruct the permission. </param>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="esd" /> parameter is <see langword="null" />. </exception>
        /// <exception cref="T:System.ArgumentException">The <paramref name="esd" /> parameter is not a valid permission element.-or- The <paramref name="esd" /> parameter's version number is not supported. </exception>
        // Token: 0x06002621 RID: 9761 RVA: 0x000898EC File Offset: 0x00087AEC
        public override void FromXml(SecurityElement esd)
        {
            CodeAccessPermission.ValidateElement(esd, this);
            if (XMLUtil.IsUnrestricted(esd))
            {
                this.m_flags = SecurityPermissionFlag.AllFlags;
                return;
            }
            this.Reset();
            this.SetUnrestricted(false);
            string text = esd.Attribute("Flags");

            if (text != null)
            {
                this.m_flags = (SecurityPermissionFlag)Enum.Parse(typeof(SecurityPermissionFlag), text);
            }
        }
Ejemplo n.º 22
0
        /// <summary>Reconstructs a permission with a specified state from an XML encoding.</summary>
        /// <param name="esd">The XML encoding to use to reconstruct the permission. </param>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="esd" /> parameter is <see langword="null" />. </exception>
        /// <exception cref="T:System.ArgumentException">The <paramref name="esd" /> parameter is not a valid permission element.-or- The <paramref name="esd" /> parameter's version number is not valid. </exception>
        // Token: 0x060025F8 RID: 9720 RVA: 0x000889DC File Offset: 0x00086BDC
        public override void FromXml(SecurityElement esd)
        {
            CodeAccessPermission.ValidateElement(esd, this);
            if (XMLUtil.IsUnrestricted(esd))
            {
                this.m_flags = (ReflectionPermissionFlag.TypeInformation | ReflectionPermissionFlag.MemberAccess | ReflectionPermissionFlag.ReflectionEmit | ReflectionPermissionFlag.RestrictedMemberAccess);
                return;
            }
            this.Reset();
            this.SetUnrestricted(false);
            string text = esd.Attribute("Flags");

            if (text != null)
            {
                this.m_flags = (ReflectionPermissionFlag)Enum.Parse(typeof(ReflectionPermissionFlag), text);
            }
        }
Ejemplo n.º 23
0
 public override void FromXml(SecurityElement esd)
 {
     CodeAccessPermission.ValidateElement(esd, this);
     if (XMLUtil.IsUnrestricted(esd))
     {
         this.m_flags = ReflectionPermissionFlag.RestrictedMemberAccess | ReflectionPermissionFlag.AllFlags;
     }
     else
     {
         this.Reset();
         this.SetUnrestricted(false);
         string str = esd.Attribute("Flags");
         if (str != null)
         {
             this.m_flags = (ReflectionPermissionFlag)Enum.Parse(typeof(ReflectionPermissionFlag), str);
         }
     }
 }
Ejemplo n.º 24
0
        public override void FromXml(SecurityElement e)
        {
            this.m_unrestricted = false;
            this.m_strongNames  = null;
            CodeAccessPermission.ValidateElement(e, this);
            string strA = e.Attribute("Unrestricted");

            if ((strA != null) && (string.Compare(strA, "true", StringComparison.OrdinalIgnoreCase) == 0))
            {
                this.m_unrestricted = true;
            }
            else
            {
                StrongName2        name;
                string             publicKey = e.Attribute("PublicKeyBlob");
                string             str3      = e.Attribute("Name");
                string             version   = e.Attribute("AssemblyVersion");
                List <StrongName2> list      = new List <StrongName2>();
                if (((publicKey != null) || (str3 != null)) || (version != null))
                {
                    name = new StrongName2((publicKey == null) ? null : new StrongNamePublicKeyBlob(publicKey), str3, (version == null) ? null : new System.Version(version));
                    list.Add(name);
                }
                ArrayList children = e.Children;
                if (children != null)
                {
                    foreach (SecurityElement element in children)
                    {
                        publicKey = element.Attribute("PublicKeyBlob");
                        str3      = element.Attribute("Name");
                        version   = element.Attribute("AssemblyVersion");
                        if (((publicKey != null) || (str3 != null)) || (version != null))
                        {
                            name = new StrongName2((publicKey == null) ? null : new StrongNamePublicKeyBlob(publicKey), str3, (version == null) ? null : new System.Version(version));
                            list.Add(name);
                        }
                    }
                }
                if (list.Count != 0)
                {
                    this.m_strongNames = list.ToArray();
                }
            }
        }
        /// <summary>Reconstructs a permission with a specified state from an XML encoding.</summary>
        /// <param name="e">The XML encoding to use to reconstruct the permission. </param>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="e" /> parameter is <see langword="null" />. </exception>
        /// <exception cref="T:System.ArgumentException">The <paramref name="e" /> parameter is not a valid permission element.-or- The <paramref name="e" /> parameter's version number is not valid. </exception>
        // Token: 0x06002644 RID: 9796 RVA: 0x0008A7A8 File Offset: 0x000889A8
        public override void FromXml(SecurityElement e)
        {
            this.m_unrestricted = false;
            this.m_strongNames  = null;
            CodeAccessPermission.ValidateElement(e, this);
            string text = e.Attribute("Unrestricted");

            if (text != null && string.Compare(text, "true", StringComparison.OrdinalIgnoreCase) == 0)
            {
                this.m_unrestricted = true;
                return;
            }
            string             text2 = e.Attribute("PublicKeyBlob");
            string             text3 = e.Attribute("Name");
            string             text4 = e.Attribute("AssemblyVersion");
            List <StrongName2> list  = new List <StrongName2>();

            if (text2 != null || text3 != null || text4 != null)
            {
                StrongName2 item = new StrongName2((text2 == null) ? null : new StrongNamePublicKeyBlob(text2), text3, (text4 == null) ? null : new Version(text4));
                list.Add(item);
            }
            ArrayList children = e.Children;

            if (children != null)
            {
                foreach (object obj in children)
                {
                    SecurityElement securityElement = (SecurityElement)obj;
                    text2 = securityElement.Attribute("PublicKeyBlob");
                    text3 = securityElement.Attribute("Name");
                    text4 = securityElement.Attribute("AssemblyVersion");
                    if (text2 != null || text3 != null || text4 != null)
                    {
                        StrongName2 item = new StrongName2((text2 == null) ? null : new StrongNamePublicKeyBlob(text2), text3, (text4 == null) ? null : new Version(text4));
                        list.Add(item);
                    }
                }
            }
            if (list.Count != 0)
            {
                this.m_strongNames = list.ToArray();
            }
        }
Ejemplo n.º 26
0
        public override void FromXml(SecurityElement esd)
        {
            CodeAccessPermission.ValidateElement(esd, this);
            if (XMLUtil.IsUnrestricted(esd))
            {
                m_flags = ReflectionPermission.AllFlagsAndMore;
                return;
            }

            Reset();
            SetUnrestricted(false);

            String flags = esd.Attribute("Flags");

            if (flags != null)
            {
                m_flags = (ReflectionPermissionFlag)Enum.Parse(typeof(ReflectionPermissionFlag), flags);
            }
        }
Ejemplo n.º 27
0
 /// <summary>从 XML 编码重新构造具有指定状态的权限。</summary>
 /// <param name="esd">用于重新构造权限的 XML 编码。</param>
 /// <exception cref="T:System.ArgumentNullException">
 /// <paramref name="esd" /> 参数为 null。</exception>
 /// <exception cref="T:System.ArgumentException">
 /// <paramref name="esd" /> 参数不是有效的权限元素。- 或 -<paramref name="esd" /> 参数的版本号无效。</exception>
 public override void FromXml(SecurityElement esd)
 {
     CodeAccessPermission.ValidateElement(esd, (IPermission)this);
     if (XMLUtil.IsUnrestricted(esd))
     {
         this.m_unrestricted = true;
     }
     else
     {
         this.m_unrestricted = false;
         this.m_read         = (StringExpressionSet)null;
         this.m_write        = (StringExpressionSet)null;
         this.m_create       = (StringExpressionSet)null;
         this.m_viewAcl      = (StringExpressionSet)null;
         this.m_changeAcl    = (StringExpressionSet)null;
         string str1 = esd.Attribute("Read");
         if (str1 != null)
         {
             this.m_read = new StringExpressionSet(str1);
         }
         string str2 = esd.Attribute("Write");
         if (str2 != null)
         {
             this.m_write = new StringExpressionSet(str2);
         }
         string str3 = esd.Attribute("Create");
         if (str3 != null)
         {
             this.m_create = new StringExpressionSet(str3);
         }
         string str4 = esd.Attribute("ViewAccessControl");
         if (str4 != null)
         {
             this.m_viewAcl = new StringExpressionSet(str4);
         }
         string str5 = esd.Attribute("ChangeAccessControl");
         if (str5 == null)
         {
             return;
         }
         this.m_changeAcl = new StringExpressionSet(str5);
     }
 }
Ejemplo n.º 28
0
        public override void FromXml(SecurityElement esd)
        {
            CodeAccessPermission.ValidateElement(esd, this);

            m_allowed = IsolatedStorageContainment.None;    // default if no match

            if (XMLUtil.IsUnrestricted(esd))
            {
                m_allowed = IsolatedStorageContainment.UnrestrictedIsolatedStorage;
            }
            else
            {
                String allowed = esd.Attribute("Allowed");

                if (allowed != null)
                {
                    m_allowed = (IsolatedStorageContainment)Enum.Parse(typeof(IsolatedStorageContainment), allowed);
                }
            }

            if (m_allowed == IsolatedStorageContainment.UnrestrictedIsolatedStorage)
            {
                m_userQuota      = Int64.MaxValue;
                m_machineQuota   = Int64.MaxValue;
                m_expirationDays = Int64.MaxValue;
                m_permanentData  = true;
            }
            else
            {
                String param;
                param       = esd.Attribute(_strUserQuota);
                m_userQuota = param != null?Int64.Parse(param, CultureInfo.InvariantCulture) : 0;

                param          = esd.Attribute(_strMachineQuota);
                m_machineQuota = param != null?Int64.Parse(param, CultureInfo.InvariantCulture) : 0;

                param            = esd.Attribute(_strExpiry);
                m_expirationDays = param != null?Int64.Parse(param, CultureInfo.InvariantCulture) : 0;

                param           = esd.Attribute(_strPermDat);
                m_permanentData = param != null ? (Boolean.Parse(param)) : false;
            }
        }
 public override void FromXml(SecurityElement esd)
 {
     CodeAccessPermission.ValidateElement(esd, this);
     if (XMLUtil.IsUnrestricted(esd))
     {
         this.m_unrestricted = true;
     }
     else
     {
         this.m_unrestricted = false;
         this.m_read         = null;
         this.m_write        = null;
         this.m_create       = null;
         this.m_viewAcl      = null;
         this.m_changeAcl    = null;
         string str = esd.Attribute("Read");
         if (str != null)
         {
             this.m_read = new StringExpressionSet(str);
         }
         str = esd.Attribute("Write");
         if (str != null)
         {
             this.m_write = new StringExpressionSet(str);
         }
         str = esd.Attribute("Create");
         if (str != null)
         {
             this.m_create = new StringExpressionSet(str);
         }
         str = esd.Attribute("ViewAccessControl");
         if (str != null)
         {
             this.m_viewAcl = new StringExpressionSet(str);
         }
         str = esd.Attribute("ChangeAccessControl");
         if (str != null)
         {
             this.m_changeAcl = new StringExpressionSet(str);
         }
     }
 }
 public override void FromXml(SecurityElement esd)
 {
     CodeAccessPermission.ValidateElement(esd, (IPermission)this);
     if (XMLUtil.IsUnrestricted(esd))
     {
         this.Resources = HostProtectionResource.All;
     }
     else
     {
         string str = esd.Attribute("Resources");
         if (str == null)
         {
             this.Resources = HostProtectionResource.None;
         }
         else
         {
             this.Resources = (HostProtectionResource)Enum.Parse(typeof(HostProtectionResource), str);
         }
     }
 }