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


C# PermissionSet.RemovePermission方法代码示例

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


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

示例1: RemovePermission_None

		public void RemovePermission_None () 
		{
			PermissionSet ps = new PermissionSet (PermissionState.None);
			Assert.IsNull (ps.RemovePermission (typeof (SecurityPermission)), "Empty");
			SecurityPermission sp = new SecurityPermission (SecurityPermissionFlag.Assertion);
			ps.AddPermission (sp);
			SecurityPermission removed = (SecurityPermission) ps.RemovePermission (typeof (SecurityPermission));
			Assert.IsNotNull (removed, "SecurityPermission");
			Assert.AreEqual (sp.Flags, removed.Flags, "Flags");
			Assert.IsNull (ps.RemovePermission (typeof (SecurityPermission)), "Empty-Again");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:11,代码来源:PermissionSetTest.cs

示例2: RemovePermission_Unrestricted

		public void RemovePermission_Unrestricted ()
		{
			PermissionSet ps = new PermissionSet (PermissionState.Unrestricted);
			Assert.IsNull (ps.RemovePermission (typeof (SecurityPermission)), "Empty");
			SecurityPermission sp = new SecurityPermission (SecurityPermissionFlag.Assertion);
			ps.AddPermission (sp);
			Assert.IsNull (ps.RemovePermission (typeof (SecurityPermission)), "SecurityPermissionn");
			ZoneIdentityPermission zip = new ZoneIdentityPermission (SecurityZone.MyComputer);
			ps.AddPermission (zip);
			ZoneIdentityPermission removed = (ZoneIdentityPermission)ps.RemovePermission (typeof (ZoneIdentityPermission));
#if NET_2_0
			// identity permissions aren't added to unrestricted permission sets
			// so they cannot be removed later (hence the null)
			Assert.IsNull (removed, "ZoneIdentityPermission");
#else
			Assert.IsNotNull (removed, "ZoneIdentityPermission");
#endif
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:18,代码来源:PermissionSetTest.cs

示例3: RemoveAssertedPermissionSet

 internal static void RemoveAssertedPermissionSet(PermissionSet demandSet, PermissionSet assertSet, out PermissionSet alteredDemandSet)
 {
     Contract.Assert(!assertSet.IsUnrestricted(), "Cannot call this function if assertSet is unrestricted");
     alteredDemandSet = null;
     
     PermissionSetEnumeratorInternal enumerator = new PermissionSetEnumeratorInternal(demandSet);
     while (enumerator.MoveNext())
     {
         CodeAccessPermission demandDerm = (CodeAccessPermission)enumerator.Current;
         int i = enumerator.GetCurrentIndex();
         if (demandDerm != null)
         {
             CodeAccessPermission assertPerm
                 = (CodeAccessPermission)assertSet.GetPermission(i);
             try
             {
                 if (demandDerm.CheckAssert(assertPerm))
                 {
                     if (alteredDemandSet == null)
                         alteredDemandSet = demandSet.Copy();
     
                     alteredDemandSet.RemovePermission(i);
                 }
             }
             catch (ArgumentException)
             {
             }
         }
     }
     return;
 }
开发者ID:l1183479157,项目名称:coreclr,代码行数:31,代码来源:PermissionSet.cs

示例4: RemovePermission_Null

		public void RemovePermission_Null () 
		{
			PermissionSet ps = new PermissionSet (PermissionState.None);
			Assert.IsNull (ps.RemovePermission (null));
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:5,代码来源:PermissionSetTest.cs

示例5: CopyWithNoIdentityPermissions

        internal PermissionSet CopyWithNoIdentityPermissions()
        {
            // Explicitly make a new PermissionSet, rather than copying, since we may have a
            // ReadOnlyPermissionSet which cannot have identity permissions removed from it in a true copy.
            PermissionSet copy = new PermissionSet(this);

            // There's no easy way to distinguish an identity permission from any other CodeAccessPermission,
            // so remove them directly.
#if FEATURE_CAS_POLICY
            copy.RemovePermission(typeof(GacIdentityPermission));
#if FEATURE_X509
            copy.RemovePermission(typeof(PublisherIdentityPermission));
#endif
            copy.RemovePermission(typeof(StrongNameIdentityPermission));
            copy.RemovePermission(typeof(UrlIdentityPermission));
            copy.RemovePermission(typeof(ZoneIdentityPermission));
#endif // FEATURE_CAS_POLICY

            return copy;
        }
开发者ID:l1183479157,项目名称:coreclr,代码行数:20,代码来源:PermissionSet.cs

示例6: FrameDescSetHelper


//.........这里部分代码省略.........
                throw new SecurityException(Environment.GetResourceString("Security_GenericNoType"));
            }
                
            // In the case of denial, we define an exception to be failure of the check
            // and therefore we throw a security exception.
                
            try
            {
                permSet = secDesc.GetDenials();

    #if _DEBUG
                if (debug)
                {
                    DEBUG_OUT("Checking Denials");
                    DEBUG_OUT("denials set =\n" + permSet.ToXml().ToString() );
                    DEBUG_OUT("demandSet =\n" + demandSet.ToXml().ToString() );
                }
    #endif

                if (permSet != null)
                {
                    PermissionSet intersection = demandSet.Intersect(permSet);
            
                    if (intersection != null && !intersection.IsEmpty())
                    {
                        throw new SecurityException(Environment.GetResourceString("Security_GenericNoType"));
                    }
                }
            }
            catch (Exception)
            {
                throw new SecurityException(Environment.GetResourceString("Security_GenericNoType"));
            }
            
            // The assert case is more complex.  Since asserts have the ability to "bleed through"
            // (where part of a demand is handled by an assertion, but the rest is passed on to
            // continue the stackwalk), we need to be more careful in handling the "failure" case.
            // Therefore, if an exception is thrown in performing any operation, we make sure to keep
            // that permission in the demand set thereby continuing the demand for that permission
            // walking down the stack.
            
            if (secDesc.GetAssertAllPossible())
            {
                return StackHalt;
            }        
            
            permSet = secDesc.GetAssertions();
            if (permSet != null)
            {
                // If this frame asserts a superset of the demand set we're done
                
                try
                {
                    if (demandSet.IsSubsetOf( permSet ))
                        return StackHalt;
                }
                catch (Exception)
                {
                }
                
                // Determine whether any of the demand set asserted.  We do this by
                // copying the demand set and removing anything in it that is asserted.
                    
                if (!permSet.IsUnrestricted())
                {
                    PermissionSetEnumerator enumerator = (PermissionSetEnumerator)demandSet.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        IPermission perm
                            = (IPermission)enumerator.Current;
                        int i = enumerator.GetCurrentIndex();
                        if (perm != null)
                        {
                            bool unrestricted = perm is System.Security.Permissions.IUnrestrictedPermission;
                            IPermission assertPerm
                                = (IPermission)permSet.GetPermission(i, unrestricted);
                            
                            bool removeFromAlteredDemand = false;
                            try
                            {
                                removeFromAlteredDemand = perm.IsSubsetOf(assertPerm);
                            }
                            catch (Exception)
                            {
                            }
                        
                            if (removeFromAlteredDemand)
                            {
                                if (alteredDemandSet == null)
                                    alteredDemandSet = demandSet.Copy();
                                alteredDemandSet.RemovePermission(i, unrestricted);
                            }                        
                        
                        }
                    }
                }
            }
            
            return StackContinue;
        }
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:securityruntime.cs

