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


C# TokenBasedSet.SetItem方法代码示例

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


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

示例1: AppendStackHelper

		private void AppendStackHelper( TokenBasedSet thisSet, TokenBasedSet permSet, bool unrestrictedThisSet, bool unrestrictedPermSet, bool unrestricted )
		{
            int maxThis = thisSet.GetMaxUsedIndex();
            int maxPerm = permSet.GetMaxUsedIndex();
            
            int maxIndex = maxThis > maxPerm ? maxThis : maxPerm;
            
            for (int i = 0; i <= maxIndex; i++)
            {
                PermissionList plist = (PermissionList)thisSet.GetItem(i);
                PermissionList appendList = (PermissionList)permSet.GetItem(i);
                if (plist != null)
                {
                    if (appendList != null)
                    {
                        // This call will not add the permission if the list is
                        // empty, or if the last element is a normal check with
                        // a null Permission. Let the method take care of it...
                        plist.AppendStack(appendList.Copy());
                    }
                    else
                    {
                        // Nothing on the compressed stack for this index,
                        // so terminate current list.
                        if (!unrestrictedPermSet)
                        {
                            thisSet.SetItem( i, plist.Copy() );
                        }
                    }
                }
                else if (unrestrictedThisSet && appendList != null)
                {
                    thisSet.SetItem(i, appendList.Copy());
                }
            }
		}
开发者ID:ArildF,项目名称:masters,代码行数:36,代码来源:permissionlistset.cs

示例2: CopyTokenBasedSet

        public static TokenBasedSet CopyTokenBasedSet( TokenBasedSet set )
        {
            if (set == null || set.GetCount() == 0)
                return null;

            int maxIndex = set.GetMaxUsedIndex();

            TokenBasedSet copySet = new TokenBasedSet( maxIndex + 1, 4 );

            for (int i = 0; i <= maxIndex; ++i)
            {
                Object obj = set.GetItem( i );

                if (obj == null)
                    copySet.SetItem( i, null );
                else if (obj is IPermission)
                    copySet.SetItem( i, ((IPermission)obj).Copy() );
                else if (obj is PermissionList)
                    copySet.SetItem( i, ((PermissionList)obj).Copy() );
                else
                {
                    BCLDebug.Assert( false, "CopyTokenBasedSet can only be used for IPermission and PermissionList based TokenBasedSets" );
                    copySet.SetItem( i, obj );
                }
            }

            return copySet;
        }
开发者ID:ArildF,项目名称:masters,代码行数:28,代码来源:permissionlistset.cs

示例3: AppendTokenBasedSets

     private void AppendTokenBasedSets( TokenBasedSet thisSet, TokenBasedSet permSet, int type, bool unrestricted )
     {
         int thisMaxIndex = thisSet.GetMaxUsedIndex();
         int permMaxIndex = permSet == null ? 0 : permSet.GetMaxUsedIndex();
         int maxIndex = thisMaxIndex > permMaxIndex ? thisMaxIndex : permMaxIndex;
         
         // Loop over the relevant indexes...
         for (int i = 0; i <= maxIndex; i++)
         {
             PermissionList plist = (PermissionList)thisSet.GetItem(i);
             CodeAccessPermission cap = permSet == null ? null : (CodeAccessPermission)permSet.GetItem(i);
             
             if (plist == null)
             {
                 if (this.m_unrestricted)
                 {
                     switch (type)
                     {
                     case PermissionList.MatchChecked:
                     case PermissionList.MatchPermitOnly:
                         plist = new PermissionList();
                         plist.AppendPermission(cap, type);
                         thisSet.SetItem( i, plist );
                         break;
                     
                     case PermissionList.MatchDeny:
                     case PermissionList.MatchAssert:
                         if (cap != null)
                         {
                             plist = new PermissionList();
                             plist.AppendPermission(cap, type);
                             thisSet.SetItem( i, plist );
                         }
                         break;
                     
                     default:
                         throw new ArgumentException(Environment.GetResourceString( "Argument_InvalidPermissionListType" ));
                     }
                 }
             }
             else
             {                    
                 // A list already exists. All lists should have at least
                 // one element in them.
 
                 // Normally, only append if the permission is not null.
                 // However, if the type is Checked, then make sure the
                 // list is terminated with a permission, null or not.
                 switch (type)
                 {
                 case PermissionList.MatchChecked:
                 case PermissionList.MatchPermitOnly:
                     plist.AppendPermissionAndCompress(cap, type);
                     break;
                         
                 case PermissionList.MatchDeny:
                 case PermissionList.MatchAssert:
                     if (cap != null)
                         plist.AppendPermissionAndCompress(cap, type);
                     break;
                         
                 default:
                     throw new ArgumentException(Environment.GetResourceString( "Argument_InvalidPermissionListType" ));
                 }
             }
         }
     }
