示例#1
0
        public void Write(SourceWriter writer)
        {
            foreach (var line in Summary)
            {
                writer.FullLine(line);
            }

            foreach (var arg in GenericArgs)
            {
                writer.FullLine(arg);
            }

            foreach (var param in Parameters)
            {
                writer.FullLine(param);
            }

            foreach (var exception in Exceptions)
            {
                writer.FullLine(exception);
            }

            foreach (var desc in ReturnDescription)
            {
                writer.FullLine(desc);
            }
        }
示例#2
0
        public void Write(SourceWriter writer)
        {
            if (IsExpression)
            {
                if (Body.Length != 1)
                {
                    throw new InvalidOperationException($"Method body {ToString()} should be expression but is not exactly 1 line");
                }

                if (SingleLineExpression)
                {
                    writer.WriteLine($" => {Body.Single()};");
                }
                else
                {
                    writer.WriteLine(" =>");
                    writer.FullLine($"    {Body.Single()};");
                }
            }
            else
            {
                writer.WriteLine("");

                writer.FullLine("{");

                for (var i = 0; i < Body.Length; i++)
                {
                    if (Body[i] == string.Empty)
                    {
                        writer.WriteLine("");
                    }
                    else
                    {
                        writer.FullLine($"    {Body[i]}");
                    }
                }

                writer.FullLine("}");
            }
        }