Ejemplo n.º 1
0
        /// <summary>
        /// Append the name for typeof operator.
        /// </summary>
        /// <param name="typeName">A <see cref="StringBuilder"/> to append the name.</param>
        /// <param name="context"></param>
        protected override void AppendTypeOfNameToCore(StringBuilder typeName, IFormatterContext context)
        {
            var offset = typeName.Length;

            Parent.AppendTypeOfNameTo(typeName, context);
            if (offset < typeName.Length)
            {
                typeName.Append('.');
            }
            typeName.Append(CoreName);
            if (IsConstructed)
            {
                typeName.Append('<');
                var args = GenericTypeArgumentNames;
                args[0].AppendTypeOfNameTo(typeName, context);
                for (int i = 1; i < args.Length; i++)
                {
                    typeName.Append(", ");
                    args[i].AppendTypeOfNameTo(typeName, context);
                }
                typeName.Append('>');
            }
            else
            {
                typeName.Append(GetTypeOfNameTypeArgumentsNames(GenericTypeArgumentNames.Length));
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Append the name for cref attribute in document comment.
 /// </summary>
 /// <param name="typeName">A <see cref="StringBuilder"/> to append the name.</param>
 /// <param name="context"></param>
 protected override void AppendCRefNameToCore(StringBuilder typeName, IFormatterContext context)
 {
     if (!_System.IsImported && !_System.IsDeclared)
     {
         typeName.Append("System.");
     }
     typeName.Append("Nullable{");
     UnderlyingTypeName.AppendCRefNameTo(typeName, context);
     typeName.Append('}');
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Gets the name for type of operator.
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public sealed override string GetTypeOfName(IFormatterContext context)
 {
     if (_TypeOfNameContext != context)
     {
         var typeName = new StringBuilder();
         AppendTypeOfNameToCore(typeName, context);
         _TypeOfName        = typeName.ToString();
         _TypeOfNameContext = context;
     }
     return(_TypeOfName);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Append the name for typeof operator.
        /// </summary>
        /// <param name="typeName">A <see cref="StringBuilder"/> to append the name.</param>
        /// <param name="context"></param>
        protected override void AppendTypeOfNameToCore(StringBuilder typeName, IFormatterContext context)
        {
            var offset = typeName.Length;

            Parent.AppendTypeOfNameTo(typeName, context);
            if (offset < typeName.Length)
            {
                typeName.Append('.');
            }
            typeName.Append(Name);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Gets the name for type alias declaration.
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public sealed override string GetAliasName(IFormatterContext context)
 {
     if (_AliasName == null)
     {
         var typeName = new StringBuilder();
         AppendAliasNameToCore(typeName, context);
         _AliasName        = typeName.ToString();
         _AliasNameContext = context;
     }
     return(_AliasName);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Append the name of this object.
 /// </summary>
 /// <param name="typeName">A <see cref="StringBuilder"/> to append the name.</param>
 /// <param name="context"></param>
 public sealed override void AppendNameTo(StringBuilder typeName, IFormatterContext context)
 {
     if (_NameContext != context)
     {
         var offset = typeName.Length;
         AppendNameToCore(typeName, context);
         _Name        = typeName.ToString(offset, typeName.Length - offset);
         _NameContext = context;
     }
     else
     {
         typeName.Append(_Name);
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Begin namespace declaration with specified name.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public IDisposable BeginNamespaceDeclaration(string name)
        {
            var namespaceName = Factory.GetNamespaceName(
                Context.NamespaceName.IsGlobal
                ? name
                : (new StringBuilder(Context.NamespaceName.FullName.Length + 1 + name.Length).Append(Context.NamespaceName.FullName).Append('.').Append(name).ToString()));
            var context  = new NamespaceDeclarationFormatterContext(Context, namespaceName);
            var declared = context.NamespaceName;

            do
            {
                declared.IsDeclared = true;
            } while ((declared = declared.Parent) != Context.NamespaceName);
            Context = context;
            return(new NamespaceDeclaration(this));
        }
Ejemplo n.º 8
0
        /// <summary></summary>
        internal void EndNamespace()
        {
            foreach (var imported in Context.ImportedNamespaceNames)
            {
                imported.EndImport();
            }
            var context = Context;

            Context = context.Parent;
            var declared = context.NamespaceName;

            do
            {
                declared.IsDeclared = false;
            } while ((declared = declared.Parent) != Context.NamespaceName);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Append the name of this object.
 /// </summary>
 /// <param name="typeName">A <see cref="StringBuilder"/> to append the name.</param>
 /// <param name="context"></param>
 public void AppendNameTo(StringBuilder typeName, IFormatterContext context)
 {
     if (IsImported)
     {
         return;
     }
     if (CachedContext != context)
     {
         if (context.NamespaceName.IsGlobal || Root != context.NamespaceName.Root)
         {
             CachedName = FullName;
         }
         else if (IsDeclared)
         {
             CachedName = string.Empty;
         }
         else
         {
             var anscestor = Parent;
             for (; ; anscestor = anscestor.Parent)
             {
                 if (anscestor.IsDeclared)
                 {
                     CachedName = FullName.Substring(anscestor.FullName.Length + 1);
                     break;
                 }
                 else if (anscestor.IsGlobal)
                 {
                     CachedName = FullName;
                     break;
                 }
             }
         }
         CachedContext = context;
         typeName.Append(CachedName);
     }
     else
     {
         typeName.Append(CachedName);
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Append the name for cref attribute in document comment.
        /// </summary>
        /// <param name="typeName">A <see cref="StringBuilder"/> to append the name.</param>
        /// <param name="context"></param>
        protected override void AppendCRefNameToCore(StringBuilder typeName, IFormatterContext context)
        {
            var offset = typeName.Length;

            Parent.AppendCRefNameTo(typeName, context);
            if (offset < typeName.Length)
            {
                typeName.Append('.');
            }
            typeName.Append(CoreName);
            typeName.Append('{');
            var args = GenericTypeArgumentNames;

            args[0].AppendCRefNameTo(typeName, context);
            for (int i = 1; i < args.Length; i++)
            {
                typeName.Append(", ");
                args[i].AppendCRefNameTo(typeName, context);
            }
            typeName.Append('}');
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Append the name for typeof operator.
 /// </summary>
 /// <param name="typeName">A <see cref="StringBuilder"/> to append the name.</param>
 /// <param name="context"></param>
 public override void AppendTypeOfNameTo(StringBuilder typeName, IFormatterContext context)
 {
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Append the name of this object.
 /// </summary>
 /// <param name="typeName">A <see cref="StringBuilder"/> to append the name.</param>
 /// <param name="context"></param>
 public override void AppendNameTo(StringBuilder builder, IFormatterContext context)
 {
     builder.Append(Name);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Append the name for cref attribute in document comment.
 /// </summary>
 /// <param name="typeName">A <see cref="StringBuilder"/> to append the name.</param>
 /// <param name="context"></param>
 public override void AppendCRefNameTo(StringBuilder typeName, IFormatterContext context)
 {
     typeName.Append(Name);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Gets the name for type of operator.
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public override string GetTypeOfName(IFormatterContext context)
 => string.Empty;
Ejemplo n.º 15
0
 /// <summary>
 /// Gets the name for cref attribute in document comment.
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public abstract string GetCRefName(IFormatterContext context);
Ejemplo n.º 16
0
 /// <summary>
 /// Append the name for cref attribute in document comment.
 /// </summary>
 /// <param name="typeName">A <see cref="StringBuilder"/> to append the name.</param>
 /// <param name="context"></param>
 public void AppendCRefNameTo(StringBuilder typeName, IFormatterContext context)
 {
     AppendNameTo(typeName, context);
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Append the name for typeof operator.
 /// </summary>
 /// <param name="typeName">A <see cref="StringBuilder"/> to append the name.</param>
 /// <param name="context"></param>
 protected override void AppendTypeOfNameToCore(StringBuilder typeName, IFormatterContext context)
 {
     ElementTypeName.AppendTypeOfNameTo(typeName, context);
     typeName.Append('*');
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Append the name for typeof operator.
 /// </summary>
 /// <param name="typeName">A <see cref="StringBuilder"/> to append the name.</param>
 /// <param name="context"></param>
 protected override void AppendTypeOfNameToCore(StringBuilder typeName, IFormatterContext context)
 {
     UnderlyingTypeName.AppendTypeOfNameTo(typeName, context);
     typeName.Append('?');
 }
Ejemplo n.º 19
0
 public override string GetAliasName(IFormatterContext context)
 => Type.FullName;
Ejemplo n.º 20
0
 /// <summary>
 /// Append the name for the type alias declaration.
 /// </summary>
 /// <param name="typeName">A <see cref="StringBuilder"/> to append the name.</param>
 /// <param name="context"></param>
 protected override void AppendAliasNameToCore(StringBuilder typeName, IFormatterContext context)
 {
     typeName.Append("System.Nullable<");
     UnderlyingTypeName.AppendAliasNameTo(typeName, context);
     typeName.Append('>');
 }
Ejemplo n.º 21
0
 public NamespaceDeclarationFormatterContext(IFormatterContext parent, INamespaceName namespaceName)
 {
     Parent        = parent;
     NamespaceName = namespaceName;
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Gets the name for type alias declaration.
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public abstract string GetAliasName(IFormatterContext context);
Ejemplo n.º 23
0
 /// <summary>
 /// Append the name for typeof operator.
 /// </summary>
 /// <param name="typeName">A <see cref="StringBuilder"/> to append the name.</param>
 /// <param name="context"></param>
 protected abstract void AppendTypeOfNameToCore(StringBuilder typeName, IFormatterContext context);
Ejemplo n.º 24
0
 /// <summary>
 /// Gets the name of this object.
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public override string GetName(IFormatterContext context)
 => Name;
Ejemplo n.º 25
0
 public override string GetTypeOfName(IFormatterContext context)
 => PrimitiveName;
Ejemplo n.º 26
0
 /// <summary>
 /// Append the name for the type alias declaration.
 /// </summary>
 /// <param name="typeName">A <see cref="StringBuilder"/> to append the name.</param>
 /// <param name="context"></param>
 protected override void AppendAliasNameToCore(StringBuilder typeName, IFormatterContext context)
 {
     ElementTypeName.AppendAliasNameTo(typeName, context);
     typeName.Append(Ranks);
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Append the name for the type alias declaration.
 /// </summary>
 /// <param name="typeName">A <see cref="StringBuilder"/> to append the name.</param>
 /// <param name="context"></param>
 public void AppendAliasNameTo(StringBuilder typeName, IFormatterContext context)
 {
     typeName.Append(FullName);
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Append the name for typeof operator.
 /// </summary>
 /// <param name="typeName">A <see cref="StringBuilder"/> to append the name.</param>
 /// <param name="context"></param>
 public abstract void AppendTypeOfNameTo(StringBuilder typeName, IFormatterContext context);
Ejemplo n.º 29
0
 public override void AppendTypeOfNameTo(StringBuilder typeName, IFormatterContext context)
 {
     typeName.Append(PrimitiveName);
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Gets the name for type of operator.
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public abstract string GetTypeOfName(IFormatterContext context);