예제 #1
0
        public static StructuralTypeDef FromJson(Json.ArrayExpression type)
        {
            var n = type.ElementCount - 1;

            var stms = new AnonymousStructuralTypeMember[n];

            for (var i = 0; i < n; i++)
            {
                var element = type.GetElement(i + 1);
                var member  = AnonymousStructuralTypeMember.FromJson(element);
                stms[i] = member;
            }

            return(new AnonymousStructuralTypeDef(stms));
        }
예제 #2
0
        private TypeDef AddTypeAnonymousStructural(StructuralTypeSlim type, ReadOnlyCollection <TypeSlim> genericArguments)
        {
            var properties = type.Properties;
            var count      = properties.Count;

            var members = new AnonymousStructuralTypeMember[count];

            for (var i = 0; i < count; i++)
            {
                var property = properties[i];
                var member   = new AnonymousStructuralTypeMember {
                    Name = property.Name, Type = AddType(property.PropertyType, genericArguments), IsKey = !property.CanWrite
                };
                members[i] = member;
            }

            return(new AnonymousStructuralTypeDef(members));
        }