public TypeScriptType ReferenceFrom(TypeScriptUnit targetUnit, ITypeGenerator typeGenerator) { var typeReference = typeGenerator.ResolveType(type.GetGenericTypeDefinition()).ReferenceFrom(targetUnit, typeGenerator); var arguments = new List <TypeScriptType>(); foreach (var argument in type.GetGenericArguments()) { var targetType = typeGenerator.ResolveType(argument).ReferenceFrom(targetUnit, typeGenerator); arguments.Add(targetType is INullabilityWrapperType nullabilityType ? nullabilityType.InnerType : targetType); } return(new TypeScriptGenericTypeReference(typeReference as TypeScriptTypeReference, arguments.ToArray())); }
public TypeScriptType ReferenceFrom(TypeScriptUnit targetUnit, ITypeGenerator typeGenerator, IAttributeProvider?attributeProvider) { var itemType = typeGenerator.ResolveType(elementType).ReferenceFrom(targetUnit, typeGenerator, null); var resultType = TypeScriptGeneratorHelpers.BuildTargetNullableTypeByOptions(itemType, CanItemBeNull(attributeProvider), options); return(new TypeScriptArrayType(resultType)); }
public TypeScriptType ReferenceFrom(TypeScriptUnit targetUnit, ITypeGenerator typeGenerator) { var itemTypeScriptType = typeGenerator.ResolveType(itemType).ReferenceFrom(targetUnit, typeGenerator); return(useGlobalNullable ? (TypeScriptType) new TypeScriptNullableType(itemTypeScriptType) : new TypeScriptOrNullType(itemTypeScriptType)); }
public override void BuildDefinition(ITypeGenerator typeGenerator) { var types = Type.Assembly .GetTypes() .Where(x => x != Type && Type.IsAssignableFrom(x) && (useAbstractChildren || !x.IsAbstract)) .Select(x => typeGenerator.ResolveType(x).ReferenceFrom(Unit, typeGenerator)) .ToArray(); Declaration.Definition = new TypeScriptUnionType(types); }
public override void BuildDefinition(ITypeGenerator typeGenerator) { var types = typeGenerator.TypesProvider .GetAssemblyTypes(Type) .Where(x => !x.Equals(Type) && Type.IsAssignableFrom(x) && (useAbstractChildren || !x.IsAbstract)) .Select(x => typeGenerator.ResolveType(x).ReferenceFrom(Unit, typeGenerator, null)) .ToArray(); Declaration.Definition = new TypeScriptUnionType(types); }
public override void Initialize(ITypeGenerator typeGenerator) { Declaration = CreateComplexTypeScriptDeclarationWithoutDefinition(Type); Unit.Body.Add(new TypeScriptExportTypeStatement { Declaration = Declaration }); if (Type.BaseType != typeof(object) && Type.BaseType != typeof(ValueType) && Type.BaseType != typeof(MarshalByRefObject) && Type.BaseType != null) { typeGenerator.ResolveType(Type.BaseType); } }
public TypeScriptType ReferenceFrom(TypeScriptUnit targetUnit, ITypeGenerator typeGenerator, IAttributeProvider?attributeProvider) { var typeReference = typeGenerator.ResolveType(type.GetGenericTypeDefinition()).ReferenceFrom(targetUnit, typeGenerator, null); var arguments = new List <TypeScriptType>(); var nullableIndex = 1; foreach (var argument in type.GetGenericArguments()) { var targetType = typeGenerator.ResolveType(argument).ReferenceFrom(targetUnit, typeGenerator, null); if (options.NullabilityMode == NullabilityMode.NullableReference) { var isNullable = TypeScriptGeneratorHelpers.NullableReferenceCanBeNull(attributeProvider, argument, nullableIndex); nullableIndex += TypeScriptGeneratorHelpers.GetGenericArgumentsToSkip(argument); arguments.Add(TypeScriptGeneratorHelpers.BuildTargetNullableTypeByOptions(targetType, !argument.IsValueType && isNullable, options)); } else { arguments.Add(targetType is INullabilityWrapperType nullabilityType ? nullabilityType.InnerType : targetType); } } return(new TypeScriptGenericTypeReference((TypeScriptTypeReference)typeReference, arguments.ToArray())); }
public TypeScriptType ReferenceFrom(TypeScriptUnit targetUnit, ITypeGenerator typeGenerator) { var keyTypeScriptType = typeGenerator.ResolveType(keyType).ReferenceFrom(targetUnit, typeGenerator); var valueTypeScriptType = typeGenerator.ResolveType(valueType).ReferenceFrom(targetUnit, typeGenerator); return(new TypeScriptTypeDefintion { Members = { new TypeScriptTypePropertyGetterDeclaration { Argument = new TypeScriptArgumentDeclaration { Name = "key", Type = keyTypeScriptType, }, ResultType = valueTypeScriptType, Optional = true, } } }); }
public override void Initialize(ITypeGenerator typeGenerator) { Declaration = CreateComplexTypeScriptDeclarationWithoutDefinition(Type); Unit.Body.Add(new TypeScriptExportTypeStatement { Declaration = Declaration }); var baseType = Type.BaseType; if (baseType != null && !baseType.Equals(TypeInfo.From <object>()) && !baseType.Equals(TypeInfo.From <ValueType>()) && !baseType.Equals(TypeInfo.From <MarshalByRefObject>())) { typeGenerator.ResolveType(baseType); } }
private TypeScriptType GetValueType(TypeScriptUnit targetUnit, ITypeGenerator typeGenerator, IAttributeProvider?attributeProvider) { var value = typeGenerator.ResolveType(valueType).ReferenceFrom(targetUnit, typeGenerator, null); return(MaybeNull(valueType, value, attributeProvider, 1 + TypeScriptGeneratorHelpers.GetGenericArgumentsToSkip(keyType))); }
private TypeScriptType GetKeyType(TypeScriptUnit targetUnit, ITypeGenerator typeGenerator, IAttributeProvider?attributeProvider) { var key = typeGenerator.ResolveType(keyType).ReferenceFrom(targetUnit, typeGenerator, null); return(MaybeNull(keyType, key, attributeProvider, 1)); }
public TypeScriptType ReferenceFrom(TypeScriptUnit targetUnit, ITypeGenerator typeGenerator) { var itemType = typeGenerator.ResolveType(elementType).ReferenceFrom(targetUnit, typeGenerator); return(new TypeScriptArrayType(itemType)); }
public static TypeScriptType BuildAndImportType(this ITypeGenerator typeGenerator, TypeScriptUnit typeScriptUnit, ITypeInfo type) { return(typeGenerator.ResolveType(type).ReferenceFrom(type, typeScriptUnit, typeGenerator)); }