Beispiel #1
0
        private static void GenerateTypeScript(string outFolder, bool setBOM)
        {
            if (!Directory.Exists(outFolder))
            {
                Directory.CreateDirectory(outFolder);
            }

            var targetAssemblyName = Program.ProjectInfo.AssemblyName;
            var assemblyContext    = new AssemblyContext($"{TargetBinFolder}/{targetAssemblyName}.dll", DotNetFramework.Parse(Program.ProjectInfo.TargetFramework));

            var types = assemblyContext.RootAssembly.GetTypesWhichExtends <DbContext>(true);

            foreach (var type in types)
            {
                var outFile = $"{Path.GetFullPath($"{outFolder}/{type.Name}.html")}";

                var builder = new DbStructureBuilder();
                builder.Cache(type);
                var csvContent = builder.GetHtml();
                var bytes      = setBOM
                    ? new byte[] { 0xef, 0xbb, 0xbf }.Concat(csvContent.Bytes(Encoding.UTF8)).ToArray()
                    : csvContent.Bytes(Encoding.UTF8).ToArray();

                File.WriteAllBytes(outFile, bytes);
                Console.WriteLine($"File Saved: {outFile}");
            }
        }
Beispiel #2
0
        public override void Run()
        {
            if (!Directory.Exists(OutFolder))
            {
                Directory.CreateDirectory(OutFolder);
            }

            var targetAssemblyName = Program.ProjectInfo.AssemblyName;
            var assemblyContext    = new AssemblyContext($"{TargetBinFolder}/{targetAssemblyName}.dll", DotNetFramework.Parse(Program.ProjectInfo.TargetFramework));

            var dbContextType = assemblyContext.GetType($"Microsoft.EntityFrameworkCore.DbContext,Microsoft.EntityFrameworkCore");
            var types         = assemblyContext.RootAssembly.GetTypesWhichExtends(dbContextType, true);

            foreach (var type in types)
            {
                var outFile = $"{Path.GetFullPath($"{OutFolder}/{type.Name}.html")}";

                var builder = new DbStructureBuilder();
                builder.Cache(type);
                var csvContent = builder.GetHtml();
                var bytes      = SetBOM
                    ? new byte[] { 0xef, 0xbb, 0xbf }.Concat(csvContent.Bytes(Encoding.UTF8)).ToArray()
                    : csvContent.Bytes(Encoding.UTF8).ToArray();

                File.WriteAllBytes(outFile, bytes);
                Console.WriteLine($"File Saved: {outFile}");
            }
        }