예제 #1
0
        public static TsClass CreateFrom <T>(TypeResolver typeResolver, ITsConfigurationProvider configurationProvider)
        {
            var @class = new TsClass((TsBasicType)typeResolver.ResolveType(typeof(T)));

            var classType     = typeof(T);
            var classTypeInfo = classType.GetTypeInfo();

            @class.Interfaces = classTypeInfo.ImplementedInterfaces
                                .Except(classTypeInfo.ImplementedInterfaces.SelectMany(@interface => @interface.GetTypeInfo().ImplementedInterfaces))
                                .Select(@interface => typeResolver.ResolveType(@interface))
                                .Where(interfaceType => interfaceType != null)
                                .ToList();

            //TODO: why we filter ValueType in V1?
            if (classTypeInfo.BaseType != null && classTypeInfo.BaseType != typeof(object) && classTypeInfo.BaseType != typeof(ValueType))
            {
                @class.BaseType = typeResolver.ResolveType(classTypeInfo.BaseType);
            }

            @class.Properties = classTypeInfo.DeclaredProperties
                                .Select(pi => TsProperty.CreateFrom(pi, typeResolver, configurationProvider))
                                .ToList();

            return(@class);
        }
예제 #2
0
        public static TsProperty CreateFrom(PropertyInfo propertyInfo, TypeResolver resolver, ITsConfigurationProvider configurationProvider)
        {
            var property = new TsProperty();

            var propertyConfiguration = configurationProvider.GetMemberConfiguration(propertyInfo);

            property.Name = propertyConfiguration.Name;

            property.Type = resolver.ResolveType(propertyInfo.PropertyType);

            return(property);
        }