private static void WriteAcls(JsonWriter writer, List <Claim> allowed, List <Claim> denied, List <ResetRequest> reset)
        {
            var map = new Dictionary <SidTypeKey, ClaimGroup>();

            allowed.For(x =>
            {
                ClaimGroup group;
                var key = new SidTypeKey {
                    Sid = x.Sid, Type = x.ClaimType
                };
                if (map.TryGetValue(key, out group) == false)
                {
                    group = new ClaimGroup {
                        Sid = x.Sid, Type = x.ClaimType
                    }
                }
                ;
                group.Allowed.Add(x.AccessType);
            });
            denied.For(x =>
            {
                ClaimGroup group;
                var key = new SidTypeKey {
                    Sid = x.Sid, Type = x.ClaimType
                };
                if (map.TryGetValue(key, out group) == false)
                {
                    group = new ClaimGroup {
                        Sid = x.Sid, Type = x.ClaimType
                    }
                }
                ;
                group.Denied.Add(x.AccessType);
            });
            reset.For(x =>
            {
                ClaimGroup group;
                var key = new SidTypeKey {
                    Sid = x.Sid, Type = x.Type
                };
                if (map.TryGetValue(key, out group) == false)
                {
                    group = new ClaimGroup {
                        Sid = x.Sid, Type = x.Type
                    }
                }
                ;
                group.Reset.Add(x.Access);
            });

            writer.WriteStartArray();
            map.Values.For(x =>
            {
                writer.WriteStartObject();
                writer.WriteProperty("sid", x.Sid);
                writer.WriteProperty("type", x.Type.ToString().ToLower());
                if (x.Allowed.Count > 0)
                {
                    writer.WriteArray("allow", x.Allowed.Select(y => y.ToString().ToLower()));
                }
                if (x.Denied.Count > 0)
                {
                    writer.WriteArray("deny", x.Denied.Select(y => y.ToString().ToLower()));
                }
                if (x.Reset.Count > 0)
                {
                    writer.WriteArray("dontcare", x.Reset.Select(y => y.ToString().ToLower()));
                }
                writer.WriteEndObject();
            });
            writer.WriteEndArray();
        }
        private static void WriteAcls(JsonWriter writer, List<Claim> allowed, List<Claim> denied, List<ResetRequest> reset)
        {
            var map = new Dictionary<SidTypeKey, ClaimGroup>();
            allowed.For(x =>
            {
                ClaimGroup group;
                var key = new SidTypeKey { Sid = x.Sid, Type = x.ClaimType };
                if (map.TryGetValue(key, out group) == false)
                    group = new ClaimGroup { Sid = x.Sid, Type = x.ClaimType };
                group.Allowed.Add(x.AccessType);
            });
            denied.For(x =>
            {
                ClaimGroup group;
                var key = new SidTypeKey { Sid = x.Sid, Type = x.ClaimType };
                if (map.TryGetValue(key, out group) == false)
                    group = new ClaimGroup { Sid = x.Sid, Type = x.ClaimType };
                group.Denied.Add(x.AccessType);
            });
            reset.For(x =>
            {
                ClaimGroup group;
                var key = new SidTypeKey { Sid = x.Sid, Type = x.Type };
                if (map.TryGetValue(key, out group) == false)
                    group = new ClaimGroup { Sid = x.Sid, Type = x.Type };
                group.Reset.Add(x.Access);
            });

            writer.WriteStartArray();
            map.Values.For(x =>
            {
                writer.WriteStartObject();
                writer.WriteProperty("sid", x.Sid);
                writer.WriteProperty("type", x.Type.ToString().ToLower());
                if (x.Allowed.Count > 0)
                    writer.WriteArray("allow", x.Allowed.Select(y => y.ToString().ToLower()));
                if (x.Denied.Count > 0)
                    writer.WriteArray("deny", x.Denied.Select(y => y.ToString().ToLower()));
                if (x.Reset.Count > 0)
                    writer.WriteArray("dontcare", x.Reset.Select(y => y.ToString().ToLower()));
                writer.WriteEndObject();
            });
            writer.WriteEndArray();
        }