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


C# PermissionSet.CreatePermission方法代码示例

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


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

示例1: InplaceIntersect


//.........这里部分代码省略.........
                            newElemUU.AddAttribute( "class", otherElem.Attribute( "class" ) );
                            SafeChildAdd( newElemUU, otherElem, true );
                            otherElem = newElemUU;
                            copyOther = false;
                        }
                        
                        SecurityElement newElem = new SecurityElement( s_str_PermissionIntersection );
                        newElem.AddAttribute( "class", thisElem.Attribute( "class" ) );
                        
                        SafeChildAdd( newElem, thisElem, false );
                        SafeChildAdd( newElem, otherElem, copyOther );
                        this.m_permSet.SetItem( i, newElem );
                    }
                }
                else
#endif // FEATURE_CAS_POLICY
                if (thisObj == null)
                {
                    // There is no object in <this>, so intersection is empty except for IUnrestrictedPermissions
                    if (this.IsUnrestricted())
                    {
#if FEATURE_CAS_POLICY
                        if (otherElem != null)
                        {
                            SecurityElement newElem = new SecurityElement( s_str_PermissionUnrestrictedIntersection );
                            newElem.AddAttribute( "class", otherElem.Attribute( "class" ) );
                            SafeChildAdd( newElem, otherElem, true );
                            this.m_permSet.SetItem( i, newElem );
                            Contract.Assert( PermissionToken.s_tokenSet.GetItem( i ) != null, "PermissionToken should already be assigned" );
                        }
                        else
#endif // FEATURE_CAS_POLICY
                        {
                            PermissionToken token = (PermissionToken)PermissionToken.s_tokenSet.GetItem( i );
                            if ((token.m_type & PermissionTokenType.IUnrestricted) != 0)
                            {
                                this.m_permSet.SetItem( i, otherPerm.Copy() );
                                Contract.Assert( PermissionToken.s_tokenSet.GetItem( i ) != null, "PermissionToken should already be assigned" );
                            }
                        }
                    }
                }
                else if (otherObj == null)
                {
                    if (other.IsUnrestricted())
                    {
#if FEATURE_CAS_POLICY
                        if (thisElem != null)
                        {
                            SecurityElement newElem = new SecurityElement( s_str_PermissionUnrestrictedIntersection );
                            newElem.AddAttribute( "class", thisElem.Attribute( "class" ) );
                            SafeChildAdd( newElem, thisElem, false );
                            this.m_permSet.SetItem( i, newElem );
                        }
                        else
#endif // FEATURE_CAS_POLICY
                        {
                            PermissionToken token = (PermissionToken)PermissionToken.s_tokenSet.GetItem( i );
                            if ((token.m_type & PermissionTokenType.IUnrestricted) == 0)
                                this.m_permSet.SetItem( i, null );
                        }
                    }
                    else
                    {
                        this.m_permSet.SetItem( i, null );
                    }
                }
                else
                {
#if FEATURE_CAS_POLICY
                    if (thisElem != null)
                        thisPerm = this.CreatePermission(thisElem, i);
                    if (otherElem != null)
                        otherPerm = other.CreatePermission(otherElem, i);
#endif // FEATURE_CAS_POLICY

                    try
                    {
                        IPermission intersectPerm;
                        if (thisPerm == null)
                            intersectPerm = otherPerm;
                        else if(otherPerm == null)
                            intersectPerm = thisPerm;
                        else
                            intersectPerm = thisPerm.Intersect( otherPerm );
                        this.m_permSet.SetItem( i, intersectPerm );
                    }
                    catch (Exception e)
                    {
                        if (savedException == null)
                            savedException = e;
                    }
                }
            }

            this.m_Unrestricted = this.m_Unrestricted && other.m_Unrestricted;

            if (savedException != null)
                throw savedException;
        }
开发者ID:l1183479157,项目名称:coreclr,代码行数:101,代码来源:PermissionSet.cs

示例2: Intersect


