internal SecurityElement ToXml(PolicyLevel level, string policyClassName) { if ((this.m_membershipCondition == null) && (this.m_element != null)) { this.ParseMembershipCondition(); } if (this.m_children == null) { this.ParseChildren(); } if ((this.m_policy == null) && (this.m_element != null)) { this.ParsePolicy(); } SecurityElement element = new SecurityElement("CodeGroup"); XMLUtil.AddClassAttribute(element, base.GetType(), policyClassName); element.AddAttribute("version", "1"); element.AddChild(this.m_membershipCondition.ToXml(level)); if (this.m_policy != null) { PermissionSet permissionSetNoCopy = this.m_policy.GetPermissionSetNoCopy(); NamedPermissionSet set2 = permissionSetNoCopy as NamedPermissionSet; if (((set2 != null) && (level != null)) && (level.GetNamedPermissionSetInternal(set2.Name) != null)) { element.AddAttribute("PermissionSetName", set2.Name); } else if (!permissionSetNoCopy.IsEmpty()) { element.AddChild(permissionSetNoCopy.ToXml()); } if (this.m_policy.Attributes != PolicyStatementAttribute.Nothing) { element.AddAttribute("Attributes", XMLUtil.BitFieldEnumToString(typeof(PolicyStatementAttribute), this.m_policy.Attributes)); } } if (this.m_children.Count > 0) { lock (this) { IEnumerator enumerator = this.m_children.GetEnumerator(); while (enumerator.MoveNext()) { element.AddChild(((CodeGroup)enumerator.Current).ToXml(level)); } } } if (this.m_name != null) { element.AddAttribute("Name", SecurityElement.Escape(this.m_name)); } if (this.m_description != null) { element.AddAttribute("Description", SecurityElement.Escape(this.m_description)); } this.CreateXml(element, level); return(element); }
//------------------------------------------------------ // // XML // //------------------------------------------------------ public override SecurityElement ToXml() { SecurityElement esd = CodeAccessPermission.CreatePermissionElement( this, this.GetType().FullName ); if(IsUnrestricted()) esd.AddAttribute( "Unrestricted", "true" ); else esd.AddAttribute( "Resources", XMLUtil.BitFieldEnumToString( typeof( HostProtectionResource ), Resources ) ); return esd; }
internal SecurityElement ToXml(PolicyLevel level, string policyClassName) { if (this.m_membershipCondition == null && this.m_element != null) { this.ParseMembershipCondition(); } if (this.m_children == null) { this.ParseChildren(); } if (this.m_policy == null && this.m_element != null) { this.ParsePolicy(); } SecurityElement element = new SecurityElement("CodeGroup"); XMLUtil.AddClassAttribute(element, this.GetType(), policyClassName); element.AddAttribute("version", "1"); element.AddChild(this.m_membershipCondition.ToXml(level)); if (this.m_policy != null) { PermissionSet permissionSetNoCopy = this.m_policy.GetPermissionSetNoCopy(); NamedPermissionSet namedPermissionSet = permissionSetNoCopy as NamedPermissionSet; if (namedPermissionSet != null && level != null && level.GetNamedPermissionSetInternal(namedPermissionSet.Name) != null) { element.AddAttribute("PermissionSetName", namedPermissionSet.Name); } else if (!permissionSetNoCopy.IsEmpty()) { element.AddChild(permissionSetNoCopy.ToXml()); } if (this.m_policy.Attributes != PolicyStatementAttribute.Nothing) { element.AddAttribute("Attributes", XMLUtil.BitFieldEnumToString(typeof(PolicyStatementAttribute), (object)this.m_policy.Attributes)); } } if (this.m_children.Count > 0) { lock (this) { foreach (CodeGroup item_0 in (IEnumerable)this.m_children) { element.AddChild(item_0.ToXml(level)); } } } if (this.m_name != null) { element.AddAttribute("Name", SecurityElement.Escape(this.m_name)); } if (this.m_description != null) { element.AddAttribute("Description", SecurityElement.Escape(this.m_description)); } this.CreateXml(element, level); return(element); }
public override SecurityElement ToXml() { SecurityElement element = CodeAccessPermission.CreatePermissionElement(this, base.GetType().FullName); if (this.IsUnrestricted()) { element.AddAttribute("Unrestricted", "true"); return(element); } element.AddAttribute("Resources", XMLUtil.BitFieldEnumToString(typeof(HostProtectionResource), this.Resources)); return(element); }
internal SecurityElement ToXml(PolicyLevel level, bool useInternal) { SecurityElement e = new SecurityElement("PolicyStatement"); e.AddAttribute("version", "1"); if (m_attributes != PolicyStatementAttribute.Nothing) { e.AddAttribute("Attributes", XMLUtil.BitFieldEnumToString(typeof(PolicyStatementAttribute), m_attributes)); } lock (this) { if (m_permSet != null) { if (m_permSet is NamedPermissionSet) { // If the named permission set exists in the parent level of this // policy struct, then just save the name of the permission set. // Otherwise, serialize it like normal. NamedPermissionSet namedPermSet = (NamedPermissionSet)m_permSet; if (level != null && level.GetNamedPermissionSet(namedPermSet.Name) != null) { e.AddAttribute("PermissionSetName", namedPermSet.Name); } else { if (useInternal) { e.AddChild(namedPermSet.InternalToXml()); } else { e.AddChild(namedPermSet.ToXml()); } } } else { if (useInternal) { e.AddChild(m_permSet.InternalToXml()); } else { e.AddChild(m_permSet.ToXml()); } } } } return(e); }
public override SecurityElement ToXml() { SecurityElement element = CodeAccessPermission.CreatePermissionElement(this, "System.Security.Permissions.SecurityPermission"); if (!this.IsUnrestricted()) { element.AddAttribute("Flags", XMLUtil.BitFieldEnumToString(typeof(SecurityPermissionFlag), this.m_flags)); return(element); } element.AddAttribute("Unrestricted", "true"); return(element); }
/// <include file='doc\SecurityPermission.uex' path='docs/doc[@for="SecurityPermission.ToXml"]/*' /> public override SecurityElement ToXml() { SecurityElement esd = CodeAccessPermission.CreatePermissionElement(this); if (!IsUnrestricted()) { esd.AddAttribute("Flags", XMLUtil.BitFieldEnumToString(typeof(SecurityPermissionFlag), m_flags)); } else { esd.AddAttribute("Unrestricted", "true"); } return(esd); }
/// <summary>创建权限及其当前状态的 XML 编码。</summary> /// <returns>权限的 XML 编码,包括任何状态信息。</returns> public override SecurityElement ToXml() { SecurityElement permissionElement = CodeAccessPermission.CreatePermissionElement((IPermission)this, "System.Security.Permissions.ReflectionPermission"); if (!this.IsUnrestricted()) { permissionElement.AddAttribute("Flags", XMLUtil.BitFieldEnumToString(typeof(ReflectionPermissionFlag), (object)this.m_flags)); } else { permissionElement.AddAttribute("Unrestricted", "true"); } return(permissionElement); }
// Token: 0x06002A0B RID: 10763 RVA: 0x0009C32C File Offset: 0x0009A52C internal SecurityElement ToXml(PolicyLevel level, bool useInternal) { SecurityElement securityElement = new SecurityElement("PolicyStatement"); securityElement.AddAttribute("version", "1"); if (this.m_attributes != PolicyStatementAttribute.Nothing) { securityElement.AddAttribute("Attributes", XMLUtil.BitFieldEnumToString(typeof(PolicyStatementAttribute), this.m_attributes)); } lock (this) { if (this.m_permSet != null) { if (this.m_permSet is NamedPermissionSet) { NamedPermissionSet namedPermissionSet = (NamedPermissionSet)this.m_permSet; if (level != null && level.GetNamedPermissionSet(namedPermissionSet.Name) != null) { securityElement.AddAttribute("PermissionSetName", namedPermissionSet.Name); } else if (useInternal) { securityElement.AddChild(namedPermissionSet.InternalToXml()); } else { securityElement.AddChild(namedPermissionSet.ToXml()); } } else if (useInternal) { securityElement.AddChild(this.m_permSet.InternalToXml()); } else { securityElement.AddChild(this.m_permSet.ToXml()); } } } return(securityElement); }
protected override void CreateXml(SecurityElement element, PolicyLevel level) { element.AddAttribute("Access", XMLUtil.BitFieldEnumToString(typeof(FileIOPermissionAccess), m_access)); }
[System.Security.SecurityCritical] // auto-generated internal SecurityElement ToXml(PolicyLevel level, String policyClassName) { if (m_membershipCondition == null && m_element != null) { ParseMembershipCondition(); } if (m_children == null) { ParseChildren(); } if (m_policy == null && m_element != null) { ParsePolicy(); } SecurityElement e = new SecurityElement("CodeGroup"); System.Security.Util.XMLUtil.AddClassAttribute(e, this.GetType(), policyClassName); // 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(policyClassName), "Incorrect class name passed in! Was: " + policyClassName + " Should be " + this.GetType().FullName); e.AddAttribute("version", "1"); e.AddChild(m_membershipCondition.ToXml(level)); // Grab the inerts of the policy statement's xml and just stick it // into the code group xml directly. We do this to hide the policy statement from // users in the config file. if (m_policy != null) { PermissionSet permSet = m_policy.GetPermissionSetNoCopy(); NamedPermissionSet namedPermSet = permSet as NamedPermissionSet; if (namedPermSet != null && level != null && level.GetNamedPermissionSetInternal(namedPermSet.Name) != null) { e.AddAttribute("PermissionSetName", namedPermSet.Name); } else { if (!permSet.IsEmpty()) { e.AddChild(permSet.ToXml()); } } if (m_policy.Attributes != PolicyStatementAttribute.Nothing) { e.AddAttribute("Attributes", XMLUtil.BitFieldEnumToString(typeof(PolicyStatementAttribute), m_policy.Attributes)); } } if (m_children.Count > 0) { lock (this) { IEnumerator enumerator = m_children.GetEnumerator(); while (enumerator.MoveNext()) { e.AddChild(((CodeGroup)enumerator.Current).ToXml(level)); } } } if (m_name != null) { e.AddAttribute("Name", SecurityElement.Escape(m_name)); } if (m_description != null) { e.AddAttribute("Description", SecurityElement.Escape(m_description)); } CreateXml(e, level); return(e); }
/// <include file='doc\CodeGroup.uex' path='docs/doc[@for="CodeGroup.ToXml1"]/*' /> public SecurityElement ToXml(PolicyLevel level) { if (m_membershipCondition == null && m_element != null) { ParseMembershipCondition(); } if (m_children == null) { ParseChildren(); } if (m_policy == null && m_element != null) { ParsePolicy(); } SecurityElement e = new SecurityElement("CodeGroup"); System.Security.Util.XMLUtil.AddClassAttribute(e, this.GetType()); e.AddAttribute("version", "1"); e.AddChild(m_membershipCondition.ToXml(level)); // Grab the inerts of the policy statement's xml and just stick it // into the code group xml directly. We do this to hide the policy statement from // users in the config file. if (m_policy != null) { PermissionSet permSet = m_policy.GetPermissionSetNoCopy(); NamedPermissionSet namedPermSet = permSet as NamedPermissionSet; if (namedPermSet != null && level != null && level.GetNamedPermissionSetInternal(namedPermSet.Name) != null) { e.AddAttribute("PermissionSetName", namedPermSet.Name); } else { if (!permSet.IsEmpty()) { e.AddChild(permSet.ToXml()); } } if (m_policy.Attributes != PolicyStatementAttribute.Nothing) { e.AddAttribute("Attributes", XMLUtil.BitFieldEnumToString(typeof(PolicyStatementAttribute), m_policy.Attributes)); } } if (m_children.Count > 0) { lock (this) { IEnumerator enumerator = m_children.GetEnumerator(); while (enumerator.MoveNext()) { e.AddChild(((CodeGroup)enumerator.Current).ToXml(level)); } } } if (m_name != null) { e.AddAttribute("Name", SecurityElement.Escape(m_name)); } if (m_description != null) { e.AddAttribute("Description", SecurityElement.Escape(m_description)); } CreateXml(e, level); return(e); }