示例#1
0
        private static IList <IDictionary <string, object> > Constraints(TokenRead tokens, SchemaRead schemaRead, Anonymizer anonymizer)
        {
            IList <IDictionary <string, object> > constraints = new List <IDictionary <string, object> >();

            SilentTokenNameLookup tokenLookup = new SilentTokenNameLookup(tokens);

            IEnumerator <ConstraintDescriptor> iterator = schemaRead.ConstraintsGetAll();

            while (iterator.MoveNext())
            {
                ConstraintDescriptor         constraint = iterator.Current;
                EntityType                   entityType = constraint.Schema().entityType();
                IDictionary <string, object> data       = new Dictionary <string, object>();

                data["properties"] = Map(constraint.Schema().PropertyIds, id => anonymizer.PropertyKey(tokenLookup.PropertyKeyGetName(id), id));
                data["type"]       = ConstraintType(constraint);
                int entityTokenId = constraint.Schema().EntityTokenIds[0];

                switch (entityType.innerEnumValue)
                {
                case EntityType.InnerEnum.NODE:
                    data["label"] = anonymizer.Label(tokenLookup.LabelGetName(entityTokenId), entityTokenId);
                    constraints.Add(data);
                    break;

                case EntityType.InnerEnum.RELATIONSHIP:
                    data["relationshipType"] = anonymizer.RelationshipType(tokenLookup.RelationshipTypeGetName(entityTokenId), entityTokenId);
                    constraints.Add(data);
                    break;

                default:
                    break;
                }
            }

            return(constraints);
        }