EntityDescriptor for NorthwindIB data model
Inheritance: EntityDescriptor
Exemplo n.º 1
0
        //class person { public string name { get; set; } }
        static void Main(string[] args)
        {
            //var persons = new[] {
            //    new person { name = "personA" },
            //    new person { name = "personAA"},
            //    new person { name = "personB" }
            //};

            //var filteredPersons =
            //    persons
            //        .Where(p => { var x = p.name.ToLower(); return x.EndsWith("a"); })
            //        .Where(p => p.name.ToLower().Count(c => c == 'a') > 0);

            var procname = System.Diagnostics.Process.GetCurrentProcess().ProcessName;

            Console.WriteLine(procname + ' ' + string.Join(" ", args));

            var parser = new CommandLine.Parser(ps => { ps.MutuallyExclusive = true; ps.HelpWriter = Console.Out; });

            if (!parser.ParseArguments(args, Options))
            {
                return;
            }
            var assemblyName = GetAssemblyName(Options.InputFile);

            if (!File.Exists(assemblyName))
            {
                Console.WriteLine("The specified file {0} cannot be found", assemblyName);
                return;
            }
            string outfile = GetFilePath();

            // TODO: how to get this from the command line?
            EntityDescriptor descriptor;

            if (assemblyName.Contains("Northwind"))
            {
                descriptor = new NorthwindEntityDescriptor();
            }
            else
            {
                descriptor = new EntityDescriptor();
            }

            var metadata = Generator.Generate(assemblyName, descriptor);
            var json     = ToJson(metadata);

            if (outfile != null)
            {
                Console.WriteLine("Writing to " + outfile);
                File.WriteAllText(outfile, json);
            }
            else
            {
                Console.WriteLine(json);
            }
            Console.WriteLine("Done");

            Console.ReadKey();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var procname = System.Diagnostics.Process.GetCurrentProcess().ProcessName;
            Console.WriteLine(procname + ' ' + string.Join(" ", args));
            var parser = new CommandLine.Parser(ps => { ps.MutuallyExclusive = true; ps.HelpWriter = Console.Out; });

            if (!parser.ParseArguments(args, Options))
            {
                return;
            }
            var assemblyName = GetAssemblyName(Options.InputFile);

            if (!File.Exists(assemblyName))
            {
                Console.WriteLine("The specified file {0} cannot be found", assemblyName);
                return;
            }
            string outfile = GetFilePath();

            // TODO: how to get this from the command line?
            EntityDescriptor descriptor;
            if (assemblyName.Contains("Northwind"))
                descriptor = new NorthwindEntityDescriptor();
            else
                descriptor = new EntityDescriptor();

            var metadata = Generator.Generate(assemblyName, descriptor);
            var json = ToJson(metadata);

            if (outfile != null)
            {
                Console.WriteLine("Writing to " + outfile);
                File.WriteAllText(outfile, json);
            }
            else
            {
                Console.WriteLine(json);
            }
            Console.WriteLine("Done");
        }