当前位置: 首页>>代码示例>>C#>>正文


C# PermissionSet.FromXml方法代码示例

本文整理汇总了C#中System.Security.PermissionSet.FromXml方法的典型用法代码示例。如果您正苦于以下问题:C# PermissionSet.FromXml方法的具体用法?C# PermissionSet.FromXml怎么用?C# PermissionSet.FromXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Security.PermissionSet的用法示例。


在下文中一共展示了PermissionSet.FromXml方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParsePermissionSet

 private PermissionSet ParsePermissionSet(Parser parser)
 {
     SecurityElement topElement = parser.GetTopElement();
     PermissionSet set = new PermissionSet(PermissionState.None);
     set.FromXml(topElement);
     return set;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:PermissionSetAttribute.cs

示例2: Create

        public static PluginHost Create(string pluginId, IDictionary<string, object> config)
        {
            var currentDirectory = Directory.GetCurrentDirectory();

            var setup = new AppDomainSetup
            {
                ApplicationBase = currentDirectory,
                ApplicationName = pluginId,
                ConfigurationFile = "", // DO not set to empty string if we want to use the conf file from this domain
                DisallowBindingRedirects = true,
                DisallowCodeDownload = true,
                DisallowPublisherPolicy = true
            };

            var permissions = new PermissionSet(PermissionState.None);

            if (config.ContainsKey("Permissions") && config["Permissions"] != null)
            {
                var securityElement = SecurityElement.FromString(config["Permissions"].ToString());

                if (securityElement != null)
                {
                    permissions.FromXml(securityElement);
                }
            }

            permissions.AddPermission(new SecurityPermission(SecurityPermissionFlag.ControlEvidence // To get nice exceptions with permission demands.
                | SecurityPermissionFlag.ControlPolicy   // See ^
                | SecurityPermissionFlag.Execution       // To allow the plugin to execute
                ));

            // WCF hosting for JSONRPC
            permissions.AddPermission(new WebPermission(NetworkAccess.Connect | NetworkAccess.Accept,
                new Regex(@"http://localhost:31337/hadouken\.plugins.*")));

            // Isolated storage
            permissions.AddPermission(new IsolatedStorageFilePermission(PermissionState.Unrestricted));

            var ev = new Evidence(new EvidenceBase[] {new Url(config["Url"].ToString())}, null);

            var fxAsm = Assembly.LoadFile(Path.Combine(currentDirectory, FxAssembly));
            var domain = AppDomain.CreateDomain(pluginId, ev, setup, permissions,
                typeof (PluginHost).Assembly.Evidence.GetHostEvidence<StrongName>(),
                fxAsm.Evidence.GetHostEvidence<StrongName>());

            return (PluginHost) Activator.CreateInstanceFrom(
                domain,
                typeof (PluginHost).Assembly.ManifestModule.FullyQualifiedName,
                typeof (PluginHost).FullName,
                false,
                BindingFlags.Default,
                null,
                new object[] {pluginId, config},
                null,
                null).Unwrap();
        }
开发者ID:KyulingLee,项目名称:hadouken,代码行数:56,代码来源:PluginHost.cs

示例3: UpdateHandler

        internal static void UpdateHandler( String[] args )
        {
            if (args[0].Equals( "__internal_usage__" ))
            {
                Console.WriteLine( "SecDBEdit -update <file>\n    Add translations for database entries with missing binary values" );
                return;
            }
            
            if (args.Length < 2)
            {
                Error( "-update", "Not enough arguments", -1 );
            }
            
            ArrayList list = null;
            
            try
            {
                list = LoadDatabase( args[1] );
            }
            catch (Exception e)
            {
                Error( "-update", "Failed during load - " + e.Message, -1 );
            }
            
            for (int i = 0; i < list.Count; ++i)
            {
                if ((((DatabaseEntry)list[i]).xml != null) && (((DatabaseEntry)list[i]).binary == null))
                {
                    try
                    {
                        Console.WriteLine( "Adding binary value for entry #" + (i+1) + ":" );
                        PermissionSet pset;
                        if (IsSecAttr( ((DatabaseEntry)list[i]).xml))
                        {
                            pset = SecAttrToPermSet( ((DatabaseEntry)list[i]).xml );
                            Console.WriteLine( pset.ToString() );
                        }
                        else
                        {
                            SecurityElement elem = GetElementFromUbyte( ((DatabaseEntry)list[i]).xml );
                            Console.WriteLine( elem.ToString() );
                            pset = new PermissionSet( PermissionState.None );
                            pset.FromXml( elem );
                        }
                        MemoryStream stream = new MemoryStream();
                        BinaryFormatter formatter = new BinaryFormatter();
                        formatter.Serialize( stream, pset );
                        ((DatabaseEntry)list[i]).binary = stream.ToArray();
                        
                    }
                    catch (Exception)
                    {
                        Console.WriteLine( "Error converting entry");
                    }
                }
            }

            try
            {
                SaveDatabase( args[1], list );
            }
            catch (Exception)
            {
                Error( "-update", "Error saving database", -1 );
            }
        }
开发者ID:ArildF,项目名称:masters,代码行数:66,代码来源:secdbedit.cs

示例4: PermissionSetDemo

		public static void PermissionSetDemo()
		{
			
			Console.WriteLine("Executing Permission Set Demo");
			try
			{
				// Open a permission set.
				PermissionSet ps1 = new PermissionSet(PermissionState.None);
				Console.WriteLine("Adding permission to open a file from a file dialog box.");
				// Add a permission to the permission set.
				ps1.AddPermission(new FileDialogPermission(FileDialogPermissionAccess.Open));
				Console.WriteLine("Demanding Permission to open a file.");
				ps1.Demand();
				Console.WriteLine("Demand succeeded.");
				Console.WriteLine("Adding permission to save a file from a file dialog box.");
				ps1.AddPermission(new FileDialogPermission(FileDialogPermissionAccess.Save));
				Console.WriteLine("Demanding permission to open and save a file.");
				ps1.Demand();
				Console.WriteLine("Demand succeeded.");
				Console.WriteLine("Adding a permission to read environment variable USERNAME.");
				ps1.AddPermission(new EnvironmentPermission(EnvironmentPermissionAccess.Read, "USERNAME"));
				ps1.Demand();
				Console.WriteLine("Demand succeeded.");
				Console.WriteLine("Adding permission to read environment variable COMPUTERNAME.");
				ps1.AddPermission(new EnvironmentPermission(EnvironmentPermissionAccess.Read, "COMPUTERNAME"));
				// Demand all the permissions in the set.
				Console.WriteLine("Demand all permissions.");
				ps1.Demand();
				Console.WriteLine("Demand succeeded.");
				// Display the number of permissions in the set.
				Console.WriteLine("Number of permissions = " + ps1.Count);
				// Display the value of the IsSynchronized property.
				Console.WriteLine("IsSynchronized property = " + ps1.IsSynchronized);
				// Display the value of the IsReadOnly property.
				Console.WriteLine("IsReadOnly property = " + ps1.IsReadOnly);
				// Display the value of the SyncRoot property.
				Console.WriteLine("SyncRoot property = " + ps1.SyncRoot);
				// Display the result of a call to the ContainsNonCodeAccessPermissions method.
				// Gets a value indicating whether the PermissionSet contains permissions
				// that are not derived from CodeAccessPermission.
				// Returns true if the PermissionSet contains permissions that are not 
				// derived from CodeAccessPermission; otherwise, false.
				Console.WriteLine("ContainsNonCodeAccessPermissions method returned " + ps1.ContainsNonCodeAccessPermissions());
				Console.WriteLine("Value of the permission set ToString = \n" + ps1.ToString());
				PermissionSet ps2 = new PermissionSet(PermissionState.None);
				// Create a second permission set and compare it to the first permission set.
				ps2.AddPermission(new EnvironmentPermission(EnvironmentPermissionAccess.Read, "USERNAME"));
				ps2.AddPermission(new EnvironmentPermission(EnvironmentPermissionAccess.Write, "COMPUTERNAME"));
				Console.WriteLine("Permission set 2 = " + ps2);
				IEnumerator list = ps1.GetEnumerator();
				Console.WriteLine("Permissions in first permission set:");
				foreach (var permission in ps1)
					Console.WriteLine(permission.ToString());
				Console.WriteLine("Second permission IsSubSetOf first permission = " + ps2.IsSubsetOf(ps1));
				// Display the intersection of two permission sets.
				PermissionSet ps3 = ps2.Intersect(ps1);
				Console.WriteLine("The intersection of the first permission set and the second permission set = " + ps3.ToString());
				// Create a new permission set.
				PermissionSet ps4 = new PermissionSet(PermissionState.None);
				ps4.AddPermission(new FileIOPermission(FileIOPermissionAccess.Read, "C:\\Temp\\Testfile.txt"));
				ps4.AddPermission(new FileIOPermission(FileIOPermissionAccess.Write | FileIOPermissionAccess.Append, "C:\\Temp\\Testfile.txt"));
				// Display the union of two permission sets.
				PermissionSet ps5 = ps3.Union(ps4);
				Console.WriteLine("The union of permission set 3 and permission set 4 = " + ps5.ToString());
				// Remove FileIOPermission from the permission set.
				ps5.RemovePermission(typeof(FileIOPermission));
				Console.WriteLine("The last permission set after removing FileIOPermission = " + ps5.ToString());
				// Change the permission set using SetPermission
				ps5.SetPermission(new EnvironmentPermission(EnvironmentPermissionAccess.AllAccess, "USERNAME"));
				Console.WriteLine("Permission set after SetPermission = " + ps5.ToString());
				// Display result of ToXml and FromXml operations.
				PermissionSet ps6 = new PermissionSet(PermissionState.None);
				ps6.FromXml(ps5.ToXml());
				Console.WriteLine("Result of ToFromXml = " + ps6.ToString() + "\n");
				// Display result of PermissionSet.GetEnumerator.
				IEnumerator psEnumerator = ps1.GetEnumerator();
				while (psEnumerator.MoveNext())
				{
					Console.WriteLine(psEnumerator.Current.ToString());
				}
				// Check for an unrestricted permission set.
				PermissionSet ps7 = new PermissionSet(PermissionState.Unrestricted);
				Console.WriteLine("Permission set is unrestricted = " + ps7.IsUnrestricted());
				// Create and display a copy of a permission set.
				ps7 = ps5.Copy();
				Console.WriteLine("Result of copy = " + ps7.ToString());
			}
			catch (Exception e)
			{
				Console.WriteLine(e.Message.ToString());
			}
		}
开发者ID:oblivious,项目名称:Oblivious,代码行数:92,代码来源:Program.cs

示例5: Deserialize

        [System.Security.SecurityCritical]  // auto-generated
        private static Object Deserialize(byte[] blob)
        {
            if (blob == null)
                return null;

            if (blob[0] == 0)
            {
                Parser parser = new Parser( blob, Tokenizer.ByteTokenEncoding.UTF8Tokens, 1 );
                SecurityElement root = parser.GetTopElement();
                if (root.Tag.Equals( "IPermission" ) || root.Tag.Equals( "Permission" ))
                {
                    IPermission ip = System.Security.Util.XMLUtil.CreatePermission( root, PermissionState.None, false );

                    if (ip == null)
                    {
                        return null;
                    }

                    ip.FromXml( root );

                    return ip;
                }
                else if (root.Tag.Equals( "PermissionSet" ))
                {
                    PermissionSet permissionSet = new PermissionSet();

                    permissionSet.FromXml( root, false, false );

                    return permissionSet;
                }
                else if (root.Tag.Equals( "PermissionToken" ))
                {
                    PermissionToken pToken = new PermissionToken();

                    pToken.FromXml( root );

                    return pToken;
                }
                else
                {
                    return null;
                }

            }
            else
            {
                Object obj = null;
                using(MemoryStream stream = new MemoryStream( blob, 1, blob.Length - 1 )) {
                    obj = CrossAppDomainSerializer.DeserializeObject(stream);
                }

                Contract.Assert( !(obj is IPermission), "IPermission should be xml deserialized" );
                Contract.Assert( !(obj is PermissionSet), "PermissionSet should be xml deserialized" );

                return obj;
            }
        }
开发者ID:Rayislandstyle,项目名称:dotnet-coreclr,代码行数:58,代码来源:AppDomain.cs

示例6: FromXml_PermissionOutsideCorlib

		public void FromXml_PermissionOutsideCorlib ()
		{
			SecurityElement child = new SecurityElement ("IPermission");
			child.AddAttribute ("class", "PrintingPermission");	// System.Drawing
			child.AddAttribute ("version", "1");
			child.AddAttribute ("Level", "DefaultPrinting");

			SecurityElement se = new SecurityElement ("PermissionSet");
			se.AddAttribute ("class", "PermissionSet");
			se.AddAttribute ("version", "1");
			se.AddChild (child);

			PermissionSet ps = new PermissionSet (PermissionState.None);
			ps.FromXml (se);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:15,代码来源:PermissionSetTest.cs

示例7: FromXmlWrongVersion

		// [ExpectedException (typeof (ArgumentException))]
		public void FromXmlWrongVersion () 
		{
			PermissionSet ps = new PermissionSet (PermissionState.None);
			SecurityElement se = ps.ToXml ();
			// can't modify - so we create our own
			SecurityElement se2 = new SecurityElement (se.Tag, se.Text);
			se2.AddAttribute ("class", se.Attribute ("class"));
			se2.AddAttribute ("version", "2");
			ps.FromXml (se2);
			// wow - here we accept a version 2 !!!
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:12,代码来源:PermissionSetTest.cs

示例8: FromXmlNull

		public void FromXmlNull () 
		{
			PermissionSet ps = new PermissionSet (PermissionState.None);
			ps.FromXml (null);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:5,代码来源:PermissionSetTest.cs

示例9: IsDataObjectFromLessPriviligedApplicationDomain

        private static bool IsDataObjectFromLessPriviligedApplicationDomain(IDataObject dataObjectToApply) 
        {
            bool retVal = false; 
            object applicationTrust = null; 
            // Extract the permission set in case of xaml cut and paste
            // extract permission set if it exists if not data came from full trust app and we do not care 
            bool isApplicationTrustFormatPresent = false;
            isApplicationTrustFormatPresent = dataObjectToApply.GetDataPresent(DataFormats.ApplicationTrust, /*autoConvert:*/false);
            if (isApplicationTrustFormatPresent)
            { 
                applicationTrust = dataObjectToApply.GetData(DataFormats.ApplicationTrust, /*autoConvert:*/false);
            } 
 
            if (applicationTrust != null)
            { 
                string applicationTrustText = null;
                // convert to string
                applicationTrustText = applicationTrust.ToString();
 

                // Convert string to permission set for getting permission set of source 
                PermissionSet permissionSetSource; 
                try
                { 
                    SecurityElement securityElement = SecurityElement.FromString(applicationTrustText);
                    permissionSetSource = new System.Security.PermissionSet(PermissionState.None);
                    permissionSetSource.FromXml(securityElement);
                } 
                catch(XmlSyntaxException)
                { 
                    // This is the condition where we have Malformed XML in the clipboard for application trust 
                    // here we will fail silently since we do not want to break arbitrary applications
                    // but since we cannot establish the validity of the application trust content we will fall back to 
                    // whatever is more secure
                    return  true;
                }
 
                //extract permission set for the current appdomain which is target
                PermissionSet permissionSetDestination = SecurityHelper.ExtractAppDomainPermissionSetMinusSiteOfOrigin(); 
                //Compare permissions sets 
                if (!permissionSetDestination.IsSubsetOf(permissionSetSource))
                { 
                    retVal = true; // in case target is not subset of source revert to unicode or text
                }
            }
            return retVal; 
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:47,代码来源:clipboard.cs

示例10: CreatePermissionSet

	// 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;
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:45,代码来源:PermissionSetAttribute.cs

示例11: ConvertPermissionSet

        ConvertPermissionSet(String inFormat,
                             byte[] inData,
                             String outFormat)
        {
            if(inData == null) 
                return null;
            if(inFormat == null)
                throw new ArgumentNullException("inFormat");
            if(outFormat == null)
                throw new ArgumentNullException("outFormat");
    
            PermissionSet permSet = new PermissionSet( false );
    
            inFormat = String.SmallCharToUpper(inFormat);
            outFormat = String.SmallCharToUpper(outFormat);

            if (inFormat.Equals( "XMLASCII" ) || inFormat.Equals( "XML" ))
            {
                permSet.FromXml( new Parser( inData, Tokenizer.ByteTokenEncoding.ByteTokens ).GetTopElement() );
            }
            else if (inFormat.Equals( "XMLUNICODE" ))
            {
                permSet.FromXml( new Parser( inData, Tokenizer.ByteTokenEncoding.UnicodeTokens ).GetTopElement() );
            }
            else if (inFormat.Equals( "BINARY" ))
            {
                permSet.DecodeUsingSerialization( inData );
            }
            else
            {
                return null;
            }
            
            if (outFormat.Equals( "XMLASCII" ) || outFormat.Equals( "XML" ))
            {
                MemoryStream ms = new MemoryStream();
                StreamWriter writer = new StreamWriter( ms, Encoding.ASCII );
                writer.Write( permSet.ToXml().ToString() );
                writer.Flush();
                return ms.ToArray();
            }
            else if (outFormat.Equals( "XMLUNICODE" ))
            {
                MemoryStream ms = new MemoryStream();
                StreamWriter writer = new StreamWriter( ms, Encoding.Unicode );
                writer.Write( permSet.ToXml().ToString() );
                writer.Flush();

                ms.Position = 2;
                int countBytes = (int)ms.Length - 2;
                byte[] retval = new byte[countBytes];
                ms.Read( retval, 0, retval.Length );
                return retval;
            }
            else if (outFormat.Equals( "BINARY" ))
            {
                return permSet.EncodeUsingSerialization();
            }
            else
            {
                return null;
            }
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:63,代码来源:permissionset.cs

示例12: GetPermsFromSpecTree

        private static PermissionSet GetPermsFromSpecTree(SecurityElement et)
        {
            BCLDebug.Assert(et != null, "et != null");
            
            SecurityElement el, ec;
            
            if (et.Tag.Equals(s_sPermSpecTag) && et.Children != null)
                ec = (SecurityElement)et.Children[0];
            else if (et.Tag.Equals(s_str_PermissionSet))
                ec = et;
            else
                return null;
            
            if (ec == null)
                return null;

            // All of the next bit is a hack to support capability xml until we're
            // sure the compilers don't use it anymore.
            
            if (ec.Tag.Equals( s_sCapRefTag ))
                el = ec;
            else
                el = ec.SearchForChildByTag(s_sCapRefTag);
                
            if (el != null)
            {
            
                SecurityElement eGUID = el.SearchForChildByTag("GUID");
            
                if (eGUID != null)
                {
                    if (eGUID.Text.Equals("{9653abdf-7db7-11d2-b2eb-00a0c9b4694e}"))
                    {
                        return new PermissionSet( false );
                    }
                    else if (eGUID.Text.Equals("{9653abde-7db7-11d2-b2eb-00a0c9b4694e}"))
                    {
                        return new PermissionSet( true );
                    }
                    else
                    {
                        return new PermissionSet( false );
                    }
                }
                
                return new PermissionSet( false );
            }
            
            if (ec.Tag.Equals( s_str_PermissionSet ))
                el = ec;
            else
                el = ec.SearchForChildByTag(s_str_PermissionSet);
                
            if (el != null)
            {
                PermissionSet permSet = new PermissionSet(false);
                permSet.FromXml(el);
                return permSet;
            }
    
            return null;
        }
开发者ID:ArildF,项目名称:masters,代码行数:62,代码来源:permissionset.cs

示例13: DecodeFromASCIIFile

      DecodeFromASCIIFile (String fileName,
                           String format)
      {
          if (fileName == null)
              return null ;
  
          PermissionSet permSet = new PermissionSet (false) ;
          
          try {
              FileStream fs = new FileStream (fileName, 
                                          FileMode.Open, 
                                          FileAccess.Read) ;
  #if _DEBUG
              if (debug)
                  DEBUG_WRITE("DecodeFromASCIIFile: Format = " + format + " File = " + fileName);
  #endif
              if (format == null || format.Equals( "XMLASCII" ))
              {
                  permSet.FromXml( new Parser( new BinaryReader( fs, Encoding.ASCII ) ).GetTopElement() );
              }
              else if (format.Equals( "XMLUNICODE" ))
              {
                  permSet.FromXml( new Parser( new BinaryReader( fs ) ).GetTopElement() );
              }
              else
              {
                  return null;
              }
          }
          catch (Exception)
          {
          }
 
          return null;
      }
开发者ID:ArildF,项目名称:masters,代码行数:35,代码来源:permissionset.cs

示例14: ToSecurityObject

 internal object ToSecurityObject()
 {
     string str;
     if (((str = this.m_strTag) != null) && (str == "PermissionSet"))
     {
         PermissionSet set = new PermissionSet(PermissionState.None);
         set.FromXml(this);
         return set;
     }
     return this.ToPermission(false);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:SecurityElement.cs

示例15: RegenHandler

        internal static void RegenHandler( String[] args )
        {
            if (args[0].Equals( "__internal_usage__" ))
            {
                Console.WriteLine( "SecDBEdit -regen <file> [{binary|xml}]\n    Regenerate translations for database entries with missing binary values" );
                return;
            }
            
            if (args.Length < 2)
            {
                Error( "-regen", "Not enough arguments", -1 );
            }

            bool useBinary = true;

            if (args.Length > 2 && String.Compare( args[2], "xml", true, CultureInfo.InvariantCulture ) == 0)
            {
                useBinary = false;
            }
            
            ArrayList list = null;
            
            try
            {
                list = LoadDatabase( args[1] );
            }
            catch (Exception e)
            {
                Error( "-regen", "Failed during load - " + e.Message, -1 );
            }
            
            for (int i = 0; i < list.Count; ++i)
            {
                if ((((DatabaseEntry)list[i]).xml != null))
                {
                    try
                    {
                        Console.WriteLine( "Adding binary value for entry #" + (i+1) + ":" );
                        PermissionSet pset;
                        if (IsSecAttr( ((DatabaseEntry)list[i]).xml))
                        {
                            pset = SecAttrToPermSet( ((DatabaseEntry)list[i]).xml );
                            Console.WriteLine( pset.ToString() );
                        }
                        else
                        {
                            SecurityElement elem = GetElementFromUbyte( ((DatabaseEntry)list[i]).xml );
                            Console.WriteLine( elem.ToString() );
                            pset = new PermissionSet( PermissionState.None );
                            pset.FromXml( elem );
                        }

                        byte[] bArray;

                        // These should be functionally identical to
                        // PermissionSet.EncodeBinary() and
                        // PermissionSet.EncodeXml()

                        if (useBinary)
                        {
                            MemoryStream stream = new MemoryStream();
                            BinaryFormatter formatter = new BinaryFormatter();
                            formatter.Serialize( stream, pset );
                            bArray = stream.ToArray();
                        }
                        else
                        {
                            MemoryStream stream = new MemoryStream();
                            BinaryWriter writer = new BinaryWriter( stream, Encoding.Unicode );
                            writer.Write( pset.ToXml().ToString() );
                            writer.Flush();

                            stream.Position = 2;
                            int countBytes = (int)stream.Length - 2;
                            bArray = new byte[countBytes];
                            stream.Read( bArray, 0, bArray.Length );
                        }

                        ((DatabaseEntry)list[i]).binary = bArray;
                    }
                    catch (Exception)
                    {
                        Console.WriteLine( "Error converting entry");
                    }
                }
            }

            try
            {
                SaveDatabase( args[1], list );
            }
            catch (Exception)
            {
                Error( "-regen", "Error saving database", -1 );
            }
        }
开发者ID:ArildF,项目名称:masters,代码行数:96,代码来源:secdbedit.cs


注:本文中的System.Security.PermissionSet.FromXml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。