コード例 #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 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>
 public override void FromXml(SecurityElement esd)
 {
     CodeAccessPermission.CheckSecurityElement(esd, "esd", 1, 1);
     if (CodeAccessPermission.IsUnrestricted(esd))
     {
         this.flags = ReflectionPermissionFlag.AllFlags;
     }
     else
     {
         this.flags = ReflectionPermissionFlag.NoFlags;
         string text = esd.Attributes["Flags"] as string;
         if (text.IndexOf("MemberAccess") >= 0)
         {
             this.flags |= ReflectionPermissionFlag.MemberAccess;
         }
         if (text.IndexOf("ReflectionEmit") >= 0)
         {
             this.flags |= ReflectionPermissionFlag.ReflectionEmit;
         }
         if (text.IndexOf("TypeInformation") >= 0)
         {
             this.flags |= ReflectionPermissionFlag.TypeInformation;
         }
     }
 }
コード例 #2
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 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>
 public override void FromXml(SecurityElement esd)
 {
     CodeAccessPermission.CheckSecurityElement(esd, "esd", 1, 1);
     this.m_userQuota      = 0L;
     this.m_machineQuota   = 0L;
     this.m_expirationDays = 0L;
     this.m_permanentData  = false;
     this.m_allowed        = IsolatedStorageContainment.None;
     if (CodeAccessPermission.IsUnrestricted(esd))
     {
         this.UsageAllowed = IsolatedStorageContainment.UnrestrictedIsolatedStorage;
     }
     else
     {
         string text = esd.Attribute("Allowed");
         if (text != null)
         {
             this.UsageAllowed = (IsolatedStorageContainment)((int)Enum.Parse(typeof(IsolatedStorageContainment), text));
         }
         text = esd.Attribute("UserQuota");
         if (text != null)
         {
             Exception ex;
             long.Parse(text, true, out this.m_userQuota, out ex);
         }
     }
 }
コード例 #3
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 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>
        public override void FromXml(SecurityElement esd)
        {
            CodeAccessPermission.CheckSecurityElement(esd, "esd", 1, 1);
            CodeAccessPermission.CheckSecurityElement(esd, "esd", 1, 1);
            if (CodeAccessPermission.IsUnrestricted(esd))
            {
                this._state = PermissionState.Unrestricted;
            }
            string text = esd.Attribute("Create");

            if (text != null && text.Length > 0)
            {
                this.SetPathList(RegistryPermissionAccess.Create, text);
            }
            string text2 = esd.Attribute("Read");

            if (text2 != null && text2.Length > 0)
            {
                this.SetPathList(RegistryPermissionAccess.Read, text2);
            }
            string text3 = esd.Attribute("Write");

            if (text3 != null && text3.Length > 0)
            {
                this.SetPathList(RegistryPermissionAccess.Write, text3);
            }
        }
コード例 #4
0
 /// <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 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>
 public override void FromXml(SecurityElement esd)
 {
     CodeAccessPermission.CheckSecurityElement(esd, "esd", 1, 1);
     if (CodeAccessPermission.IsUnrestricted(esd))
     {
         this._window    = UIPermissionWindow.AllWindows;
         this._clipboard = UIPermissionClipboard.AllClipboard;
     }
     else
     {
         string text = esd.Attribute("Window");
         if (text == null)
         {
             this._window = UIPermissionWindow.NoWindows;
         }
         else
         {
             this._window = (UIPermissionWindow)((int)Enum.Parse(typeof(UIPermissionWindow), text));
         }
         string text2 = esd.Attribute("Clipboard");
         if (text2 == null)
         {
             this._clipboard = UIPermissionClipboard.NoClipboard;
         }
         else
         {
             this._clipboard = (UIPermissionClipboard)((int)Enum.Parse(typeof(UIPermissionClipboard), text2));
         }
     }
 }
コード例 #5
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 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>
        public override void FromXml(SecurityElement esd)
        {
            CodeAccessPermission.CheckSecurityElement(esd, "esd", 1, 1);
            string text = esd.Attribute("Site");

            if (text != null)
            {
                this.Site = text;
            }
        }
コード例 #6
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 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>
        /// <PermissionSet>
        ///   <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Create" />
        /// </PermissionSet>
        public override void FromXml(SecurityElement esd)
        {
            CodeAccessPermission.CheckSecurityElement(esd, "esd", 1, 1);
            string text = esd.Attributes["X509v3Certificate"] as string;

            if (text != null)
            {
                byte[] data = CryptoConvert.FromHex(text);
                this.x509 = new X509Certificate(data);
            }
        }
コード例 #7
0
 public override void FromXml(SecurityElement securityElement)
 {
     CodeAccessPermission.CheckSecurityElement(securityElement, "securityElement", 1, 1);
     if (CodeAccessPermission.IsUnrestricted(securityElement))
     {
         this._flags = KeyContainerPermissionFlags.AllFlags;
     }
     else
     {
         this._flags = (KeyContainerPermissionFlags)((int)Enum.Parse(typeof(KeyContainerPermissionFlags), securityElement.Attribute("Flags")));
     }
 }
