public InterfaceType(string name) { AttributeValues = new TypeScriptInterfaceAttributeValues { Name = name }; }
private string GetInterfaceName(TypeScriptInterfaceAttributeValues attributeValues) { if (!string.IsNullOrEmpty(attributeValues.NamePrefix)) { return(attributeValues.NamePrefix + attributeValues.Name); } return(attributeValues.Name); }
private TypeScriptInterfaceAttributeValues GetAttributeValues( CodeClass codeClass) { TypeScriptInterfaceAttributeValues result = null; CodeAttribute attribute; if (TryGetAttribute( codeClass.Attributes, InterfaceAttributeFullName, out attribute)) { result = this.GetInterfaceValues( codeClass, attribute); } return(result); }
public InterfaceType(TypeScriptInterfaceAttributeValues values) { AttributeValues = values; }
public TypeScriptInterface Build( CodeClass codeClass, TypeContext typeContext) { TypeScriptInterface result = null; TypeScriptInterfaceAttributeValues attributeValues = this.GetAttributeValues(codeClass); if (attributeValues != null) { string moduleName = attributeValues.Module; if (String.IsNullOrEmpty(moduleName) && codeClass.Namespace != null) { moduleName = codeClass.Namespace.FullName; } bool interfaceCreated; result = typeContext.GetOrCreateInterface( moduleName, TypeName.ParseDte(codeClass.FullName), GetInterfaceName(attributeValues), out interfaceCreated); if (!String.IsNullOrEmpty(attributeValues.Extends)) { result.Parent = typeContext.GetLiteralReference(attributeValues.Extends); } else if (codeClass.Bases.Count > 0) { // Getting the first item directly causes problems in unit tests. Get it from an enumerator. IEnumerator enumerator = codeClass.Bases.GetEnumerator(); enumerator.MoveNext(); TypeName parentTypeName = TypeName.ParseDte( ((CodeElement)enumerator.Current).FullName); if (BuilderHelper.IsValidBaseType(parentTypeName)) { result.Parent = typeContext.GetTypeReference( parentTypeName, result); } } result.IndexedType = this.GetIndexedType( result, codeClass, typeContext); Traversal.TraverseProperties( codeClass.Members, (property) => { TypeScriptMember member; if (TryGetMember( result, property, typeContext, out member)) { result.Fields.Add(member); } }); } return(result); }