开发者ID:ArildF,项目名称:masters,代码行数:67,代码来源:permissionlistset.cs

示例4: SpecialUnion

        // Used to merge two distinct TokenBasedSets (used currently only in PermissionSet Deserialization)
        internal TokenBasedSet SpecialUnion(TokenBasedSet other)
        {
            // This gets called from PermissionSet.OnDeserialized and it's possible that the TokenBasedSets have 
            // not been subjected to VTS callbacks yet
            OnDeserializedInternal();
            TokenBasedSet unionSet = new TokenBasedSet();
            int maxMax;
            if (other != null)
            {
                other.OnDeserializedInternal();
                maxMax = this.GetMaxUsedIndex() > other.GetMaxUsedIndex() ? this.GetMaxUsedIndex() : other.GetMaxUsedIndex();
            }
            else
                maxMax = this.GetMaxUsedIndex();
        
            for (int i = 0; i <= maxMax; ++i)
            {
                Object thisObj = this.GetItem( i );
                IPermission thisPerm = thisObj as IPermission;
#if FEATURE_CAS_POLICY
                ISecurityElementFactory thisElem = thisObj as ISecurityElementFactory;
#endif // FEATURE_CAS_POLICY

                Object otherObj = (other != null)?other.GetItem( i ):null;
                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 (thisObj == null)
                {
#if FEATURE_CAS_POLICY
                    if (otherElem != null)
                    {
                        otherPerm = PermissionSet.CreatePerm(otherElem, false);
                    }
#endif // FEATURE_CAS_POLICY

                    PermissionToken token = PermissionToken.GetToken(otherPerm);
                    
                    if (token == null)
                    {
                        throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState"));
                    }
                    
                    unionSet.SetItem(token.m_index, otherPerm);
                }
                else if (otherObj == null)
                {
#if FEATURE_CAS_POLICY
                    if (thisElem != null)
                    {
                        thisPerm = PermissionSet.CreatePerm(thisElem, false);
                    }
#endif // FEATURE_CAS_POLICY

                    PermissionToken token = PermissionToken.GetToken(thisPerm);
                    if (token == null)
                    {
                        throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState"));
                    }
                    unionSet.SetItem( token.m_index, thisPerm);
                }
                else
                {
                    Contract.Assert( (thisObj == null || otherObj == null), "Permission cannot be in both TokenBasedSets" );
                }
            }
            return unionSet;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:75,代码来源:TokenBasedSet.cs

示例5: PermissionListSet

     public PermissionListSet(PermissionListSet permListSet)
     {
         if (permListSet == null)
         {
             Reset();
             return;
         }
         
         m_unrestrictedPermSet = new TokenBasedSet(permListSet.m_unrestrictedPermSet);
 
         // Now deep copy all permission lists in set.
         // Note that this DOES deep copy permissions in the list.
         for (int i = 0; i <= m_unrestrictedPermSet.GetMaxUsedIndex(); i++)
         {
             PermissionList plist = (PermissionList)m_unrestrictedPermSet.GetItem(i);
             if (plist != null)
             {
                 m_unrestrictedPermSet.SetItem(i, plist.Copy());
             }
         }
         
         m_normalPermSet = new TokenBasedSet(permListSet.m_normalPermSet);
         
         // Now deep copy all permission lists in set.
         // Note that this DOES deep copy permissions in the list.
         for (int i = 0; i <= m_normalPermSet.GetMaxUsedIndex(); i++)
         {
             PermissionList plist = (PermissionList)m_normalPermSet.GetItem(i);
             if (plist != null)
             {
                 m_normalPermSet.SetItem(i, plist.Copy());
             }
         }        
         
         m_unrestricted = permListSet.m_unrestricted;
         m_state = permListSet.m_state;
     }
开发者ID:ArildF,项目名称:masters,代码行数:37,代码来源:permissionlistset.cs

示例6: PermissionSet

        /// <include file='doc\PermissionSet.uex' path='docs/doc[@for="PermissionSet.PermissionSet1"]/*' />
        public PermissionSet(PermissionSet permSet)
            : this()
        {
            if (permSet == null)
            {
                Reset();
                return;
            }
    
            m_Unrestricted = permSet.m_Unrestricted;
            m_CheckedForNonCas = permSet.m_CheckedForNonCas;
            m_ContainsCas = permSet.m_ContainsCas;
            m_ContainsNonCas = permSet.m_ContainsNonCas;
            
            if (permSet.m_normalPermSet != null)
            {
                m_normalPermSet = new TokenBasedSet(permSet.m_normalPermSet);
                
                 // now deep copy all permissions in set
                for (int i = 0; i <= m_normalPermSet.GetMaxUsedIndex(); i++)
                {
                    IPermission perm = (IPermission)m_normalPermSet.GetItem(i);
                    if (perm != null)
                    {
                        m_normalPermSet.SetItem(i, perm.Copy());
                    }
                }
            }
               
            if (permSet.m_unrestrictedPermSet != null)
            {
                m_unrestrictedPermSet = new TokenBasedSet(permSet.m_unrestrictedPermSet);
                
                 // now deep copy all permissions in set
                for (int i = 0; i <= m_unrestrictedPermSet.GetMaxUsedIndex(); i++)
                {
                    IPermission perm = (IPermission)m_unrestrictedPermSet.GetItem(i);
                    if (perm != null)
                    {
                        m_unrestrictedPermSet.SetItem(i, perm.Copy());
                    }
                }
            }

            if (permSet.m_toBeLoaded != null)
            {
                this.m_toBeLoaded = new SecurityElement();

                IEnumerator enumerator = permSet.m_toBeLoaded.m_lChildren.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    this.m_toBeLoaded.AddChild( (SecurityElement)enumerator.Current );
                }
            }

        }
