Пример #1
0
 // Fetch the contents of the "values.reg" file into the internal cache.
 private void ReadToCache()
 {
     try
     {
         StreamReader reader = new StreamReader
                                   (directory + Path.DirectorySeparatorChar +
                                   "values.reg");
         String xml = reader.ReadToEnd();
         reader.Close();
         values = SecurityElement.Parse(xml);
     }
     catch (IOException)
     {
         values = new SecurityElement("values");
     }
 }
Пример #2
0
        // Create a permission set object.
        public PermissionSet CreatePermissionSet()
        {
            PermissionSet   set;
            SecurityElement element;
            StreamReader    reader;
            String          buf;

            if (Unrestricted)
            {
                set = new PermissionSet(PermissionState.Unrestricted);
            }
            else if (name != null)
            {
                set = CreateBuiltinPermissionSet(name);
            }
            else if (file != null)
            {
                // Parse the contents of a file.
                reader = new StreamReader(file);
                buf    = reader.ReadToEnd();
                reader.Close();
                set     = new PermissionSet(PermissionState.None);
                element = SecurityElement.Parse(buf);
                if (element != null)
                {
                    set.FromXml(element);
                }
            }
            else if (xml != null)
            {
                // Parse the contents of a string.
                set     = new PermissionSet(PermissionState.None);
                element = SecurityElement.Parse(xml);
                if (element != null)
                {
                    set.FromXml(element);
                }
            }
            else
            {
                set = new PermissionSet(PermissionState.None);
            }
            return(set);
        }