Esempio n. 1
0
        public void advanced_usages()
        {
            // SAMPLE: SourceWriterAdvanced
            var writer = new SourceWriter();

            // Add "using [namespace]; statements
            writer.UsingNamespace(typeof(Console).Namespace);
            writer.UsingNamespace <IOperation>();

            writer.Namespace("GeneratedCode");
            // Write new classes and code within the namespace
            writer.FinishBlock();


            // Helper to write using blocks in C# code
            writer.UsingBlock("var conn = new SqlConnection()", w =>
            {
                w.Write("conn.Open();");
                // other statements
            });



            // Write a comment text into the code at the correct indention
            // level
            writer.WriteComment("Some message");


            // Start the declaration of a new public class named "MyClass"
            // that implements the IDisposable interface
            writer.StartClass("MyClass", typeof(IDisposable));
            // ENDSAMPLE
        }
Esempio n. 2
0
        public void write_comment()
        {
            var writer = new SourceWriter();

            writer.Write("BLOCK:public void Go()");
            writer.WriteComment("Some Comment");

            var lines = writer.Code().ReadLines().ToArray();

            lines.Last().ShouldBe("    // Some Comment");
        }