private bool TryGetMember(CodeProperty property, TypeContext typeContext, out TypeScriptInterfaceMember member) { member = null; CodeFunction getter = property.Getter; if (getter == null || property.Name == "this") { return(false); } TypeScriptMemberAttributeValues values = GetMemberValues(property, typeContext); member = new TypeScriptInterfaceMember { Name = values.Name, FullName = property.FullName, Optional = values.Optional, Ignore = values.Ignore, Type = (string.IsNullOrWhiteSpace(values.Type)) ? typeContext.GetTypeScriptType(getter.Type) : new InterfaceType(values.Type) }; if (member.Name == null) { // The property is not explicit marked with TypeScriptMemberAttribute if (property.Access != vsCMAccess.vsCMAccessPublic) { // remove non-public default properties return(false); } member.Name = property.Name; } if (member.Ignore) { return(false); } if (values.CamelCase && values.Name == null) { member.Name = member.Name.Substring(0, 1).ToLowerInvariant() + member.Name.Substring(1); } return(true); }
private bool TryGetEnumMember(CodeVariable variable, TypeContext typeContext, int index, out TypeScriptEnumMember member) { TypeScriptMemberAttributeValues values = GetMemberValues(variable, typeContext); try { member = new TypeScriptEnumMember { Name = values.Name, FullName = variable.FullName, Ignore = values.Ignore, Value = variable.InitExpression == null ? index : Int32.Parse(variable.InitExpression.ToString()), }; } catch (Exception e) { throw new Exception(string.Format("{0}: {1}", variable.FullName, e.Message), e); } if (member.Name == null) { // The property is not explicit marked with TypeScriptMemberAttribute if (variable.Access != vsCMAccess.vsCMAccessPublic) { // remove non-public default properties return(false); } member.Name = variable.Name; } if (member.Ignore) { return(false); } if (values.CamelCase && values.Name == null) { member.Name = member.Name.Substring(0, 1).ToLowerInvariant() + member.Name.Substring(1); } return(true); }