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


C# SecurityElement.AddChild方法代码示例

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


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

示例1: ToXml

 internal SecurityElement ToXml()
 {
     SecurityElement element2;
     SecurityElement element = new SecurityElement("System.Security.Policy.PermissionRequestEvidence");
     element.AddAttribute("version", "1");
     if (this.m_request != null)
     {
         element2 = new SecurityElement("Request");
         element2.AddChild(this.m_request.ToXml());
         element.AddChild(element2);
     }
     if (this.m_optional != null)
     {
         element2 = new SecurityElement("Optional");
         element2.AddChild(this.m_optional.ToXml());
         element.AddChild(element2);
     }
     if (this.m_denied != null)
     {
         element2 = new SecurityElement("Denied");
         element2.AddChild(this.m_denied.ToXml());
         element.AddChild(element2);
     }
     return element;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:PermissionRequestEvidence.cs

示例2: Constructor_SecurityElement_RSA

	public void Constructor_SecurityElement_RSA ()
	{
		SecurityElement se = new SecurityElement ("RSASignature");
		se.AddChild (new SecurityElement ("Key", "System.Security.Cryptography.RSACryptoServiceProvider"));
		se.AddChild (new SecurityElement ("Digest", "System.Security.Cryptography.SHA1CryptoServiceProvider"));
		se.AddChild (new SecurityElement ("Formatter", "System.Security.Cryptography.RSAPKCS1SignatureFormatter"));
		se.AddChild (new SecurityElement ("Deformatter", "System.Security.Cryptography.RSAPKCS1SignatureDeformatter"));

		SignatureDescription sig = new SignatureDescription (se);
		Assert.AreEqual ("System.Security.Cryptography.RSACryptoServiceProvider", sig.KeyAlgorithm);
		Assert.AreEqual ("System.Security.Cryptography.SHA1CryptoServiceProvider", sig.DigestAlgorithm);
		Assert.AreEqual ("System.Security.Cryptography.RSAPKCS1SignatureFormatter", sig.FormatterAlgorithm);
		Assert.AreEqual ("System.Security.Cryptography.RSAPKCS1SignatureDeformatter", sig.DeformatterAlgorithm);
	}
开发者ID:sushihangover,项目名称:playscript,代码行数:14,代码来源:SignatureDescriptionTest.cs

示例3: ToXml

 private SecurityElement ToXml()
 {
     SecurityElement root = new SecurityElement("System.Xml.XmlSecureResolver");
     root.AddAttribute("version", "1");
     root.AddChild(new SecurityElement("UncDirectory", _uncDir));
     return root;
 }
开发者ID:Corillian,项目名称:corefx,代码行数:7,代码来源:XmlSecureResolver.cs

示例4: ToXml

 internal SecurityElement ToXml()
 {
     SecurityElement element = new SecurityElement("System.Security.Policy.ApplicationDirectory");
     element.AddAttribute("version", "1");
     if (this.m_appDirectory != null)
     {
         element.AddChild(new SecurityElement("Directory", this.m_appDirectory.ToString()));
     }
     return element;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:ApplicationDirectory.cs

示例5: CreateElement

		private SecurityElement CreateElement ()
		{
			SecurityElement elem = new SecurityElement ("IPermission");
			elem.AddAttribute ("class", "System");
			elem.AddAttribute ("version", "1");
			
			SecurityElement child = new SecurityElement ("ConnectAccess");
			elem.AddChild (child);
			
			SecurityElement grandchild = new SecurityElement ("ENDPOINT", "some text");
			grandchild.AddAttribute ("transport", "All");
			grandchild.AddAttribute ("host", "localhost");
			grandchild.AddAttribute ("port", "8080");
			child.AddChild (grandchild);

			SecurityElement grandchild2 = new SecurityElement ("ENDPOINT");
			grandchild2.AddAttribute ("transport", "Tcp");
			grandchild2.AddAttribute ("host", "www.ximian.com");
			grandchild2.AddAttribute ("port", "All");
			child.AddChild (grandchild2);
			
			return elem;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:23,代码来源:SecurityElementTest.cs

示例6: FromXml_InvalidVersion

		public void FromXml_InvalidVersion ()
		{
			ApplicationTrust at = new ApplicationTrust ();
			SecurityElement se = at.ToXml ();

			SecurityElement w = new SecurityElement (se.Tag);
			w.AddAttribute ("version", "2");
			foreach (SecurityElement child in se.Children)
				w.AddChild (child);

			at.FromXml (w);
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:12,代码来源:ApplicationTrustTest.cs

示例7: CalculatePolicy

        internal PolicyStatement CalculatePolicy( String host, String scheme, String port )
        {
            SecurityElement webPerm = CreateWebPermission( host, scheme, port );

            SecurityElement root = new SecurityElement( "PolicyStatement" );
            SecurityElement permSet = new SecurityElement( "PermissionSet" );
            permSet.AddAttribute( "class", "System.Security.PermissionSet" );
            permSet.AddAttribute( "version", "1" );

            if (webPerm != null)
                permSet.AddChild( webPerm );

            root.AddChild( permSet );

            PolicyStatement policy = new PolicyStatement();
            policy.FromXml( root );
            return policy;
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:18,代码来源:netcodegroup.cs

示例8: FromXml_WithPermissionWithoutClass

		public void FromXml_WithPermissionWithoutClass ()
		{
			SecurityElement child = new SecurityElement ("IPermission");
			child.AddAttribute ("version", "1");

			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,代码行数:13,代码来源:PermissionSetTest.cs

示例9: FromXml_PermissionWithoutNamespace

		public void FromXml_PermissionWithoutNamespace ()
		{
			SecurityElement child = new SecurityElement ("IPermission");
			child.AddAttribute ("class", "EnvironmentPermission");
			child.AddAttribute ("version", "1");
			child.AddAttribute ("Read", "USERNAME");

			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

示例10: ProcessAssemblyXml

		static bool ProcessAssemblyXml (TextWriter tw, AssemblyDefinition ad)
		{
			SecurityElement se = new SecurityElement ("Assembly");
			se.AddAttribute ("Name", ad.Name.FullName);

			if (ad.SecurityDeclarations.Count > 0) {
				se.AddChild (AddSecurityXml (ad.SecurityDeclarations));
			}

			ArrayList tlist = new ArrayList ();
			ArrayList mlist = new ArrayList ();

			foreach (ModuleDefinition module in ad.Modules) {

				foreach (TypeDefinition type in module.Types) {

					SecurityElement klass = new SecurityElement ("Class");
					SecurityElement methods = new SecurityElement ("Methods");

					SecurityElement typelem = null;
					if (type.SecurityDeclarations.Count > 0) {
						typelem = AddSecurityXml (type.SecurityDeclarations);
					}

					if (mlist.Count > 0)
						mlist.Clear ();

					foreach (MethodDefinition method in type.Methods) {
						if (method.SecurityDeclarations.Count > 0) {
							SecurityElement meth = new SecurityElement ("Method");
							AddAttribute (meth, "Name", method.ToString ());
							meth.AddChild (AddSecurityXml (method.SecurityDeclarations));
							mlist.Add (meth);
						}
					}

					// sort methods
					mlist.Sort (Comparer);
					foreach (SecurityElement method in mlist) {
						methods.AddChild (method);
					}

					if ((typelem != null) || ((methods.Children != null) && (methods.Children.Count > 0))) {
						AddAttribute (klass, "Name", type.ToString ());
						if (typelem != null)
							klass.AddChild (typelem);
						if ((methods.Children != null) && (methods.Children.Count > 0))
							klass.AddChild (methods);
						tlist.Add (klass);
					}
				}

				// sort types
				tlist.Sort (Comparer);
				foreach (SecurityElement type in tlist) {
					se.AddChild (type);
				}
			}

			tw.WriteLine (se.ToString ());
			return true;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:62,代码来源:permview.cs

示例11: ToXml

 internal SecurityElement ToXml()
 {
     SecurityElement element = new SecurityElement("System.Security.Policy.Site");
     element.AddAttribute("version", "1");
     if (this.m_name != null)
     {
         element.AddChild(new SecurityElement("Name", this.m_name.ToString()));
     }
     return element;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:Site.cs

示例12: ToXml

		public virtual SecurityElement ToXml ()
		{
			SecurityElement se = new SecurityElement (tagName);
			se.AddAttribute ("class", GetType ().FullName);
			se.AddAttribute ("version", version.ToString ());
			if (state == PermissionState.Unrestricted)
				se.AddAttribute ("Unrestricted", "true");

			// required for permissions that do not implement IUnrestrictedPermission
			foreach (IPermission p in list) {
				se.AddChild (p.ToXml ());
			}
			return se;
		}
开发者ID:zxlin25,项目名称:mono,代码行数:14,代码来源:PermissionSet.cs

示例13: SafeChildAdd

 static internal void SafeChildAdd( SecurityElement parent, ISecurityElementFactory child, bool copy )
 {
     if (child == parent)
         return;
     if (child.GetTag().Equals( "IPermission" ) || child.GetTag().Equals( "Permission" ))
     {
         parent.AddChild( child );
     }
     else if (parent.Tag.Equals( child.GetTag() ))
     {
         Contract.Assert( child is SecurityElement, "SecurityElement expected" );
         SecurityElement elChild = (SecurityElement)child;
         Contract.Assert( elChild.InternalChildren != null,
             "Non-permission elements should have children" );
             
         for (int i = 0; i < elChild.InternalChildren.Count; ++i)
         {
             ISecurityElementFactory current = (ISecurityElementFactory)elChild.InternalChildren[i];
             Contract.Assert( !current.GetTag().Equals( parent.Tag ),
                 "Illegal to insert a like-typed element" );
             parent.AddChildNoDuplicates( current );
         }
     }
     else
     {
         parent.AddChild( (ISecurityElementFactory)(copy ? child.Copy() : child) );
     }
 }
开发者ID:l1183479157,项目名称:coreclr,代码行数:28,代码来源:PermissionSet.cs

示例14: InternalToXml

        internal SecurityElement InternalToXml()
        {
            SecurityElement elTrunk = new SecurityElement("PermissionSet");
            elTrunk.AddAttribute( "class", this.GetType().FullName);
            elTrunk.AddAttribute( "version", "1" );
        
            if (m_Unrestricted)
            {
                elTrunk.AddAttribute(s_str_Unrestricted, "true" );
            }
    
            if (this.m_permSet != null)
            {
                int maxIndex = this.m_permSet.GetMaxUsedIndex();

                for (int i = m_permSet.GetStartingIndex(); i <= maxIndex; ++i)
                {
                    Object obj = this.m_permSet.GetItem( i );
                    if (obj != null)
                    {
                        if (obj is IPermission)
                        {
                            if (!m_Unrestricted)
                                elTrunk.AddChild( ((IPermission)obj).ToXml() );
                        }
                        else
                        {
                            elTrunk.AddChild( (SecurityElement)obj );
                        }
                    }

                }
            }
            return elTrunk ;
        }
开发者ID:l1183479157,项目名称:coreclr,代码行数:35,代码来源:PermissionSet.cs

示例15: ToXml

        // internal helper which takes in the hardcoded permission name to avoid lookup at runtime
        // can be called from classes that derive from PermissionSet
        internal SecurityElement ToXml(String permName)
        {
            SecurityElement elTrunk = new SecurityElement("PermissionSet");
            elTrunk.AddAttribute( "class", permName );

            elTrunk.AddAttribute( "version", "1" );
        
            PermissionSetEnumeratorInternal enumerator = new PermissionSetEnumeratorInternal(this);
    
            if (m_Unrestricted)
            {
                elTrunk.AddAttribute(s_str_Unrestricted, "true" );
            }
   
            while (enumerator.MoveNext())
            {
                IPermission perm = (IPermission)enumerator.Current;

                if (!m_Unrestricted)
                    elTrunk.AddChild( perm.ToXml() );
            }
            return elTrunk;
        }
开发者ID:l1183479157,项目名称:coreclr,代码行数:25,代码来源:PermissionSet.cs


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