protected virtual IOption <TypescriptBaseClass> GetBaseClassFor(Type baseType, TypescriptModel model) { if (baseType == typeof(Object)) { return(new None <TypescriptBaseClass>()); } return(new TypescriptBaseClass { Name = NameWithoutGeneric(baseType), GenericArguments = TypescriptTypeCreatorBase.GetGenericTypeArgumentsFor(typeCreator, baseType, model) }.ToOption()); }
public TypescriptType GetTypeFor(Type type, TypescriptModel model) { if (model.knownTypes.ContainsKey(type)) { return(model.knownTypes[type]); } else { var newInterface = new TypescriptInterface { Name = NameWithoutGeneric(type) }; model.knownTypes.Add(type, newInterface.ToTypescriptType()); // TODO: implement inherrited interfaces. newInterface. = GetBaseClassFor(type.BaseType, model); newInterface.Content = new TypescriptInterfaceContentList(GetInterfaceContent(type, model)); newInterface.GenricTypeParameters = TypescriptTypeCreatorBase.GetGenericTypeParametersFor(type); return(newInterface.ToTypescriptType()); } }
public static TypescriptType ClassTypeToTypescriptClass(this Type type, ITypescriptTypeCreator typeCreator, TypescriptModel model) { // TODO Check if type is indeed a class.. if (model.knownTypes.ContainsKey(type)) { return(model.knownTypes[type]); } else { var newClass = new TypescriptClass { Name = type.NameWithoutGeneric() }; model.knownTypes.Add(type, newClass.ToTypescriptType()); newClass.BaseClass = type.BaseType.ToTypescriptBaseClass(model); newClass.Content = type.GetTypescriptProperties(typeCreator, model).ToClassContent(); newClass.GenricTypeParameters = TypescriptTypeCreatorBase.GetGenericTypeParametersFor(type); return(newClass.ToTypescriptType()); } }
public static TypescriptType ClassTypeToTypescriptInterface(this Type type, ITypescriptTypeCreator typeCreator, TypescriptModel model) { // TODO validate parameters. the input hsould be a class type... if (model.knownTypes.ContainsKey(type)) { return(model.knownTypes[type]); } else { var newInterface = new TypescriptInterface { Name = type.NameWithoutGeneric() }; model.knownTypes.Add(type, newInterface.ToTypescriptType()); // TODO: implement inherrited interfaces. newInterface. = GetBaseClassFor(type.BaseType, model); newInterface.BaseType = type.ClassBaseClassAndInterfacesAsBaseInterfaces(typeCreator, model); newInterface.Content = type.GetInterfaceContent(typeCreator, model); newInterface.GenricTypeParameters = TypescriptTypeCreatorBase.GetGenericTypeParametersFor(type); return(newInterface.ToTypescriptType()); } }
public static TypescriptType InterfaceTypeToTypescriptInterface(this Type type, ITypescriptTypeCreator typeCreator, TypescriptModel model) { // TODO Check and refactor this and method below. if (model.knownTypes.ContainsKey(type)) { return(model.knownTypes[type]); } else { var newInterface = new TypescriptInterface { Name = type.NameWithoutGeneric() }; model.knownTypes.Add(type, newInterface.ToTypescriptType()); // TODO: implement inherrited interfaces. newInterface. = GetBaseClassFor(type.BaseType, model); newInterface.BaseType = type.TypescriptImplementedInterfaces(); newInterface.Content = type.GetInterfaceContent(typeCreator, model); newInterface.GenricTypeParameters = TypescriptTypeCreatorBase.GetGenericTypeParametersFor(type); return(newInterface.ToTypescriptType()); } }