/// <summary> /// Creates a Typescript type union /// </summary> /// <param name="name">The name used for the type</param> /// <param name="directory">The <see cref="TsDir" /> where the resulting file should be placed.</param> /// <param name="filters">The filters used to find the types used in the union.</param> /// <returns></returns> public UnionTypeDefinition UnionType(string name, TsDir directory = null, params Func <Type, bool>[] filters) { var typesForUnion = new List <TypedFile>(); foreach (var type in _allTypes.Where(t => filters.Any(f => f(t)))) { TypedFile typeForUnion; if (InterfaceFiles.ContainsKey(type)) { typeForUnion = Interface(type); } else if (ClassFiles.ContainsKey(type)) { typeForUnion = Class(type); } else if (type.IsInterface) { typeForUnion = Interface(type); } else { typeForUnion = Class(type); } typesForUnion.Add(typeForUnion); } return(UnionType(name, directory, typesForUnion.ToArray())); }
public ClassFile Class(Type type) { var t = type.UnderlyingType(); if (!ClassFiles.ContainsKey(t)) { ClassFiles[t] = new ClassFile(this, t, RootDir); } return(ClassFiles[t]); }