public static TypeScriptInterfaceDefinition RefactInterface(this TypeScriptClassDefinition classDefinition, ICodeNamingConvention namingConvention = null, params string[] exclusions) { var interfaceDefinition = new TypeScriptInterfaceDefinition(); if (namingConvention == null) { namingConvention = new TypeScriptNamingConvention(); } interfaceDefinition.Name = namingConvention.GetInterfaceName(classDefinition.Name); interfaceDefinition.Namespaces = classDefinition.Namespaces; foreach (var @event in classDefinition.Events.Where(item => item.AccessModifier == AccessModifier.Public && !exclusions.Contains(item.Name))) { interfaceDefinition.Events.Add(new EventDefinition(@event.Type, @event.Name)); } foreach (var property in classDefinition.Properties.Where(item => item.AccessModifier == AccessModifier.Public && !exclusions.Contains(item.Name))) { interfaceDefinition.Properties.Add(new PropertyDefinition(property.Type, property.Name) { IsAutomatic = property.IsAutomatic, IsReadOnly = property.IsReadOnly }); } foreach (var method in classDefinition.Methods.Where(item => item.AccessModifier == AccessModifier.Public && !exclusions.Contains(item.Name))) { interfaceDefinition.Methods.Add(new MethodDefinition(method.Type, method.Name, method.Parameters.ToArray())); } return(interfaceDefinition); }
public static void AddImport(this TypeScriptInterfaceDefinition objectDefinition, string type, string from) => objectDefinition.Namespaces.Add(string.Format("{{ {0} }} from \"{1}\"", type, from));
public static void AddImport(this TypeScriptInterfaceDefinition objectDefinition, IEnumerable <string> types, string from) => objectDefinition.Namespaces.Add(string.Format("{{ {0} }} from \"{1}\"", string.Join(", ", types), from));