//.........这里部分代码省略.........
                        SecurityElement newElemUU = new SecurityElement( s_str_PermissionUnrestrictedUnion );
                        newElemUU.AddAttribute( "class", thisElem.Attribute( "class" ) );
                        SafeChildAdd( newElemUU, thisElem, true );
                        copyThis = false;
                        thisElem = newElemUU;
                    }
                    if (other.IsUnrestricted())
                    {
                        SecurityElement newElemUU = new SecurityElement( s_str_PermissionUnrestrictedUnion );
                        newElemUU.AddAttribute( "class", otherElem.Attribute( "class" ) );
                        SafeChildAdd( newElemUU, otherElem, true );
                        copyOther = false;
                        otherElem = newElemUU;
                    }

                    SafeChildAdd( newElem, otherElem, copyOther );
                    SafeChildAdd( newElem, thisElem, copyThis );
                    pset.m_permSet.SetItem( i, newElem );
                }
                else
#endif // FEATURE_CAS_POLICY
                if (thisObj == null)
                {
                    if (this.m_Unrestricted)
                    {
#if FEATURE_CAS_POLICY
                        if (otherElem != null)
                        {
                            SecurityElement newElem = new SecurityElement( s_str_PermissionUnrestrictedIntersection );
                            newElem.AddAttribute( "class", otherElem.Attribute( "class" ) );
                            SafeChildAdd( newElem, otherElem, true );
                            pset.m_permSet.SetItem( i, newElem );
                            Contract.Assert( PermissionToken.s_tokenSet.GetItem( i ) != null, "PermissionToken should already be assigned" );
                        }
                        else
#endif // FEATURE_CAS_POLICY
                        if (otherPerm != null)
                        {
                            PermissionToken token = (PermissionToken)PermissionToken.s_tokenSet.GetItem( i );
                            if ((token.m_type & PermissionTokenType.IUnrestricted) != 0)
                            {
                                pset.m_permSet.SetItem( i, otherPerm.Copy() );
                                Contract.Assert( PermissionToken.s_tokenSet.GetItem( i ) != null, "PermissionToken should already be assigned" );
                            }
                        }
                    }
                }
                else if (otherObj == null)
                {
                    if (other.m_Unrestricted)
                    {
#if FEATURE_CAS_POLICY
                        if (thisElem != null)
                        {
                            SecurityElement newElem = new SecurityElement( s_str_PermissionUnrestrictedIntersection );
                            newElem.AddAttribute( "class", thisElem.Attribute( "class" ) );
                            SafeChildAdd( newElem, thisElem, true );
                            pset.m_permSet.SetItem( i, newElem );
                            Contract.Assert( PermissionToken.s_tokenSet.GetItem( i ) != null, "PermissionToken should already be assigned" );
                        }
                        else
#endif // FEATURE_CAS_POLICY
                        if (thisPerm != null)
                        {
                            PermissionToken token = (PermissionToken)PermissionToken.s_tokenSet.GetItem( i );
                            if ((token.m_type & PermissionTokenType.IUnrestricted) != 0)
                            {
                                pset.m_permSet.SetItem( i, thisPerm.Copy() );
                                Contract.Assert( PermissionToken.s_tokenSet.GetItem( i ) != null, "PermissionToken should already be assigned" );
                            }
                        }
                    }
                }
                else
                {
#if FEATURE_CAS_POLICY
                    if (thisElem != null)
                        thisPerm = this.CreatePermission(thisElem, i);
                    if (otherElem != null)
                        otherPerm = other.CreatePermission(otherElem, i);
#endif // FEATURE_CAS_POLICY

                    IPermission intersectPerm;
                    if (thisPerm == null)
                        intersectPerm = otherPerm;
                    else if(otherPerm == null)
                        intersectPerm = thisPerm;
                    else
                        intersectPerm = thisPerm.Intersect( otherPerm );
                    pset.m_permSet.SetItem( i, intersectPerm );
                    Contract.Assert( intersectPerm == null || PermissionToken.s_tokenSet.GetItem( i ) != null, "PermissionToken should already be assigned" );
                }
            }

            pset.m_Unrestricted = this.m_Unrestricted && other.m_Unrestricted;
            if (pset.FastIsEmpty())
                return null;
            else
                return pset;
        }
开发者ID:l1183479157,项目名称:coreclr,代码行数:101,代码来源:PermissionSet.cs

