Esempio n. 1
0
 public TsType Visit(ITypeDefinition ce)
 {
     var name = SkJs.GetEntityJsName(ce);
     var ce2 = new TsType
     {
         Name = name, Kind=(ce.IsInterface() || ce.IsDelegate()) ? TsTypeKind.Interface :  TsTypeKind.Class,
         TypeParameters = ce.TypeParameters.Select(Visit).ToList()
     };
     if (name.Contains("."))
     {
         var pair = name.SplitAt(name.LastIndexOf("."), true);
         ce2.Name = pair[1];
         ce2.ModuleName = pair[0];
         ce2.IsModuleExport = true;
     }
     if (ce.IsDelegate())
     {
         var func = Visit(ce.GetDelegateInvokeMethod());
         //func.IsCallSignature = true;
         func.Name = null;
         ce2.Members.Add(func);
     }
     else
     {
         var members = TypeConverter.ClrConverter.GetMembersToExport(ce);
         var members2 = members.Select(Visit).Where(t => t != null).ToList();
         ce2.Members.AddRange(members2);
         if (ce2.Kind == TsTypeKind.Class)
         {
             ce2.Members.OfType<TsFunction>().Where(t => !t.IsConstructor || !t.Type.IsNullOrVoid()).ForEach(t => t.Body = "return null;");
             ce2.Members.OfType<TsFunction>().Where(t => t.IsConstructor).ForEach(t => t.Body = "");
         }
     }
     return ce2;
 }
Esempio n. 2
0
 public void VisitType(TsType ce)
 {
     _Writer
     .WriteIf(ce.ModuleName != null, "module " + ce.ModuleName + "\n{\n")
     .WriteIf(ce.IsModuleExport, "export ")
     .Write(ce.Kind == TsTypeKind.Interface ? "interface " : "class ")
     .Write(ce.Name)
     .VisitEachJoinIfNotNullOrEmpty(ce.TypeParameters, "<", ",", ">")
     .Write("\n{\n").VisitEach(ce.Members).Write("}\n")
     .WriteIf(ce.ModuleName != null, "\n}\n")
     ;
 }
Esempio n. 3
0
 public void VisitType(TsType ce)
 {
     _Writer
         .WriteIf(ce.ModuleName != null, "module "+ce.ModuleName+"\n{\n")
         .WriteIf(ce.IsModuleExport, "export ")
         .Write(ce.Kind == TsTypeKind.Interface ? "interface " : "class ")
         .Write(ce.Name)
         .VisitEachJoinIfNotNullOrEmpty(ce.TypeParameters, "<", ",", ">")
         .Write("\n{\n").VisitEach(ce.Members).Write("}\n")
         .WriteIf(ce.ModuleName != null, "\n}\n")
         ;
 }