예제 #1
0
        /// <summary>
        /// Create new tsClass into tsModule with members from jsClass meta information
        /// </summary>
        private Class BuildClass(Module tsModule, jsduck.Class jsClass)
        {
            Dictionary <string, HashSet <string> > jsHtmlParams;

            string[] jsHtmlComments;

            // Extract class document
            jsHtmlComments = JsDoc.ExtractComments(jsClass.Href, null, jsClass.docs, out jsHtmlParams);
            // Create class
            var tsClass = tsModule.Add(new Class(jsClass.name, jsHtmlComments, jsHtmlParams, jsClass.singleton ?? false, jsClass, this.JsClassMap, jsClass.extends));

            Console.WriteLine($@"[{jsClass.OwnMembers.Length}]");
            foreach (var jsMember in jsClass.OwnMembers)
            {
                // Extract member document
                jsHtmlComments = JsDoc.ExtractComments(jsClass.Href + '-' + jsMember.id, jsMember.id, jsClass.docs, out jsHtmlParams);
                // Create specific member
                Member member;
                switch (jsMember.tagname)
                {
                case PropertyMember.TAG:
                    member = new PropertyMember(jsMember.name, jsHtmlComments, jsHtmlParams, tsClass, jsMember, this.JsClassMap);
                    break;

                case MethodMember.TAG:
                    member = new MethodMember(jsMember.name, jsHtmlComments, jsHtmlParams, tsClass, jsMember, this.JsClassMap);
                    break;

                case ConfigMember.TAG:
                    member = new ConfigMember(jsMember.name, jsHtmlComments, jsHtmlParams, tsClass, jsMember, this.JsClassMap);
                    tsClass.MemberConfigs.Add(member.Name, member);
                    break;

                case EventMember.TAG:
                    member = new EventMember(jsMember.name, jsHtmlComments, jsHtmlParams, tsClass, jsMember, this.JsClassMap);
                    break;

                default:
                    throw new NotImplementedException(jsMember.tagname);
                }
                if (!tsClass.Members.ContainsKey(member.Name))
                {
                    tsClass.Members.Add(member.Name, member);
                }
                else
                {
                    switch (jsMember.tagname)
                    {
                    case PropertyMember.TAG:
                    case MethodMember.TAG:
                        if (!tsClass.MemberExs.ContainsKey(member.Name))
                        {
                            tsClass.MemberExs.Add(member.Name, new HashSet <Member>()
                            {
                                tsClass.Members[member.Name]
                            });
                        }
                        else
                        {
                            tsClass.MemberExs[member.Name].Add(tsClass.Members[member.Name]);
                        }
                        tsClass.Members[member.Name] = member;
                        break;

                    case ConfigMember.TAG:
                    case EventMember.TAG:
                        if (!tsClass.MemberExs.ContainsKey(member.Name))
                        {
                            tsClass.MemberExs.Add(member.Name, new HashSet <Member>()
                            {
                                member
                            });
                        }
                        else
                        {
                            tsClass.MemberExs[member.Name].Add(member);
                        }
                        break;

                    default:
                        throw new NotImplementedException(jsMember.tagname);
                    }
                }
            }

            return(tsClass);
        }
예제 #2
0
 public EventMember(EventMember member, Class cls)
     : base(member, cls)
 {
 }