示例3: InplaceUnion


//.........这里部分代码省略.........
                maxMax = other.m_permSet.GetMaxUsedIndex();                        
                this.CheckSet();
            }
            // Save exceptions until the end
            Exception savedException = null;

            for (int i = 0; i <= maxMax; ++i)
            {
                Object thisObj = this.m_permSet.GetItem( i );
                IPermission thisPerm = thisObj as IPermission;
#if FEATURE_CAS_POLICY
                ISecurityElementFactory thisElem = thisObj as ISecurityElementFactory;
#endif // FEATURE_CAS_POLICY

                Object otherObj = other.m_permSet.GetItem( i );
                IPermission otherPerm = otherObj as IPermission;
#if FEATURE_CAS_POLICY
                ISecurityElementFactory otherElem = otherObj as ISecurityElementFactory;
#endif // FEATURE_CAS_POLICY

                if (thisObj == null && otherObj == null)
                    continue;

#if FEATURE_CAS_POLICY
                if (thisElem != null && otherElem != null)
                {
                    if (thisElem.GetTag().Equals( s_str_PermissionUnion ) ||
                        thisElem.GetTag().Equals( s_str_PermissionUnrestrictedUnion ))
                    {
                        Contract.Assert( thisElem is SecurityElement, "SecurityElement expected" );
                        SafeChildAdd( (SecurityElement)thisElem, otherElem, true );
                    }
                    else
                    {
                        SecurityElement newElem;
                        if (this.IsUnrestricted() || other.IsUnrestricted())
                            newElem = new SecurityElement( s_str_PermissionUnrestrictedUnion );
                        else
                            newElem = new SecurityElement( s_str_PermissionUnion );
                        newElem.AddAttribute( "class", thisElem.Attribute( "class" ) );
                        SafeChildAdd( newElem, thisElem, false );
                        SafeChildAdd( newElem, otherElem, true );
                        this.m_permSet.SetItem( i, newElem );
                    }
                }
                else
#endif // FEATURE_CAS_POLICY
                if (thisObj == null)
                {
#if FEATURE_CAS_POLICY
                    if (otherElem != null)
                    {
                        this.m_permSet.SetItem( i, otherElem.Copy() );
                    }
                    else
#endif // FEATURE_CAS_POLICY
                    if (otherPerm != null)
                    {
                        PermissionToken token = (PermissionToken)PermissionToken.s_tokenSet.GetItem( i );
                        if (((token.m_type & PermissionTokenType.IUnrestricted) == 0) || !this.m_Unrestricted)
                        {
                            this.m_permSet.SetItem( i, otherPerm.Copy() );
                        }
                    }
                }
                else if (otherObj == null)
                {
                    continue;
                }
                else
                {
#if FEATURE_CAS_POLICY
                    if (thisElem != null)
                        thisPerm = this.CreatePermission(thisElem, i);
                    if (otherElem != null)
                        otherPerm = other.CreatePermission(otherElem, i);
#endif // FEATURE_CAS_POLICY

                    try
                    {
                        IPermission unionPerm;
                        if(thisPerm == null)
                            unionPerm = otherPerm;
                        else if(otherPerm == null)
                            unionPerm = thisPerm;
                        else
                            unionPerm = thisPerm.Union( otherPerm );
                        this.m_permSet.SetItem( i, unionPerm );
                    }
                    catch (Exception e)
                    {
                        if (savedException == null)
                            savedException = e;
                    }
                }
            }
            
            if (savedException != null)
                throw savedException;
        }
开发者ID:l1183479157,项目名称:coreclr,代码行数:101,代码来源:PermissionSet.cs

示例4: Union


