示例#1
0
        private void GenerateAssertOverloads(IndentedTextWriter writer, bool isStatic, GenSpec spec)
        {
            if (!spec.LeftPart.EndsWith(")") || !spec.RightPart.EndsWith(")"))
            {
                IssueFormatError(spec.ToString());
            }
            string leftPart  = spec.LeftPart.Substring(0, spec.LeftPart.Length - 1);
            string rightPart = spec.RightPart.Substring(0, spec.RightPart.Length - 1);

            GenSpec spec1 = new GenSpec(
                "Gen: " + leftPart + ", string message, params object[] args)=>" + rightPart + " ,message, args)");

            WriteComments(writer);
            writer.WriteLine("/// <param name=\"message\">The message to display in case of failure</param>");
            writer.WriteLine("/// <param name=\"args\">Array of objects to be used in formatting the message</param>");
            WriteMethodDefinition(writer, isStatic, spec1);

            GenSpec spec2 = new GenSpec(
                "Gen: " + leftPart + ", string message)=>" + rightPart + " ,message, null)");

            WriteComments(writer);
            writer.WriteLine("/// <param name=\"message\">The message to display in case of failure</param>");
            WriteMethodDefinition(writer, isStatic, spec2);

            GenSpec spec3 = new GenSpec(
                "Gen: " + leftPart + ")=>" + rightPart + " ,null, null)");

            WriteComments(writer);
            WriteMethodDefinition(writer, isStatic, spec3);
        }
示例#2
0
        private void WriteMethodDefinition(IndentedTextWriter writer, bool isStatic, GenSpec spec)
        {
            if (spec.Attributes != null)
            {
                writer.WriteLine(spec.Attributes);
            }

            if (isStatic)
            {
                writer.WriteLine("public static {0} {1}", typeName, spec.MethodName);
            }
            else
            {
                writer.WriteLine("public {0} {1}", typeName, spec.MethodName);
            }
            writer.WriteLine("{");
            writer.Indent++;
            writer.WriteLine(spec.IsProperty
                    ? "get { return " + spec.RightPart + "; }"
                    : typeName == "void"
                        ? spec.RightPart + ";"
                        : "return " + spec.RightPart + ";");
            writer.Indent--;
            writer.WriteLine("}");
            writer.WriteLine();
        }
示例#3
0
        private void WriteMethodDefinition(IndentedTextWriter writer, bool isStatic, GenSpec spec)
        {
            if (spec.Attributes != null)
                writer.WriteLine(spec.Attributes);

            if (isStatic)
                writer.WriteLine("public static {0} {1}", typeName, spec.MethodName);
            else
                writer.WriteLine("public {0} {1}", typeName, spec.MethodName);
            writer.WriteLine("{");
            writer.Indent++;
            writer.WriteLine(spec.IsProperty
                    ? "get { return " + spec.RightPart + "; }"
                    : typeName == "void"
                        ? spec.RightPart + ";"
                        : "return " + spec.RightPart + ";" );
            writer.Indent--;
            writer.WriteLine("}");
            writer.WriteLine();
        }
示例#4
0
 private void GenerateMethod(IndentedTextWriter writer, bool isStatic, GenSpec spec)
 {
     WriteComments(writer);
     WriteMethodDefinition(writer, isStatic, spec);
 }
示例#5
0
        private void GenerateAssertOverloads(IndentedTextWriter writer, bool isStatic, GenSpec spec)
        {
            if (!spec.LeftPart.EndsWith(")") || !spec.RightPart.EndsWith(")"))
                IssueFormatError(spec.ToString());
            string leftPart = spec.LeftPart.Substring(0, spec.LeftPart.Length - 1);
            string rightPart = spec.RightPart.Substring(0, spec.RightPart.Length - 1);

            GenSpec spec1 = new GenSpec(
                "Gen: " + leftPart + ", string message, params object[] args)=>" + rightPart + " ,message, args)");
            WriteComments(writer);
            writer.WriteLine("/// <param name=\"message\">The message to display in case of failure</param>");
            writer.WriteLine("/// <param name=\"args\">Array of objects to be used in formatting the message</param>");
            WriteMethodDefinition(writer, isStatic, spec1);

            GenSpec spec2 = new GenSpec(
                "Gen: " + leftPart + ", string message)=>" + rightPart + " ,message, null)");
            WriteComments(writer);
            writer.WriteLine("/// <param name=\"message\">The message to display in case of failure</param>");
            WriteMethodDefinition(writer, isStatic, spec2);

            GenSpec spec3 = new GenSpec(
                "Gen: " + leftPart + ")=>" + rightPart + " ,null, null)");
            WriteComments(writer);
            WriteMethodDefinition(writer, isStatic, spec3);
        }
示例#6
0
 private void GenerateMethod(IndentedTextWriter writer, bool isStatic, GenSpec spec)
 {
     WriteComments(writer);
     WriteMethodDefinition(writer, isStatic, spec);
 }