コード例 #8
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 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>
        public override void FromXml(SecurityElement esd)
        {
            CodeAccessPermission.CheckSecurityElement(esd, "esd", 1, 1);
            string text = esd.Attribute("Zone");

            if (text == null)
            {
                this.zone = SecurityZone.NoZone;
            }
            else
            {
                this.zone = (SecurityZone)((int)Enum.Parse(typeof(SecurityZone), text));
            }
        }
コード例 #9
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 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>
        public override void FromXml(SecurityElement esd)
        {
            CodeAccessPermission.CheckSecurityElement(esd, "esd", 1, 1);
            string text = esd.Attribute("Url");

            if (text == null)
            {
                this.url = string.Empty;
            }
            else
            {
                this.Url = text;
            }
        }
コード例 #10
0
 /// <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 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 compatible. </exception>
 public override void FromXml(SecurityElement esd)
 {
     CodeAccessPermission.CheckSecurityElement(esd, "esd", 1, 1);
     if (CodeAccessPermission.IsUnrestricted(esd))
     {
         this.m_Unrestricted = true;
     }
     else
     {
         this.m_Unrestricted = false;
         string text = esd.Attribute("Read");
         if (text != null)
         {
             string[] array = text.Split(new char[]
             {
                 ';'
             });
             this.AddPathList(FileIOPermissionAccess.Read, array);
         }
         text = esd.Attribute("Write");
         if (text != null)
         {
             string[] array = text.Split(new char[]
             {
                 ';'
             });
             this.AddPathList(FileIOPermissionAccess.Write, array);
         }
         text = esd.Attribute("Append");
         if (text != null)
         {
             string[] array = text.Split(new char[]
             {
                 ';'
             });
             this.AddPathList(FileIOPermissionAccess.Append, array);
         }
         text = esd.Attribute("PathDiscovery");
         if (text != null)
         {
             string[] array = text.Split(new char[]
             {
                 ';'
             });
             this.AddPathList(FileIOPermissionAccess.PathDiscovery, array);
         }
     }
 }
コード例 #11
0
 /// <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 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>
 public override void FromXml(SecurityElement e)
 {
     CodeAccessPermission.CheckSecurityElement(e, "e", 1, 1);
     this._list.Clear();
     if (e.Children != null && e.Children.Count > 0)
     {
         foreach (object obj in e.Children)
         {
             SecurityElement se = (SecurityElement)obj;
             this._list.Add(this.FromSecurityElement(se));
         }
     }
     else
     {
         this._list.Add(this.FromSecurityElement(e));
     }
 }
コード例 #12
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 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>
 public override void FromXml(SecurityElement esd)
 {
     CodeAccessPermission.CheckSecurityElement(esd, "esd", 1, 1);
     if (CodeAccessPermission.IsUnrestricted(esd))
     {
         this.flags = SecurityPermissionFlag.AllFlags;
     }
     else
     {
         string text = esd.Attribute("Flags");
         if (text == null)
         {
             this.flags = SecurityPermissionFlag.NoFlags;
         }
         else
         {
             this.flags = (SecurityPermissionFlag)((int)Enum.Parse(typeof(SecurityPermissionFlag), text));
         }
     }
 }
コード例 #13
0
 /// <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 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>
 public override void FromXml(SecurityElement esd)
 {
     CodeAccessPermission.CheckSecurityElement(esd, "esd", 1, 1);
     if (CodeAccessPermission.IsUnrestricted(esd))
     {
         this._access = FileDialogPermissionAccess.OpenSave;
     }
     else
     {
         string text = esd.Attribute("Access");
         if (text == null)
         {
             this._access = FileDialogPermissionAccess.None;
         }
         else
         {
             this._access = (FileDialogPermissionAccess)((int)Enum.Parse(typeof(FileDialogPermissionAccess), text));
         }
     }
 }
コード例 #14
0
 public override void FromXml(SecurityElement e)
 {
     CodeAccessPermission.CheckSecurityElement(e, "e", 1, 1);
     this._resources = (HostProtectionResource)((int)Enum.Parse(typeof(HostProtectionResource), e.Attribute("Resources")));
 }
コード例 #15
0
 /// <summary>Creates a permission from an XML encoding.</summary>
 /// <param name="securityElement">A <see cref="T:System.Security.SecurityElement" />  that contains the XML encoding to use to create the permission. </param>
 /// <exception cref="T:System.ArgumentNullException">
 ///   <paramref name="securityElement" />is 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 valid. </exception>
 public override void FromXml(SecurityElement securityElement)
 {
     CodeAccessPermission.CheckSecurityElement(securityElement, "securityElement", 1, 1);
 }