//.........这里部分代码省略.........
            other.CheckSet();
            maxMax = this.m_permSet.GetMaxUsedIndex() > other.m_permSet.GetMaxUsedIndex() ? this.m_permSet.GetMaxUsedIndex() : other.m_permSet.GetMaxUsedIndex();
            pset.m_permSet = new TokenBasedSet();



            for (int i = 0; i <= maxMax; ++i)
            {
                Object thisObj = this.m_permSet.GetItem( i );
                IPermission thisPerm = thisObj as IPermission;
#if FEATURE_CAS_POLICY
                ISecurityElementFactory thisElem = thisObj as ISecurityElementFactory;
#endif // FEATURE_CAS_POLICY

                Object otherObj = other.m_permSet.GetItem( i );
                IPermission otherPerm = otherObj as IPermission;
#if FEATURE_CAS_POLICY
                ISecurityElementFactory otherElem = otherObj as ISecurityElementFactory;
#endif // FEATURE_CAS_POLICY

                if (thisObj == null && otherObj == null)
                    continue;

#if FEATURE_CAS_POLICY
                if (thisElem != null && otherElem != null)
                {
                    SecurityElement newElem;
                    if (this.IsUnrestricted() || other.IsUnrestricted())
                        newElem = new SecurityElement( s_str_PermissionUnrestrictedUnion );
                    else
                        newElem = new SecurityElement( s_str_PermissionUnion );
                    newElem.AddAttribute( "class", thisElem.Attribute( "class" ) );
                    SafeChildAdd( newElem, thisElem, true );
                    SafeChildAdd( newElem, otherElem, true );
                    pset.m_permSet.SetItem( i, newElem );
                }
                else
#endif // FEATURE_CAS_POLICY
                if (thisObj == null)
                {
#if FEATURE_CAS_POLICY
                    if (otherElem != null)
                    {
                        pset.m_permSet.SetItem( i, otherElem.Copy() );
                        Contract.Assert( PermissionToken.s_tokenSet.GetItem( i ) != null, "PermissionToken should already be assigned" );
                    }
                    else
#endif // FEATURE_CAS_POLICY
                    if (otherPerm != null)
                    {
                        PermissionToken token = (PermissionToken)PermissionToken.s_tokenSet.GetItem( i );
                        if (((token.m_type & PermissionTokenType.IUnrestricted) == 0) || !pset.m_Unrestricted)
                        {
                            pset.m_permSet.SetItem( i, otherPerm.Copy() );
                            Contract.Assert( PermissionToken.s_tokenSet.GetItem( i ) != null, "PermissionToken should already be assigned" );
                        }
                    }
                }
                else if (otherObj == null)
                {
#if FEATURE_CAS_POLICY
                    if (thisElem != null)
                    {
                        pset.m_permSet.SetItem( i, thisElem.Copy() );
                    }
                    else
#endif // FEATURE_CAS_POLICY
                    if (thisPerm != null)
                    {
                        PermissionToken token = (PermissionToken)PermissionToken.s_tokenSet.GetItem( i );
                        if (((token.m_type & PermissionTokenType.IUnrestricted) == 0) || !pset.m_Unrestricted)
                        {
                            pset.m_permSet.SetItem( i, thisPerm.Copy() );
                            Contract.Assert( PermissionToken.s_tokenSet.GetItem( i ) != null, "PermissionToken should already be assigned" );
                        }
                    }
                }
                else
                {
#if FEATURE_CAS_POLICY
                    if (thisElem != null)
                        thisPerm = this.CreatePermission(thisElem, i);
                    if (otherElem != null)
                        otherPerm = other.CreatePermission(otherElem, i);
#endif // FEATURE_CAS_POLICY

                    IPermission unionPerm;
                    if(thisPerm == null)
                        unionPerm = otherPerm;
                    else if(otherPerm == null)
                        unionPerm = thisPerm;
                    else
                        unionPerm = thisPerm.Union( otherPerm );
                    pset.m_permSet.SetItem( i, unionPerm );
                    Contract.Assert( unionPerm == null || PermissionToken.s_tokenSet.GetItem( i ) != null, "PermissionToken should already be assigned" );
                }
            }
            
            return pset;
        }
开发者ID:l1183479157,项目名称:coreclr,代码行数:101,代码来源:PermissionSet.cs

