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


C# SecurityElement.AddAttribute方法代码示例

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


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

示例1: Element

		// snippet moved from FileIOPermission (nickd) to be reused in all derived classes
		internal static SecurityElement Element (Type type, int version) 
		{
			SecurityElement se = new SecurityElement ("IPermission");
			se.AddAttribute ("class", type.FullName + ", " + type.Assembly.ToString ().Replace ('\"', '\''));
			se.AddAttribute ("version", version.ToString ());
			return se;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:8,代码来源:PermissionHelper.cs

示例2: ToXml

  } //Union()

  public override SecurityElement ToXml() 
  {
    SecurityElement s = new SecurityElement("IPermission");
    s.AddAttribute("class","myperm, myperm, Version=1.0.1.0, Culture=neutral, PublicKeyToken=0e8dcc8628396732");
    s.AddAttribute("version", "1");
    s.AddAttribute("Unrestricted", "true");
    return s;
  } //ToXml()
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:10,代码来源:myperm.cs

示例3: FromXmlWrongVersion

 public void FromXmlWrongVersion()
 {
     PrincipalPermission p = new PrincipalPermission(PermissionState.None);
     SecurityElement se = p.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");
     Assert.Throws<ArgumentException>(() => p.FromXml(se2));
 }
开发者ID:dotnet,项目名称:corefx,代码行数:10,代码来源:PrincipalPermissionTests.cs

