Beispiel #1
0
        private static void Main(string[] args)
        {
            var libType       = LibType.Assembly;
            var executingDir  = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            var sourcePath    = $"{executingDir}/testscaffolding/sources.txt";
            var omnisharpJson = File.ReadAllText($"{executingDir}/testscaffolding/omnisharp.json");
            var source        = File.ReadAllText(sourcePath);
            var sourceBuilder = new SourceBuilder();
            var scriptBuilder = new ScriptGenerator();

            // build assemblies here
            var libraryData = sourceBuilder.BuildAssembly(new[] { source });

            var firstDbsetPropertyName = "Applications";
            var userFolder             = Environment.GetEnvironmentVariable("LocalAppData");
            var appFolder         = $"{userFolder}\\SqlMapper";
            var libraryPath       = libType == LibType.Assembly ? $"{appFolder}\\generatedAssembly.dll" : $"{appFolder}\\generatedAssembly.csx";
            var scriptPath        = $"{appFolder}\\main.csx";
            var script            = scriptBuilder.BuildMainScript("GeneratedNamespace", "TempContext", libraryPath, firstDbsetPropertyName);
            var omnisharpJsonpath = $"{appFolder}\\omnisharp.json";

            var directory = new DirectoryInfo(appFolder);

            if (!directory.Exists)
            {
                directory.Create();
            }

            File.WriteAllBytes(libraryPath, libraryData);
            File.WriteAllText(scriptPath, script);
            File.WriteAllText(omnisharpJsonpath, omnisharpJson);
        }
Beispiel #2
0
        public void BuildScriptTest()
        {
            const string source1 =
                @"namespace TestNamespace
{
    public class TestClass
    {

    }
}";
            const string source2 =
                @"namespace TestNamespace
{
    public class TestClass2
    {

    }

    public class TestClass3
    {
        public void DoNothing()
        {

        }
    }
}";
            var builder = new SourceBuilder();
            var result  = builder.BuildAssembly(new[] { source1, source2 });

            File.WriteAllBytes(@"C:\Users\sharpiro\AppData\Local\SqlMapper\testAssembly.dll", result);
        }
Beispiel #3
0
 public void BuildAssemblyTest()
 {
     var builder = new SourceBuilder();
     var result  = builder.BuildAssembly(new string[0]);
 }