示例5: Union

 public PermissionSet Union(PermissionSet other)
 {
     if ((other == null) || other.FastIsEmpty())
     {
         return this.Copy();
     }
     if (this.FastIsEmpty())
     {
         return other.Copy();
     }
     int num = -1;
     PermissionSet set = new PermissionSet {
         m_Unrestricted = this.m_Unrestricted || other.m_Unrestricted
     };
     if (!set.m_Unrestricted)
     {
         this.CheckSet();
         other.CheckSet();
         num = (this.m_permSet.GetMaxUsedIndex() > other.m_permSet.GetMaxUsedIndex()) ? this.m_permSet.GetMaxUsedIndex() : other.m_permSet.GetMaxUsedIndex();
         set.m_permSet = new TokenBasedSet();
         for (int i = 0; i <= num; i++)
         {
             object item = this.m_permSet.GetItem(i);
             IPermission permission = item as IPermission;
             ISecurityElementFactory child = item as ISecurityElementFactory;
             object obj3 = other.m_permSet.GetItem(i);
             IPermission target = obj3 as IPermission;
             ISecurityElementFactory factory2 = obj3 as ISecurityElementFactory;
             if ((item != null) || (obj3 != null))
             {
                 if ((child != null) && (factory2 != null))
                 {
                     SecurityElement element;
                     if (this.IsUnrestricted() || other.IsUnrestricted())
                     {
                         element = new SecurityElement("PermissionUnrestrictedUnion");
                     }
                     else
                     {
                         element = new SecurityElement("PermissionUnion");
                     }
                     element.AddAttribute("class", child.Attribute("class"));
                     SafeChildAdd(element, child, true);
                     SafeChildAdd(element, factory2, true);
                     set.m_permSet.SetItem(i, element);
                 }
                 else if (item == null)
                 {
                     if (factory2 != null)
                     {
                         set.m_permSet.SetItem(i, factory2.Copy());
                     }
                     else if (target != null)
                     {
                         PermissionToken token = (PermissionToken) PermissionToken.s_tokenSet.GetItem(i);
                         if (((token.m_type & PermissionTokenType.IUnrestricted) == 0) || !set.m_Unrestricted)
                         {
                             set.m_permSet.SetItem(i, target.Copy());
                         }
                     }
                 }
                 else if (obj3 == null)
                 {
                     if (child != null)
                     {
                         set.m_permSet.SetItem(i, child.Copy());
                     }
                     else if (permission != null)
                     {
                         PermissionToken token2 = (PermissionToken) PermissionToken.s_tokenSet.GetItem(i);
                         if (((token2.m_type & PermissionTokenType.IUnrestricted) == 0) || !set.m_Unrestricted)
                         {
                             set.m_permSet.SetItem(i, permission.Copy());
                         }
                     }
                 }
                 else
                 {
                     IPermission permission3;
                     if (child != null)
                     {
                         permission = this.CreatePermission(child, i);
                     }
                     if (factory2 != null)
                     {
                         target = other.CreatePermission(factory2, i);
                     }
                     if (permission == null)
                     {
                         permission3 = target;
                     }
                     else if (target == null)
                     {
                         permission3 = permission;
                     }
                     else
                     {
                         permission3 = permission.Union(target);
                     }
                     set.m_permSet.SetItem(i, permission3);
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:PermissionSet.cs

示例6: Intersect


//.........这里部分代码省略.........
                 bool copy = true;
                 bool flag2 = true;
                 SecurityElement parent = new SecurityElement("PermissionIntersection");
                 parent.AddAttribute("class", factory2.Attribute("class"));
                 if (this.IsUnrestricted())
                 {
                     SecurityElement element2 = new SecurityElement("PermissionUnrestrictedUnion");
                     element2.AddAttribute("class", child.Attribute("class"));
                     SafeChildAdd(element2, child, true);
                     flag2 = false;
                     child = element2;
                 }
                 if (other.IsUnrestricted())
                 {
                     SecurityElement element3 = new SecurityElement("PermissionUnrestrictedUnion");
                     element3.AddAttribute("class", factory2.Attribute("class"));
                     SafeChildAdd(element3, factory2, true);
                     copy = false;
                     factory2 = element3;
                 }
                 SafeChildAdd(parent, factory2, copy);
                 SafeChildAdd(parent, child, flag2);
                 set.m_permSet.SetItem(i, parent);
             }
             else if (item == null)
             {
                 if (this.m_Unrestricted)
                 {
                     if (factory2 != null)
                     {
                         SecurityElement element4 = new SecurityElement("PermissionUnrestrictedIntersection");
                         element4.AddAttribute("class", factory2.Attribute("class"));
                         SafeChildAdd(element4, factory2, true);
                         set.m_permSet.SetItem(i, element4);
                     }
                     else if (target != null)
                     {
                         PermissionToken token = (PermissionToken) PermissionToken.s_tokenSet.GetItem(i);
                         if ((token.m_type & PermissionTokenType.IUnrestricted) != 0)
                         {
                             set.m_permSet.SetItem(i, target.Copy());
                         }
                     }
                 }
             }
             else if (obj3 == null)
             {
                 if (other.m_Unrestricted)
                 {
                     if (child != null)
                     {
                         SecurityElement element5 = new SecurityElement("PermissionUnrestrictedIntersection");
                         element5.AddAttribute("class", child.Attribute("class"));
                         SafeChildAdd(element5, child, true);
                         set.m_permSet.SetItem(i, element5);
                     }
                     else if (permission != null)
                     {
                         PermissionToken token2 = (PermissionToken) PermissionToken.s_tokenSet.GetItem(i);
                         if ((token2.m_type & PermissionTokenType.IUnrestricted) != 0)
                         {
                             set.m_permSet.SetItem(i, permission.Copy());
                         }
                     }
                 }
             }
             else
             {
                 IPermission permission3;
                 if (child != null)
                 {
                     permission = this.CreatePermission(child, i);
                 }
                 if (factory2 != null)
                 {
                     target = other.CreatePermission(factory2, i);
                 }
                 if (permission == null)
                 {
                     permission3 = target;
                 }
                 else if (target == null)
                 {
                     permission3 = permission;
                 }
                 else
                 {
                     permission3 = permission.Intersect(target);
                 }
                 set.m_permSet.SetItem(i, permission3);
             }
         }
     }
     set.m_Unrestricted = this.m_Unrestricted && other.m_Unrestricted;
     if (set.FastIsEmpty())
     {
         return null;
     }
     return set;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:PermissionSet.cs

示例7: InplaceUnion

 internal void InplaceUnion(PermissionSet other)
 {
     if ((this != other) && ((other != null) && !other.FastIsEmpty()))
     {
         this.m_CheckedForNonCas = false;
         this.m_Unrestricted = this.m_Unrestricted || other.m_Unrestricted;
         if (this.m_Unrestricted)
         {
             this.m_permSet = null;
         }
         else
         {
             int maxUsedIndex = -1;
             if (other.m_permSet != null)
             {
                 maxUsedIndex = other.m_permSet.GetMaxUsedIndex();
                 this.CheckSet();
             }
             Exception exception = null;
             for (int i = 0; i <= maxUsedIndex; i++)
             {
                 object item = this.m_permSet.GetItem(i);
                 IPermission permission = item as IPermission;
                 ISecurityElementFactory child = item as ISecurityElementFactory;
                 object obj3 = other.m_permSet.GetItem(i);
                 IPermission target = obj3 as IPermission;
                 ISecurityElementFactory factory2 = obj3 as ISecurityElementFactory;
                 if ((item != null) || (obj3 != null))
                 {
                     if ((child != null) && (factory2 != null))
                     {
                         if (child.GetTag().Equals("PermissionUnion") || child.GetTag().Equals("PermissionUnrestrictedUnion"))
                         {
                             SafeChildAdd((SecurityElement) child, factory2, true);
                         }
                         else
                         {
                             SecurityElement element;
                             if (this.IsUnrestricted() || other.IsUnrestricted())
                             {
                                 element = new SecurityElement("PermissionUnrestrictedUnion");
                             }
                             else
                             {
                                 element = new SecurityElement("PermissionUnion");
                             }
                             element.AddAttribute("class", child.Attribute("class"));
                             SafeChildAdd(element, child, false);
                             SafeChildAdd(element, factory2, true);
                             this.m_permSet.SetItem(i, element);
                         }
                     }
                     else if (item == null)
                     {
                         if (factory2 != null)
                         {
                             this.m_permSet.SetItem(i, factory2.Copy());
                         }
                         else if (target != null)
                         {
                             PermissionToken token = (PermissionToken) PermissionToken.s_tokenSet.GetItem(i);
                             if (((token.m_type & PermissionTokenType.IUnrestricted) == 0) || !this.m_Unrestricted)
                             {
                                 this.m_permSet.SetItem(i, target.Copy());
                             }
                         }
                     }
                     else if (obj3 != null)
                     {
                         if (child != null)
                         {
                             permission = this.CreatePermission(child, i);
                         }
                         if (factory2 != null)
                         {
                             target = other.CreatePermission(factory2, i);
                         }
                         try
                         {
                             IPermission permission3;
                             if (permission == null)
                             {
                                 permission3 = target;
                             }
                             else if (target == null)
                             {
                                 permission3 = permission;
                             }
                             else
                             {
                                 permission3 = permission.Union(target);
                             }
                             this.m_permSet.SetItem(i, permission3);
                         }
                         catch (Exception exception2)
                         {
                             if (exception == null)
                             {
                                 exception = exception2;
                             }
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:PermissionSet.cs

示例8: InplaceIntersect


//.........这里部分代码省略.........
                                 copy = false;
                             }
                             SecurityElement parent = new SecurityElement("PermissionIntersection");
                             parent.AddAttribute("class", child.Attribute("class"));
                             SafeChildAdd(parent, child, false);
                             SafeChildAdd(parent, factory2, copy);
                             this.m_permSet.SetItem(i, parent);
                         }
                     }
                     else if (item == null)
                     {
                         if (this.IsUnrestricted())
                         {
                             if (factory2 != null)
                             {
                                 SecurityElement element4 = new SecurityElement("PermissionUnrestrictedIntersection");
                                 element4.AddAttribute("class", factory2.Attribute("class"));
                                 SafeChildAdd(element4, factory2, true);
                                 this.m_permSet.SetItem(i, element4);
                             }
                             else
                             {
                                 PermissionToken token = (PermissionToken) PermissionToken.s_tokenSet.GetItem(i);
                                 if ((token.m_type & PermissionTokenType.IUnrestricted) != 0)
                                 {
                                     this.m_permSet.SetItem(i, target.Copy());
                                 }
                             }
                         }
                     }
                     else if (obj3 == null)
                     {
                         if (other.IsUnrestricted())
                         {
                             if (child != null)
                             {
                                 SecurityElement element5 = new SecurityElement("PermissionUnrestrictedIntersection");
                                 element5.AddAttribute("class", child.Attribute("class"));
                                 SafeChildAdd(element5, child, false);
                                 this.m_permSet.SetItem(i, element5);
                             }
                             else
                             {
                                 PermissionToken token2 = (PermissionToken) PermissionToken.s_tokenSet.GetItem(i);
                                 if ((token2.m_type & PermissionTokenType.IUnrestricted) == 0)
                                 {
                                     this.m_permSet.SetItem(i, null);
                                 }
                             }
                         }
                         else
                         {
                             this.m_permSet.SetItem(i, null);
                         }
                     }
                     else
                     {
                         if (child != null)
                         {
                             permission = this.CreatePermission(child, i);
                         }
                         if (factory2 != null)
                         {
                             target = other.CreatePermission(factory2, i);
                         }
                         try
                         {
                             IPermission permission3;
                             if (permission == null)
                             {
                                 permission3 = target;
                             }
                             else if (target == null)
                             {
                                 permission3 = permission;
                             }
                             else
                             {
                                 permission3 = permission.Intersect(target);
                             }
                             this.m_permSet.SetItem(i, permission3);
                         }
                         catch (Exception exception2)
                         {
                             if (exception == null)
                             {
                                 exception = exception2;
                             }
                         }
                     }
                 }
             }
             this.m_Unrestricted = this.m_Unrestricted && other.m_Unrestricted;
             if (exception != null)
             {
                 throw exception;
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:PermissionSet.cs

示例9: Union


//.........这里部分代码省略.........
                {
                    // Only unrestricted override-able permissions in both this and other ...again, we can return just an unrestricted pset
                    return pset;
                }
                if (other.m_canUnrestrictedOverride)
                {
                    // Only unrestricted override-able permissions in other...cannot null pset.m_permSet, but don't look at other.m_permSet
                    // just copy over this.m_permSet
                    pset.m_permSet = (this.m_permSet != null)? new TokenBasedSet(this.m_permSet): null;
                    return pset;
                }
            }
            
            // degenerate case where we look at both this.m_permSet and other.m_permSet
            this.CheckSet();
            other.CheckSet();
            maxMax = this.m_permSet.GetMaxUsedIndex() > other.m_permSet.GetMaxUsedIndex() ? this.m_permSet.GetMaxUsedIndex() : other.m_permSet.GetMaxUsedIndex();
            pset.m_permSet = new TokenBasedSet();



            for (int i = 0; i <= maxMax; ++i)
            {
                Object thisObj = this.m_permSet.GetItem( i );
                IPermission thisPerm = thisObj as IPermission;
                ISecurityElementFactory thisElem = thisObj as ISecurityElementFactory;
                
                Object otherObj = other.m_permSet.GetItem( i );
                IPermission otherPerm = otherObj as IPermission;
                ISecurityElementFactory otherElem = otherObj as ISecurityElementFactory;

                if (thisObj == null && otherObj == null)
                    continue;

                if (thisElem != null && otherElem != null)
                {
                    SecurityElement newElem;
                    if (this.IsUnrestricted() || other.IsUnrestricted())
                        newElem = new SecurityElement( s_str_PermissionUnrestrictedUnion );
                    else
                        newElem = new SecurityElement( s_str_PermissionUnion );
                    newElem.AddAttribute( "class", thisElem.Attribute( "class" ) );
                    SafeChildAdd( newElem, thisElem, true );
                    SafeChildAdd( newElem, otherElem, true );
                    pset.m_permSet.SetItem( i, newElem );
                }
                else if (thisObj == null)
                {
                    if (otherElem != null)
                    {
                        pset.m_permSet.SetItem( i, otherElem.Copy() );
                        BCLDebug.Assert( PermissionToken.s_tokenSet.GetItem( i ) != null, "PermissionToken should already be assigned" );
                    }
                    else if (otherPerm != null)
                    {
                        PermissionToken token = (PermissionToken)PermissionToken.s_tokenSet.GetItem( i );
                        if (((token.m_type & PermissionTokenType.IUnrestricted) == 0) || !pset.m_Unrestricted)
                        {
                            pset.m_permSet.SetItem( i, otherPerm.Copy() );
                            BCLDebug.Assert( PermissionToken.s_tokenSet.GetItem( i ) != null, "PermissionToken should already be assigned" );
                        }
                    }
                }
                else if (otherObj == null)
                {
                    if (thisElem != null)
                    {
                        pset.m_permSet.SetItem( i, thisElem.Copy() );
                    }
                    else if (thisPerm != null)
                    {
                        PermissionToken token = (PermissionToken)PermissionToken.s_tokenSet.GetItem( i );
                        if (((token.m_type & PermissionTokenType.IUnrestricted) == 0) || !pset.m_Unrestricted)
                        {
                            pset.m_permSet.SetItem( i, thisPerm.Copy() );
                            BCLDebug.Assert( PermissionToken.s_tokenSet.GetItem( i ) != null, "PermissionToken should already be assigned" );
                        }
                    }
                }
                else
                {
                    if (thisElem != null)
                        thisPerm = this.CreatePermission(thisElem, i);
                    if (otherElem != null)
                        otherPerm = other.CreatePermission(otherElem, i);

                    IPermission unionPerm;
                    if(thisPerm == null)
                        unionPerm = otherPerm;
                    else if(otherPerm == null)
                        unionPerm = thisPerm;
                    else
                        unionPerm = thisPerm.Union( otherPerm );
                    pset.m_permSet.SetItem( i, unionPerm );
                    BCLDebug.Assert( unionPerm == null || PermissionToken.s_tokenSet.GetItem( i ) != null, "PermissionToken should already be assigned" );
                }
            }
            
            return pset;
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:permissionset.cs


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