开发者ID:ArildF,项目名称:masters,代码行数:58,代码来源:permissionset.cs

示例7: PermissionSet

        public PermissionSet(PermissionSet permSet)
            : this()
        {
            if (permSet == null)
            {
                Reset();
                return;
            }

            m_Unrestricted = permSet.m_Unrestricted;
            m_CheckedForNonCas = permSet.m_CheckedForNonCas;
            m_ContainsCas = permSet.m_ContainsCas;
            m_ContainsNonCas = permSet.m_ContainsNonCas;
            m_ignoreTypeLoadFailures = permSet.m_ignoreTypeLoadFailures;

            if (permSet.m_permSet != null)
            {
                m_permSet = new TokenBasedSet(permSet.m_permSet);
                
                // now deep copy all permissions in set
                for (int i = m_permSet.GetStartingIndex(); i <= m_permSet.GetMaxUsedIndex(); i++)
                {
                    Object obj = m_permSet.GetItem(i);
                    IPermission perm = obj as IPermission;
#if FEATURE_CAS_POLICY
                    ISecurityElementFactory elem = obj as ISecurityElementFactory;
#endif // FEATURE_CAS_POLICY
                    if (perm != null)
                    {
                        m_permSet.SetItem(i, perm.Copy());
                    }
#if FEATURE_CAS_POLICY
                    else if (elem != null)
                    {
                        m_permSet.SetItem(i, elem.Copy());
                    }
#endif // FEATURE_CAS_POLICY
                }
            }
        }
开发者ID:l1183479157,项目名称:coreclr,代码行数:40,代码来源:PermissionSet.cs

示例8: PermissionSet

        public PermissionSet(PermissionSet permSet)
            : this()
        {
            if (permSet == null)
            {
                Reset();
                return;
            }

            m_Unrestricted = permSet.m_Unrestricted;
            m_CheckedForNonCas = permSet.m_CheckedForNonCas;
            m_ContainsCas = permSet.m_ContainsCas;
            m_ContainsNonCas = permSet.m_ContainsNonCas;
            m_ignoreTypeLoadFailures = permSet.m_ignoreTypeLoadFailures;

            if (permSet.m_permSet != null)
            {
                m_permSet = new TokenBasedSet(permSet.m_permSet);
                
                // now deep copy all permissions in set
                for (int i = m_permSet.GetStartingIndex(); i <= m_permSet.GetMaxUsedIndex(); i++)
                {
                    Object obj = m_permSet.GetItem(i);
                    IPermission perm = obj as IPermission;

                    if (perm != null)
                    {
                        m_permSet.SetItem(i, perm.Copy());
                    }
                }
            }
        }
