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);
        }
示例#2
0
        // 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);
        }