示例4: ToString

	// Convert this object into a string.
	public override String ToString()
			{
				SecurityElement element = new SecurityElement
					("System.Security.Policy.PermissionRequestEvidence");
				SecurityElement child;
				element.AddAttribute("version", "1");
				if(request != null)
				{
					child = new SecurityElement("Request");
					child.AddChild(request.ToXml());
					element.AddChild(child);
				}
				if(optional != null)
				{
					child = new SecurityElement("Optional");
					child.AddChild(optional.ToXml());
					element.AddChild(child);
				}
				if(denied != null)
				{
					child = new SecurityElement("Denied");
					child.AddChild(denied.ToXml());
					element.AddChild(child);
				}
				return element.ToString();
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:27,代码来源:PermissionRequestEvidence.cs

示例5: ToXml

 public SecurityElement ToXml( PolicyLevel level )
 {
     SecurityElement root = new SecurityElement( "IMembershipCondition" );
     System.Security.Util.XMLUtil.AddClassAttribute( root, this.GetType(), this.GetType().FullName );
     root.AddAttribute( "version", "1" );
     return root;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:7,代码来源:GACMembershipCondition.cs

示例6: ToXml

        internal SecurityElement ToXml()
        {
            SecurityElement root = new SecurityElement("Identity");

            if (Authenticated)
            {
                root.AddAttribute("Authenticated", "true");
            }
            if (ID != null)
            {
                root.AddAttribute("ID", SecurityElement.Escape(ID));
            }
            if (Role != null)
            {
                root.AddAttribute("Role", SecurityElement.Escape(Role));
            }

            return root;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:19,代码来源:IDRole.cs

示例7: ToString

		public override string ToString ()
		{
			SecurityElement se = new SecurityElement ("System.Security.Policy.Publisher");
			se.AddAttribute ("version", "1");
			SecurityElement cert = new SecurityElement ("X509v3Certificate");
			string data = m_cert.GetRawCertDataString ();
			if (data != null)
				cert.Text = data;
			se.AddChild (cert);
			return se.ToString ();
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:11,代码来源:Publisher.cs

示例8: ToXml

        internal SecurityElement ToXml()
        {
            SecurityElement root = new SecurityElement( "System.Security.Policy.ApplicationDirectory" );
            // If you hit this assert then most likely you are trying to change the name of this class. 
            // This is ok as long as you change the hard coded string above and change the assert below.
            Contract.Assert( this.GetType().FullName.Equals( "System.Security.Policy.ApplicationDirectory" ), "Class name changed!" );

            root.AddAttribute( "version", "1" );
            
            if (m_appDirectory != null)
                root.AddChild( new SecurityElement( "Directory", m_appDirectory.ToString() ) );
            
            return root;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:14,代码来源:applicationdirectory.cs

示例9: FromXml

        public void FromXml()
        {
            PrincipalPermission p = new PrincipalPermission(PermissionState.None);
            SecurityElement se = p.ToXml();
            Assert.NotNull(se);

            PrincipalPermission p2 = (PrincipalPermission)p.Copy();
            p2.FromXml(se);
            Assert.Equal(p.ToString(), p2.ToString());

            string className = (string)se.Attributes["class"];
            string version = (string)se.Attributes["version"];

            SecurityElement se2 = new SecurityElement(se.Tag);
            se2.AddAttribute("class", className);
            se2.AddAttribute("version", version);
            p2.FromXml(se2);

            SecurityElement sec = new SecurityElement("Identity");
            sec.AddAttribute("Authenticated", "true");
            se2.AddChild(sec);
            p2.FromXml(se2);
            Assert.True(p2.IsUnrestricted());
        }
开发者ID:dotnet,项目名称:corefx,代码行数:24,代码来源:PrincipalPermissionTests.cs

示例10: ToString

		public override string ToString () 
		{
			SecurityElement se = new SecurityElement ("System.Security.Policy.PermissionRequestEvidence");
			se.AddAttribute ("version", "1");

			if (requested != null) {
				SecurityElement requestElement = new SecurityElement ("Request");
				requestElement.AddChild (requested.ToXml ());
				se.AddChild (requestElement);
			}
			if (optional != null) {
				SecurityElement optionalElement = new SecurityElement ("Optional");
				optionalElement.AddChild (optional.ToXml ());
				se.AddChild (optionalElement);
			}
			if (denied != null) {
				SecurityElement deniedElement = new SecurityElement ("Denied");
				deniedElement.AddChild (denied.ToXml ());
				se.AddChild (deniedElement);
			}
			return se.ToString ();
		}
开发者ID:runefs,项目名称:Marvin,代码行数:22,代码来源:PermissionRequestEvidence.cs

示例11: ToXml

        internal SecurityElement ToXml()
        {
            SecurityElement elem = new SecurityElement( "System.Security.Policy.Zone" );
            // If you hit this assert then most likely you are trying to change the name of this class. 
            // This is ok as long as you change the hard coded string above and change the assert below.
            Contract.Assert( this.GetType().FullName.Equals( "System.Security.Policy.Zone" ), "Class name changed!" );

            elem.AddAttribute( "version", "1" );
            if (SecurityZone != SecurityZone.NoZone)
                elem.AddChild( new SecurityElement( "Zone", s_names[(int)SecurityZone] ) );
            else
                elem.AddChild( new SecurityElement( "Zone", s_names[s_names.Length-1] ) );
            return elem;
        }
开发者ID:ChuangYang,项目名称:coreclr,代码行数:14,代码来源:Zone.cs

示例12: ObjectToXml

        private static SecurityElement ObjectToXml (string tag, Object obj) { 
            BCLDebug.Assert(obj != null, "You need to pass in an object"); 

            ISecurityEncodable encodableObj = obj as ISecurityEncodable; 

            SecurityElement elObject;
            if (encodableObj != null) {
                elObject = encodableObj.ToXml(); 
                if (!elObject.Tag.Equals(tag))
                    throw new ArgumentException(Environment.GetResourceString("Argument_InvalidXML")); 
            } 

            MemoryStream stream = new MemoryStream(); 
            BinaryFormatter formatter = new BinaryFormatter();
            formatter.Serialize(stream, obj);
            byte[] array = stream.ToArray();
 
            elObject = new SecurityElement(tag);
            elObject.AddAttribute("Data", Hex.EncodeHexString(array)); 
            return elObject; 
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:21,代码来源:ApplicationTrust.cs

示例13: ToXml

        public SecurityElement ToXml () {
            SecurityElement elRoot = new SecurityElement("ApplicationTrust");
            elRoot.AddAttribute("version", "1");
 
#if FEATURE_CLICKONCE
            if (m_appId != null) { 
                elRoot.AddAttribute("FullName", SecurityElement.Escape(m_appId.FullName)); 
            }
            if (m_appTrustedToRun) { 
                elRoot.AddAttribute("TrustedToRun", "true");
            }
            if (m_persist) {
                elRoot.AddAttribute("Persist", "true"); 
            }
#endif // FEATURE_CLICKONCE 
 
            if (m_psDefaultGrant != null) {
                SecurityElement elDefaultGrant = new SecurityElement("DefaultGrant"); 
                elDefaultGrant.AddChild(m_psDefaultGrant.ToXml());
                elRoot.AddChild(elDefaultGrant);
            }
            if (m_fullTrustAssemblies.Count > 0) { 
                SecurityElement elFullTrustAssemblies = new SecurityElement("FullTrustAssemblies");
                foreach (StrongName fullTrustAssembly in m_fullTrustAssemblies) { 
                    elFullTrustAssemblies.AddChild(fullTrustAssembly.ToXml()); 
                }
                elRoot.AddChild(elFullTrustAssemblies); 
            }

#if FEATURE_CLICKONCE
            if (ExtraInfo != null) { 
                elRoot.AddChild(ObjectToXml("ExtraInfo", ExtraInfo));
            } 
#endif // FEATURE_CLICKONCE 
            return elRoot;
        } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:36,代码来源:ApplicationTrust.cs

示例14: ToXml

        public SecurityElement ToXml( PolicyLevel level )
        {
            if (m_site == null && m_element != null)
                ParseSite();
                        
            SecurityElement root = new SecurityElement( "IMembershipCondition" );
            System.Security.Util.XMLUtil.AddClassAttribute( root, this.GetType(), "System.Security.Policy.SiteMembershipCondition" );
            // If you hit this assert then most likely you are trying to change the name of this class. 
            // This is ok as long as you change the hard coded string above and change the assert below.
            Contract.Assert( this.GetType().FullName.Equals( "System.Security.Policy.SiteMembershipCondition" ), "Class name changed!" );

            root.AddAttribute( "version", "1" );
            
            if (m_site != null)
                root.AddAttribute( "Site", m_site.ToString() );
            
            return root;
        }
开发者ID:uQr,项目名称:referencesource,代码行数:18,代码来源:sitemembershipcondition.cs

示例15: CreateDefaultApplicationTrustManagerElement

 private static SecurityElement CreateDefaultApplicationTrustManagerElement() {
     SecurityElement elTrustManager = new SecurityElement("IApplicationTrustManager");
     elTrustManager.AddAttribute("class",
                                 "System.Security.Policy.TrustManager, System.Windows.Forms, Version=" + System.Reflection.Assembly.GetExecutingAssembly().GetVersion() + ", Culture=neutral, PublicKeyToken=" + AssemblyRef.EcmaPublicKeyToken);
     elTrustManager.AddAttribute("version", "1");
     return elTrustManager;
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:7,代码来源:applicationsecuritymanager.cs


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