コード例 #1
0
        private static void ParseClaims(Acl acl, JObject item)
        {
            var           sid           = item.Property("sid").Value.ToString();
            var           type          = item.Property("type").Value.ToString();
            List <Access> allowed       = new List <Access>();
            List <Access> denied        = new List <Access>();
            var           allowProperty = item.Property("allow");

            if (allowProperty != null)
            {
                allowProperty
                .Values()
                .Select(x => (Access)Enum.Parse(typeof(Access), x.ToString(), true))
                .For(x => allowed.Add(x));
            }
            var denyProperty = item.Property("deny");

            if (denyProperty != null)
            {
                denyProperty
                .Values()
                .Select(x => (Access)Enum.Parse(typeof(Access), x.ToString(), true))
                .For(x => denied.Add(x));
            }
            ClaimType    claimType = (ClaimType)Enum.Parse(typeof(ClaimType), type, true);
            List <Claim> claims    = new List <Claim>();

            allowed.For(x => claims.Add(new Claim(Permission.Allow, x, claimType, sid)));
            denied.For(x => claims.Add(new Claim(Permission.Deny, x, claimType, sid)));
            acl.SetInternal(claims);
        }
コード例 #2
0
 private static void ParseClaims(Acl acl, JObject item)
 {
     var sid = item.Property("sid").Value.ToString();
     var type = item.Property("type").Value.ToString();
     List<Access> allowed = new List<Access>();
     List<Access> denied = new List<Access>();
     var allowProperty = item.Property("allow");
     if (allowProperty != null)
     {
         allowProperty
             .Values()
             .Select(x => (Access)Enum.Parse(typeof(Access), x.ToString(), true))
             .For(x => allowed.Add(x));
     }
     var denyProperty = item.Property("deny");
     if (denyProperty != null)
     {
         denyProperty
             .Values()
             .Select(x => (Access)Enum.Parse(typeof(Access), x.ToString(), true))
             .For(x => denied.Add(x));
     }
     ClaimType claimType = (ClaimType)Enum.Parse(typeof(ClaimType), type, true);
     List<Claim> claims = new List<Claim>();
     allowed.For(x => claims.Add(new Claim(Permission.Allow, x, claimType, sid)));
     denied.For(x => claims.Add(new Claim(Permission.Deny, x, claimType, sid)));
     acl.SetInternal(claims);
 }