Microsoft.CSharp.CSharpCodeGenerator.GenerateArrayCreateExpression C# (CSharp) Méthode

GenerateArrayCreateExpression() private méthode

private GenerateArrayCreateExpression ( CodeArrayCreateExpression e ) : void
e System.CodeDom.CodeArrayCreateExpression
Résultat void
        private void GenerateArrayCreateExpression(CodeArrayCreateExpression e)
        {
            Output.Write("new ");

            CodeExpressionCollection init = e.Initializers;
            if (init.Count > 0)
            {
                OutputType(e.CreateType);
                if (e.CreateType.ArrayRank == 0)
                {
                    // Unfortunately, many clients are already calling this without array
                    // types. This will allow new clients to correctly use the array type and
                    // not break existing clients. For VNext, stop doing this.
                    Output.Write("[]");
                }
                Output.WriteLine(" {");
                Indent++;
                OutputExpressionList(init, newlineBetweenItems: true);
                Indent--;
                Output.Write('}');
            }
            else
            {
                Output.Write(GetBaseTypeOutput(e.CreateType));

                Output.Write('[');
                if (e.SizeExpression != null)
                {
                    GenerateExpression(e.SizeExpression);
                }
                else
                {
                    Output.Write(e.Size);
                }
                Output.Write(']');

                int nestedArrayDepth = e.CreateType.NestedArrayDepth;
                for (int i = 0; i < nestedArrayDepth - 1; i++)
                {
                    Output.Write("[]");
                }
            }
        }
CSharpCodeGenerator