示例#1
0
        public string GetReferencedName(DeclarationBase type)
        {
            string result;

            if (_cache.TryGetValue(type, out result))
            {
                return(result);
            }
            var m = FindModule(type);

            if (m != null)
            {
                result = m.Item1;
                if (!String.IsNullOrEmpty(result))
                {
                    result = result + ".";
                }
                result = result + type.Name;
            }
            else
            {
                result = GetFailedName(type.Name);
            }
            _cache[type] = result;
            return(result);
        }
示例#2
0
 public override void VisitGenericParameters(DeclarationBase decl)
 {
     if (decl.IsGeneric)
     {
         Formatter.Write("<");
         base.VisitGenericParameters(decl);
         Formatter.Write(">");
     }
 }
示例#3
0
 public static IEnumerable <TypescriptTypeReference> GetExtends(this DeclarationBase decl)
 {
     if (decl is InterfaceType)
     {
         return(((InterfaceType)decl).ExtendsTypes);
     }
     else if (decl is ClassType)
     {
         return((new[] { ((ClassType)decl).Extends }).Where(x => x != null));
     }
     else
     {
         throw new NotImplementedException("Cannot get extends from " + decl);
     }
 }
示例#4
0
 public void Generate(DeclarationBase decl)
 {
     if (decl is ClassType)
     {
         Generate((ClassType)decl);
     }
     else if (decl is InterfaceType)
     {
         Generate((InterfaceType)decl);
     }
     else
     {
         throw new ArgumentOutOfRangeException();
     }
 }
示例#5
0
 public DeclarationModuleElement(DeclarationBase decl)
 {
     Declaration = decl;
 }
示例#6
0
 private void GenerateReference(DeclarationBase type)
 {
     Formatter.Write(NameResolver.GetReferencedName(type));
 }