Exemplo n.º 1
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));
         }
     }
 }
Exemplo n.º 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);
         }
     }
 }
        /// <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);
            }
        }
 /// <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;
         }
     }
 }
 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")));
     }
 }
 /// <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);
         }
     }
 }
Exemplo n.º 7
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));
         }
     }
 }
Exemplo n.º 8
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));
         }
     }
 }
Exemplo n.º 9
0
        private PermissionSet CreateFromXml(string xml)
        {
#if !NET_2_1
            SecurityParser sp = new SecurityParser();
            try
            {
                sp.LoadXml(xml);
            }
            catch (Mono.Xml.SmallXmlParserException xe)
            {
                throw new XmlSyntaxException(xe.Line, xe.ToString());
            }
            SecurityElement se = sp.ToXml();

            string className = se.Attribute("class");
            if (className == null)
            {
                return(null);
            }

            PermissionState state = PermissionState.None;
            if (CodeAccessPermission.IsUnrestricted(se))
            {
                state = PermissionState.Unrestricted;
            }

            if (className.EndsWith("NamedPermissionSet"))
            {
                NamedPermissionSet nps = new NamedPermissionSet(se.Attribute("Name"), state);
                nps.FromXml(se);
                return((PermissionSet)nps);
            }
            else if (className.EndsWith("PermissionSet"))
            {
                PermissionSet ps = new PermissionSet(state);
                ps.FromXml(se);
                return(ps);
            }
#endif
            return(null);
        }