ToBracketEnclosedList() public static method

public static ToBracketEnclosedList ( IEnumerable items, bool includeSeparatorAtLast = false ) : string
items IEnumerable
includeSeparatorAtLast bool
return string
Example #1
0
        /// <summary>
        /// Translate the unit into TypeScript.
        /// </summary>
        /// <returns></returns>
        public override string Translate()
        {
            FormatWriter writer = new FormatWriter()
            {
                Formatter = this.Formatter
            };

            // Opening declaration
            writer.WriteLine("{0} {1} {2}{3} {4}",
                             TokenUtility.ToString(this.Visibility),
                             this.ReturnType.Translate(),
                             this.Name.Translate(),
                             SyntaxUtility.ToBracketEnclosedList(this.Arguments.Select(unit => unit.Translate())),
                             Lexems.OpenCurlyBracket);

            // Statements
            // The body, we render them as a list of semicolon/newline separated elements
            writer.WriteLine("{0}", SyntaxUtility.ToNewlineSemicolonSeparatedList(
                                 this.statements.Select(unit => unit.Translate()), true));

            // Closing declaration
            writer.WriteLine("{0}", Lexems.CloseCurlyBracket);

            return(writer.ToString());
        }
Example #2
0
        /// <summary>
        /// Translate the unit into TypeScript.
        /// </summary>
        /// <returns></returns>
        public override string Translate()
        {
            FormatWriter writer = new FormatWriter()
            {
                Formatter = this.Formatter
            };

            // Opening declaration: <visibility> constructor(<params>) {
            writer.WriteLine("{0}{1} {2}",
                             Lexems.ConstructorKeyword,
                             SyntaxUtility.ToBracketEnclosedList(this.Arguments.Select(unit => unit.Translate())),
                             Lexems.OpenCurlyBracket);

            // Statements
            // The body, we render them as a list of semicolon/newline separated elements
            foreach (ITranslationUnit statement in this.statements)
            {
                writer.WriteLine("{0}{1}",
                                 statement.Translate(),
                                 ShouldRenderSemicolon(statement) ? Lexems.Semicolon : string.Empty);
            }

            // Closing declaration
            writer.WriteLine("{0}", Lexems.CloseCurlyBracket);

            return(writer.ToString());
        }
        /// <summary>
        /// Translate the unit into TypeScript.
        /// </summary>
        /// <returns></returns>
        public virtual string Translate()
        {
            FormatWriter writer = new FormatWriter()
            {
                Formatter = this.Formatter
            };

            // Opening declaration: [<visibility>] <method-name>(<params>) : <type>
            string classVisibility = this.RenderedVisibilityModifier;

            if (this.ShouldRenderReturnType)
            {
                writer.WriteLine("{0}{1}{2} {3} {4}",
                                 classVisibility,
                                 this.RenderedName,
                                 SyntaxUtility.ToBracketEnclosedList(this.arguments.Select(unit => unit.Translate())),
                                 Lexems.Colon,
                                 this.ReturnType.Translate());
            }
            else
            {
                writer.WriteLine("{0}{1}{2}",
                                 classVisibility,
                                 this.RenderedName,
                                 SyntaxUtility.ToBracketEnclosedList(this.arguments.Select(unit => unit.Translate())));
            }

            return(writer.ToString());
        }
Example #4
0
        /// <summary>
        /// Translate the unit into TypeScript.
        /// </summary>
        /// <returns></returns>
        public override string Translate()
        {
            FormatWriter writer = new FormatWriter()
            {
                Formatter = this.Formatter
            };

            // Invokation: <expression>([<params>])
            writer.WriteLine("new {0}{1}",
                             this.expression.Translate(),
                             SyntaxUtility.ToBracketEnclosedList(this.arguments.Select(unit => unit.Translate()))
                             );

            return(writer.ToString());
        }
Example #5
0
        /// <summary>
        /// Translate the unit into TypeScript.
        /// </summary>
        /// <returns></returns>
        public virtual string Translate()
        {
            FormatWriter writer = new FormatWriter()
            {
                Formatter = this.Formatter
            };

            // Opening declaration
            writer.WriteLine("{0} {1} {2}{3}",
                             TokenUtility.ToString(this.Visibility),
                             this.ReturnType.Translate(),
                             this.Name.Translate(),
                             SyntaxUtility.ToBracketEnclosedList(this.arguments.Select(unit => unit.Translate())));

            return(writer.ToString());
        }
        /// <summary>
        /// Translate the unit into TypeScript.
        /// </summary>
        /// <returns></returns>
        public override string Translate()
        {
            FormatWriter writer = new FormatWriter()
            {
                Formatter = this.Formatter
            };

            // Opening declaration: [<visibility>] <method-name>(<params>) : <type> {
            // TODO: Handle case of no visibility specified
            string methodVisibility = this.RenderedVisibilityModifier;

            if (this.ShouldRenderReturnType)
            {
                writer.WriteLine("{0}{1}{2} {3} {4} {5}",
                                 methodVisibility,
                                 this.RenderedName,
                                 SyntaxUtility.ToBracketEnclosedList(this.Arguments.Select(unit => unit.Translate())),
                                 Lexems.Colon,
                                 this.ReturnType.Translate(),
                                 Lexems.OpenCurlyBracket);
            }
            else
            {
                writer.WriteLine("{0}{1}{2} {3}",
                                 methodVisibility,
                                 this.RenderedName,
                                 SyntaxUtility.ToBracketEnclosedList(this.Arguments.Select(unit => unit.Translate())),
                                 Lexems.OpenCurlyBracket);
            }

            // Statements
            // The body, we render them as a list of semicolon/newline separated elements
            foreach (ITranslationUnit statement in this.statements)
            {
                writer.WriteLine("{0}{1}",
                                 statement.Translate(),
                                 ShouldRenderSemicolon(statement) ? Lexems.Semicolon : string.Empty);
            }

            // Closing declaration
            writer.WriteLine("{0}", Lexems.CloseCurlyBracket);

            return(writer.ToString());
        }