示例7: CopyWithNoIdentityPermissions

 internal PermissionSet CopyWithNoIdentityPermissions()
 {
     PermissionSet set = new PermissionSet(this);
     set.RemovePermission(typeof(GacIdentityPermission));
     set.RemovePermission(typeof(PublisherIdentityPermission));
     set.RemovePermission(typeof(StrongNameIdentityPermission));
     set.RemovePermission(typeof(UrlIdentityPermission));
     set.RemovePermission(typeof(ZoneIdentityPermission));
     return set;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:PermissionSet.cs

示例8: RemoveAssertedPermissionSet

 internal static void RemoveAssertedPermissionSet(PermissionSet demandSet, PermissionSet assertSet, out PermissionSet alteredDemandSet)
 {
     alteredDemandSet = null;
     PermissionSetEnumeratorInternal internal2 = new PermissionSetEnumeratorInternal(demandSet);
     while (internal2.MoveNext())
     {
         CodeAccessPermission current = (CodeAccessPermission) internal2.Current;
         int currentIndex = internal2.GetCurrentIndex();
         if (current != null)
         {
             CodeAccessPermission permission = (CodeAccessPermission) assertSet.GetPermission(currentIndex);
             try
             {
                 if (current.CheckAssert(permission))
                 {
                     if (alteredDemandSet == null)
                     {
                         alteredDemandSet = demandSet.Copy();
                     }
                     alteredDemandSet.RemovePermission(currentIndex);
                 }
                 continue;
             }
             catch (ArgumentException)
             {
                 continue;
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:PermissionSet.cs

示例9: RemovePermission_None

		public void RemovePermission_None () 
		{
			PermissionSet ps = new PermissionSet (PermissionState.None);
			AssertNull ("Empty", ps.RemovePermission (typeof (SecurityPermission)));
			SecurityPermission sp = new SecurityPermission (SecurityPermissionFlag.Assertion);
			ps.AddPermission (sp);
			SecurityPermission removed = (SecurityPermission) ps.RemovePermission (typeof (SecurityPermission));
			AssertNotNull ("SecurityPermission", removed);
			AssertEquals ("Flags", sp.Flags, removed.Flags);
			AssertNull ("Empty-Again", ps.RemovePermission (typeof (SecurityPermission)));
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:11,代码来源:PermissionSetTest.cs


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