protected override void GenerateInner(CodeGenerator generator)
        {
            generator.Write(TokenType.Keyword, "new");
            generator.Write(TokenType.Space, ' ');
            if (CreateType != null)
            {
                CreateType.Generate(generator);
            }
            generator.Write(TokenType.Space, ' ');
            generator.WriteLine(TokenType.Punctuation, '{');

            generator.Indent++;
            for (int i = 0; i < Members.Count; i++)
            {
                var member = Members[i];
                generator.OutputIdentifier(TokenType.Identifier, member.Key);
                generator.Write(TokenType.Space, ' ');
                generator.Write(TokenType.Operator, '=');
                generator.Write(TokenType.Space, ' ');
                member.Value.Generate(generator);
                generator.WriteLine(TokenType.Punctuation, i < Members.Count - 1 ? "," : "");
            }
            generator.Indent--;

            generator.Write(TokenType.Punctuation, '}');
        }
Example #2
0
        protected override void GenerateInner(CodeGenerator generator)
        {
            generator.Write(TokenType.Keyword, "new");
            generator.Write(TokenType.Space, ' ');
            CreateType.Generate(generator);
            generator.Write(TokenType.Punctuation, '(');
            Arguments.GenerateCommaSeparated(generator);
            generator.Write(TokenType.Punctuation, ')');

            if (CollectionInitializerItems.Count > 0)
            {
                generator.Write(TokenType.Space, ' ');
                generator.WriteLine(TokenType.Punctuation, '{');
                generator.Indent++;
                for (int i = 0; i < CollectionInitializerItems.Count; i++)
                {
                    var collectionInitializerItem = CollectionInitializerItems[i];

                    if (collectionInitializerItem.Count != 1)
                    {
                        generator.Write(TokenType.Punctuation, '{');
                        collectionInitializerItem.GenerateCommaSeparated(generator);
                        generator.Write(TokenType.Punctuation, '}');
                    }
                    else
                    {
                        collectionInitializerItem.First().Generate(generator);
                    }

                    generator.WriteLine(TokenType.Punctuation, i < CollectionInitializerItems.Count - 1 ? "," : "");
                }
                generator.Indent--;
                generator.Write(TokenType.Punctuation, '}');
            }
        }
        protected override void GenerateInner(CodeGenerator generator)
        {
            generator.Write(TokenType.Keyword, "new");
            generator.Write(TokenType.Space, ' ');

            if (Lengths.Count > 0)
            {
                CreateType.NestedElementType.Generate(generator);
                generator.Write(TokenType.Punctuation, '[');
                Lengths.GenerateCommaSeparated(generator);
                generator.Write(TokenType.Punctuation, ']');
                generator.Write(TokenType.Punctuation, CreateType.ArrayElementType.CompleteArraySuffix);
            }
            else
            {
                CreateType.Generate(generator);
            }

            if (Initializer.Count > 0 || Lengths.Count == 0)
            {
                generator.Write(TokenType.Punctuation, '{');
                Initializer.GenerateCommaSeparated(generator);
                generator.Write(TokenType.Punctuation, '}');
            }
        }