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


C# PolicyLevel.GetNamedPermissionSetInternal方法代码示例

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


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

示例1: FromXml

 internal void FromXml(SecurityDocument doc, int position, PolicyLevel level, bool allowInternalOnly)
 {
     if (doc == null)
     {
         throw new ArgumentNullException("doc");
     }
     if (!doc.GetTagForElement(position).Equals("PolicyStatement"))
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_InvalidXMLElement"), new object[] { "PolicyStatement", base.GetType().FullName }));
     }
     this.m_attributes = PolicyStatementAttribute.Nothing;
     string attributeForElement = doc.GetAttributeForElement(position, "Attributes");
     if (attributeForElement != null)
     {
         this.m_attributes = (PolicyStatementAttribute) Enum.Parse(typeof(PolicyStatementAttribute), attributeForElement);
     }
     lock (this)
     {
         this.m_permSet = null;
         if (level != null)
         {
             string name = doc.GetAttributeForElement(position, "PermissionSetName");
             if (name != null)
             {
                 this.m_permSet = level.GetNamedPermissionSetInternal(name);
                 if (this.m_permSet == null)
                 {
                     this.m_permSet = new System.Security.PermissionSet(PermissionState.None);
                 }
             }
         }
         if (this.m_permSet == null)
         {
             ArrayList childrenPositionForElement = doc.GetChildrenPositionForElement(position);
             int num = -1;
             for (int i = 0; i < childrenPositionForElement.Count; i++)
             {
                 if (doc.GetTagForElement((int) childrenPositionForElement[i]).Equals("PermissionSet"))
                 {
                     num = (int) childrenPositionForElement[i];
                 }
             }
             if (num == -1)
             {
                 throw new ArgumentException(Environment.GetResourceString("Argument_InvalidXML"));
             }
             string str3 = doc.GetAttributeForElement(num, "class");
             if ((str3 != null) && (str3.Equals("NamedPermissionSet") || str3.Equals("System.Security.NamedPermissionSet")))
             {
                 this.m_permSet = new NamedPermissionSet("DefaultName", PermissionState.None);
             }
             else
             {
                 this.m_permSet = new System.Security.PermissionSet(PermissionState.None);
             }
             this.m_permSet.FromXml(doc, num, allowInternalOnly);
         }
         if (this.m_permSet == null)
         {
             this.m_permSet = new System.Security.PermissionSet(PermissionState.None);
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:63,代码来源:PolicyStatement.cs

示例2: ToXml

 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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:57,代码来源:CodeGroup.cs

示例3: FromXml

        [System.Security.SecurityCritical]  // auto-generated
        internal void FromXml( SecurityDocument doc, int position, PolicyLevel level, bool allowInternalOnly )
        {
            if (doc == null)
                throw new ArgumentNullException( "doc" );
            Contract.EndContractBlock();

            if (!doc.GetTagForElement( position ).Equals( "PolicyStatement" ))
                throw new ArgumentException( String.Format( CultureInfo.CurrentCulture, Environment.GetResourceString( "Argument_InvalidXMLElement" ),  "PolicyStatement", this.GetType().FullName ) );
        
            m_attributes = (PolicyStatementAttribute) 0;

            String strAttributes = doc.GetAttributeForElement( position, "Attributes" );

            if (strAttributes != null)
                m_attributes = (PolicyStatementAttribute)Enum.Parse( typeof( PolicyStatementAttribute ), strAttributes );

            lock (this)
            {
                m_permSet = null;

                if (level != null)
                {
                    String permSetName = doc.GetAttributeForElement( position, "PermissionSetName" );
    
                    if (permSetName != null)
                    {
                        m_permSet = level.GetNamedPermissionSetInternal( permSetName );

                        if (m_permSet == null)
                            m_permSet = new PermissionSet( PermissionState.None );
                    }
                }


                if (m_permSet == null)
                {
                    // There is no provided level, it is not a named permission set, or
                    // the named permission set doesn't exist in the provided level,
                    // so just create the class through reflection and decode normally.
        
                    ArrayList childPositions = doc.GetChildrenPositionForElement( position );
                    int positionPermissionSet = -1;

                    for (int i = 0; i < childPositions.Count; ++i)
                    {
                        if (doc.GetTagForElement( (int)childPositions[i] ).Equals( "PermissionSet" ))
                        {
                            positionPermissionSet = (int)childPositions[i];
                        }
                    }

                    if (positionPermissionSet != -1)
                    {
                        String className = doc.GetAttributeForElement( positionPermissionSet, "class" );

                        if (className != null && (className.Equals( "NamedPermissionSet" ) ||
                                                  className.Equals( "System.Security.NamedPermissionSet" )))
                            m_permSet = new NamedPermissionSet( "DefaultName", PermissionState.None );
                        else
                            m_permSet = new PermissionSet( PermissionState.None );
                
                        m_permSet.FromXml( doc, positionPermissionSet, allowInternalOnly );
                    }
                    else
                    {
                        throw new ArgumentException( Environment.GetResourceString( "Argument_InvalidXML" ) );
                    }
                }

                if (m_permSet == null) 
                    m_permSet = new PermissionSet( PermissionState.None );
            }    
        }
开发者ID:uQr,项目名称:referencesource,代码行数:74,代码来源:policystatement.cs

示例4: ToXml

        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.
            BCLDebug.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;
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:71,代码来源:codegroup.cs

示例5: ToXml

        /// <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;
        }
开发者ID:ArildF,项目名称:masters,代码行数:68,代码来源:codegroup.cs


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