开发者ID:kouvel,项目名称:coreclr,代码行数:32,代码来源:PermissionSet.cs

示例9: SpecialUnion

 internal TokenBasedSet SpecialUnion(TokenBasedSet other)
 {
     int maxUsedIndex;
     this.OnDeserializedInternal();
     TokenBasedSet set = new TokenBasedSet();
     if (other != null)
     {
         other.OnDeserializedInternal();
         maxUsedIndex = (this.GetMaxUsedIndex() > other.GetMaxUsedIndex()) ? this.GetMaxUsedIndex() : other.GetMaxUsedIndex();
     }
     else
     {
         maxUsedIndex = this.GetMaxUsedIndex();
     }
     for (int i = 0; i <= maxUsedIndex; i++)
     {
         object item = this.GetItem(i);
         IPermission perm = item as IPermission;
         ISecurityElementFactory factory = item as ISecurityElementFactory;
         object obj3 = (other != null) ? other.GetItem(i) : null;
         IPermission permission2 = obj3 as IPermission;
         ISecurityElementFactory factory2 = obj3 as ISecurityElementFactory;
         if ((item != null) || (obj3 != null))
         {
             if (item == null)
             {
                 if (factory2 != null)
                 {
                     permission2 = PermissionSet.CreatePerm(factory2, false);
                 }
                 PermissionToken token = PermissionToken.GetToken(permission2);
                 if (token == null)
                 {
                     throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState"));
                 }
                 set.SetItem(token.m_index, permission2);
             }
             else if (obj3 == null)
             {
                 if (factory != null)
                 {
                     perm = PermissionSet.CreatePerm(factory, false);
                 }
                 PermissionToken token2 = PermissionToken.GetToken(perm);
                 if (token2 == null)
                 {
                     throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState"));
                 }
                 set.SetItem(token2.m_index, perm);
             }
         }
     }
     return set;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:54,代码来源:TokenBasedSet.cs

示例10: SpecialUnion

        // Used to merge two distinct TokenBasedSets (used currently only in PermissionSet Deserialization)
        internal TokenBasedSet SpecialUnion(TokenBasedSet other, ref bool canUnrestrictedOverride)
        {
            // This gets called from PermissionSet.OnDeserialized and it's possible that the TokenBasedSets have 
            // not been subjected to VTS callbacks yet
            OnDeserializedInternal();
            TokenBasedSet unionSet = new TokenBasedSet();
            int maxMax;
            if (other != null)
            {
                other.OnDeserializedInternal();
                maxMax = this.GetMaxUsedIndex() > other.GetMaxUsedIndex() ? this.GetMaxUsedIndex() : other.GetMaxUsedIndex();
            }
            else
                maxMax = this.GetMaxUsedIndex();
        
            for (int i = 0; i <= maxMax; ++i)
            {
                Object thisObj = this.GetItem( i );
                IPermission thisPerm = thisObj as IPermission;
                ISecurityElementFactory thisElem = thisObj as ISecurityElementFactory;
                
                Object otherObj = (other != null)?other.GetItem( i ):null;
                IPermission otherPerm = otherObj as IPermission;
                ISecurityElementFactory otherElem = otherObj as ISecurityElementFactory;
        
                if (thisObj == null && otherObj == null)
                    continue;
        
             
                if (thisObj == null)
                {
                    if (otherElem != null)
                    {
                        otherPerm = PermissionSet.CreatePerm(otherElem, false);
                    }
                    
                    
                    

                    PermissionToken token = PermissionToken.GetToken(otherPerm);
                    
                    if (token == null)
                    {
                        throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState"));
                    }
                    
                    unionSet.SetItem(token.m_index, otherPerm);
                    if (!CodeAccessPermission.CanUnrestrictedOverride(otherPerm))
                        canUnrestrictedOverride = false;
                }
                else if (otherObj == null)
                {
                    if (thisElem != null)
                    {
                        thisPerm = PermissionSet.CreatePerm(thisElem, false);
                    }
                    PermissionToken token = PermissionToken.GetToken(thisPerm);
                    if (token == null)
                    {
                        throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState"));
                    }
                    unionSet.SetItem( token.m_index, thisPerm);
                    if (!CodeAccessPermission.CanUnrestrictedOverride(thisPerm))
                        canUnrestrictedOverride = false;

                }
                else
                {
                    BCLDebug.Assert( (thisObj == null || otherObj == null), "Permission cannot be in both TokenBasedSets" );
                }
            }
            return unionSet;
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:74,代码来源:tokenbasedset.cs

示例11: GenericUnion

     private void GenericUnion( TokenBasedSet target, TokenBasedSet other, bool needToCopy )
     {
         // Note: Assumes target set is large enough and empty.
         
         // Get the max indicies
         int thisMaxIndex = this.m_maxIndex;
         int otherMaxIndex = other != null ? other.m_maxIndex : 0;
         int minMaxUsedIndex;
         int maxMaxUsedIndex;
         TokenBasedSet biggerSet;
         
         // We want to save any exceptions that occur and throw them at the end.
         Exception savedException = null;
         
         if (thisMaxIndex < otherMaxIndex)
         {
             minMaxUsedIndex = thisMaxIndex;
             maxMaxUsedIndex = otherMaxIndex;
             biggerSet = other;
         }
         else
         {
             minMaxUsedIndex = otherMaxIndex;
             maxMaxUsedIndex = thisMaxIndex;
             biggerSet = this;
         }
 
         IPermission p1;
         IPermission p2;
         int i;
         
         for (i = 0; i<=minMaxUsedIndex; ++i)
         {
             try
             {
                 p2 = other != null ? (IPermission)other.m_objSet[i] : null;
                 p1 = (IPermission)this.m_objSet[i];
                 if (p2 != null)
                 {
                     // we only need to do something is the other set has something in this slot
                     if (p1 == null)
                     {
                         // nothing in this set, so insert a copy.
                         if (needToCopy)
                         target.SetItem( i, p2.Copy() );
                         else
                             target.SetItem( i, p2 );
                     }
                     else
                     {
                         // both have it, so replace this's with the union.
                         target.SetItem( i, p1.Union( p2 ) );
                     }
                 }
                 else if (needToCopy)
                 {
                     if (p1 != null)
                         target.SetItem( i, p1.Copy() );
                     else
                         target.SetItem( i, null );
                 }
                 else
                 {
                     target.SetItem( i, p1 );
                 }
             }
             catch (Exception e)
             {
                 if (savedException == null)
                     savedException = e;
             }
         }
         
         for (i = minMaxUsedIndex+1; i <= maxMaxUsedIndex; ++i)
         {
             try
             {
                 if (needToCopy && biggerSet.m_objSet[i] != null)
                     target.SetItem( i, ((IPermission)biggerSet.m_objSet[i]).Copy() );
                 else
                     target.SetItem( i, biggerSet.m_objSet[i] );
             }
             catch (Exception e)
             {
                 if (savedException == null)
                     savedException = e;
             }
         }
         
         if (savedException != null)
             throw savedException;
     }
开发者ID:ArildF,项目名称:masters,代码行数:92,代码来源:tokenbasedset.cs

示例12: GenericIntersect

 private void GenericIntersect( TokenBasedSet target, TokenBasedSet other )
 {
     // Note: Assumes target set is large enough and empty.
     int thisMaxIndex = this.m_maxIndex; 
     int otherMaxIndex = other != null ? other.m_maxIndex : 0;
     int minMaxIndex = thisMaxIndex < otherMaxIndex ? thisMaxIndex : otherMaxIndex;
     
     // We want to save any exceptions that occur and throw them at the end.
     Exception savedException = null;
     
     for (int i = 0; i <= minMaxIndex; i++)
     {
         try
         {
             IPermission p1 = other != null ? (IPermission)other.m_objSet[i] : null;
             IPermission p2 = (IPermission)this.m_objSet[i];
             if (p1 != null && p2 != null)
             {
                 target.SetItem( i, p1.Intersect(p2) );
             }
             else
             {
                 target.SetItem( i, null );
             }
         }
         catch (Exception e)
         {
             if (savedException == null)
                 savedException = e;
                 
             // Remove the permission from the intersection set
             
             target.SetItem( i, null );
         }
     }
     
     if (minMaxIndex == otherMaxIndex)
     {
         for (int i = otherMaxIndex+1; i <= target.m_maxIndex; ++i)
         {
             target.RemoveItem( i );
         }
     }
     
     if (savedException != null)
         throw savedException;
 }
开发者ID:ArildF,项目名称:masters,代码行数:47,代码来源:tokenbasedset.cs


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