Esempio n. 1
0
        private bool TryGetMember(CodeProperty property, TypeContext typeContext, out TypeScriptInterfaceMember member)
        {
            member = null;
            if (property.Access != vsCMAccess.vsCMAccessPublic)
            {
                return(false);
            }

            var getter = property.Getter;

            if (getter == null)
            {
                return(false);
            }

            var values = GetMemberValues(property, typeContext);

            member = new TypeScriptInterfaceMember
            {
                Name     = values.Name ?? property.Name,
                FullName = property.FullName,
                Optional = values.Optional,
                Type     = (string.IsNullOrWhiteSpace(values.Type))
                    ? typeContext.GetTypeScriptType(getter.Type)
                    : new CustomType(values.Type)
            };

            if (values.CamelCase && values.Name == null)
            {
                member.Name = member.Name.Substring(0, 1).ToLowerInvariant() + member.Name.Substring(1);
            }

            return(true);
        }
Esempio n. 2
0
        private bool TryGetMember(CodeProperty property, TypeContext typeContext, out TypeScriptInterfaceMember member)
        {
            member = null;
            if (property.Access != vsCMAccess.vsCMAccessPublic)
            {
                return(false);
            }

            var getter = property.Getter;

            if (getter == null)
            {
                return(false);
            }

            var values = GetMemberValues(property, typeContext);

            string name;

            if (values.Name != null)
            {
                name = values.Name;
            }
            else
            {
                name = property.Name;
                if (name.StartsWith("@"))
                {
                    name = name.Substring(1);
                }
            }

            member = new TypeScriptInterfaceMember
            {
                Name = 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.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 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);
        }
Esempio n. 4
0
        private bool TryGetMember(CodeProperty property, TypeContext typeContext, out TypeScriptInterfaceMember member)
        {
            member = null;
            if (property.Access != vsCMAccess.vsCMAccessPublic)
                return false;

            var getter = property.Getter;
            if (getter == null)
                return false;

            var values = GetMemberValues(property, typeContext);

            string name;
            if (values.Name != null)
            {
                name = values.Name;
            }
            else
            {
                name = property.Name;
                if (name.StartsWith("@"))
                    name = name.Substring(1);
            }

            member = new TypeScriptInterfaceMember
            {
                Name = 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.Ignore)
                return false;

            if (values.CamelCase && values.Name == null)
                member.Name = member.Name.Substring(0, 1).ToLowerInvariant() + member.Name.Substring(1);

            return true;
        }
Esempio n. 5
0
        private bool TryGetMember(CodeProperty property, TypeContext typeContext, out TypeScriptInterfaceMember member)
        {
            member = null;
            if (property.Access != vsCMAccess.vsCMAccessPublic)
                return false;

            var getter = property.Getter;
            if (getter == null)
                return false;

            var values = GetMemberValues(property, typeContext);
            member = new TypeScriptInterfaceMember
            {
                Name = values.Name ?? property.Name,
                FullName = property.FullName,
                Optional = values.Optional,
                Type = (string.IsNullOrWhiteSpace(values.Type))
                    ? typeContext.GetTypeScriptType(getter.Type)
                    : new CustomType(values.Type)
            };

            return true;
        }
Esempio n. 6
0
        private bool TryGetMember(CodeProperty property, TypeContext typeContext, out TypeScriptInterfaceMember member)
        {
            member = null;

            var getter = property.Getter;
            if (getter == null || property.Name == "this")
                return false;

            var values = GetMemberValues(property, typeContext);

            string name;
            if (values.Name != null)
            {
                name = values.Name;
            }
            else
            {
                name = property.Name;
                if (name.StartsWith("@"))
                    name = name.Substring(1);
            }

            member = new TypeScriptInterfaceMember
            {
                Name = name,
                //FullName = property.FullName,
                Optional = values.Optional,
                Ignore = values.Ignore,
                Type = (string.IsNullOrWhiteSpace(values.Type))
                    ? typeContext.GetTypeScriptType(getter.Type)
                    : new InterfaceType(values.Type),
                Comment = property.Comment,
                DocComment = property.DocComment
            };

            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;
        }