コード例 #1
0
        public TypeScriptType BuildAndImportType(TypeScriptUnit targetUnit, IAttributeProvider?attributeProvider, ITypeInfo typeInfo)
        {
            var(isNullable, resultType) = TypeScriptGeneratorHelpers.ProcessNullable(attributeProvider, typeInfo, Options.NullabilityMode);
            var targetType = GetTypeScriptType(targetUnit, resultType, attributeProvider);

            return(TypeScriptGeneratorHelpers.BuildTargetNullableTypeByOptions(targetType, isNullable, Options));
        }
コード例 #2
0
        public TypeScriptType BuildAndImportType([NotNull] TypeScriptUnit targetUnit, [CanBeNull] ICustomAttributeProvider customAttributeProvider, [NotNull] Type type)
        {
            var(isNullable, resultType) = TypeScriptGeneratorHelpers.ProcessNullable(customAttributeProvider, type, Options.NullabilityMode);
            var targetType = GetTypeScriptType(targetUnit, resultType, customAttributeProvider);

            return(TypeScriptGeneratorHelpers.BuildTargetNullableTypeByOptions(targetType, isNullable, Options));
        }
コード例 #3
0
        private TypeScriptType GetMaybeNullableComplexType(TypeScriptUnit unit, ITypeInfo type, IPropertyInfo property, bool isNullable)
        {
            var propertyType = BuildAndImportType(unit, property, type);

            if (property.PropertyType.IsGenericParameter)
            {
                propertyType = new TypeScriptTypeReference(property.PropertyType.Name);
            }

            return(TypeScriptGeneratorHelpers.BuildTargetNullableTypeByOptions(propertyType, isNullable, Options));
        }
コード例 #4
0
        public TypeScriptTypeMemberDeclaration?ResolveProperty(TypeScriptUnit unit, ITypeInfo typeInfo, IPropertyInfo propertyInfo)
        {
            var customMemberDeclaration = customTypeGenerator.ResolveProperty(unit, this, typeInfo, propertyInfo);

            if (customMemberDeclaration != null)
            {
                return(customMemberDeclaration);
            }

            if (propertyInfo.IsNameDefined(nameof(ContractGeneratorIgnoreAttribute)))
            {
                return(null);
            }

            var(isNullable, trueType) = TypeScriptGeneratorHelpers.ProcessNullable(propertyInfo, propertyInfo.PropertyType, Options.NullabilityMode);
            return(new TypeScriptTypeMemberDeclaration
            {
                Name = propertyInfo.Name.ToLowerCamelCase(),
                Optional = isNullable && Options.EnableOptionalProperties,
                Type = GetMaybeNullableComplexType(unit, trueType, propertyInfo, isNullable),
            });
        }
コード例 #5
0
        public TypeScriptTypeMemberDeclaration ResolveProperty([NotNull] TypeScriptUnit unit, [NotNull] Type type, [NotNull] PropertyInfo property)
        {
            var customMemberDeclaration = customTypeGenerator.ResolveProperty(unit, this, type, property);

            if (customMemberDeclaration != null)
            {
                return(customMemberDeclaration);
            }

            if (property.GetCustomAttributes <ContractGeneratorIgnoreAttribute>().Any())
            {
                return(null);
            }

            var(isNullable, trueType) = TypeScriptGeneratorHelpers.ProcessNullable(property, property.PropertyType, Options.NullabilityMode);
            return(new TypeScriptTypeMemberDeclaration
            {
                Name = property.Name.ToLowerCamelCase(),
                Optional = isNullable && Options.EnableOptionalProperties,
                Type = GetMaybeNullableComplexType(unit, trueType, property, isNullable),
            });
        }