Exemplo n.º 1
0
        /// <summary>
        ///     Gets the <see cref="NRTypeParameter" /> as a C# string.
        /// </summary>
        /// <param name="nrTypeParameter">The <see cref="NRTypeParameter" /> to convert.</param>
        /// <returns>The <see cref="NRTypeParameter" /> as a string.</returns>
        public static string Declaration(this NRTypeParameter nrTypeParameter)
        {
            if (!nrTypeParameter.IsStruct && !nrTypeParameter.IsClass && (nrTypeParameter.BaseTypes.Count <= 0) && !nrTypeParameter.IsConstructor && !nrTypeParameter.IsIn && !nrTypeParameter.IsOut)
            {
                return("");
            }

            StringBuilder result = new StringBuilder(" where " + nrTypeParameter.Name + " : ");

            if (nrTypeParameter.IsStruct)
            {
                result.Append("struct, ");
            }
            else if (nrTypeParameter.IsClass)
            {
                result.Append("class, ");
            }
            foreach (NRTypeUsage baseType in nrTypeParameter.BaseTypes)
            {
                result.Append(baseType.Declaration( ) + ", ");
            }
            if (nrTypeParameter.IsConstructor)
            {
                result.Append("new(), ");
            }
            result.Length -= 2;

            return(result.ToString( ));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Visit a <see cref="NRTypeParameter"/>.
        /// </summary>
        /// <param name="nrTypeParameter">The <see cref="NRTypeParameter"/> to visit.</param>
        public void Visit(NRTypeParameter nrTypeParameter)
        {
            if (!nrTypeParameter.IsStruct && !nrTypeParameter.IsClass && nrTypeParameter.BaseTypes.Count <= 0 && !nrTypeParameter.IsConstructor && !nrTypeParameter.IsIn && !nrTypeParameter.IsOut)
            {
                return;
            }

            StringBuilder result = new StringBuilder(" where " + nrTypeParameter.Name + " :");

            if (nrTypeParameter.IsStruct)
            {
                result.Append(" struct, ");
            }
            else if (nrTypeParameter.IsClass)
            {
                result.Append(" class, ");
            }
            foreach (NRTypeUsage baseType in nrTypeParameter.BaseTypes)
            {
                result.Append(" " + baseType.Name + ", ");
            }
            if (nrTypeParameter.IsConstructor)
            {
                result.Append(" new(), ");
            }
            result.Length -= 2;
            Output(result.ToString(), 0);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Visit a <see cref="NRTypeParameter"/>.
        /// </summary>
        /// <param name="nrTypeParameter">The <see cref="NRTypeParameter"/> to visit.</param>
        public void Visit(NRTypeParameter nrTypeParameter)
        {
            string declaration = nrTypeParameter.Declaration();

            if (!string.IsNullOrEmpty(declaration))
            {
                OutputLine(declaration);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Visit a <see cref="NRTypeParameter"/>.
 /// </summary>
 /// <param name="nrTypeParameter">The <see cref="NRTypeParameter"/> to visit.</param>
 public void Visit(NRTypeParameter nrTypeParameter)
 {
     OutputLine("NRTypeParameter");
     indent++;
     nrTypeParameter.Attributes.ForEach(nrAttribute => nrAttribute.Accept(this));
     nrTypeParameter.BaseTypes.Aggregate("", (first, second) => first + ", " + second);
     OutputLine("IsClass: " + nrTypeParameter.IsClass);
     OutputLine("IsConstructor: " + nrTypeParameter.IsConstructor);
     OutputLine("IsIn: " + nrTypeParameter.IsIn);
     OutputLine("IsOut: " + nrTypeParameter.IsOut);
     OutputLine("IsStruct: " + nrTypeParameter.IsStruct);
     OutputLine("Name: " + nrTypeParameter.Name);
     indent--;
 }