Exemplo n.º 1
0
        private static void Process(string[] args)
        {
            if (args.Length > 0 && args[0].ToLower() == "m")
            {
                if (args.Length == 1)
                {
                    ShowTableList();
                }
                else
                {
                    GenerateModelFromDatabase(args[1]);
                }
                return;
            }

            if (args.Length < 2)
            {
                throw new ArgsErrorException(0, null);
            }

            var fileName = Path.GetFullPath(args[1]);

            if (!File.Exists(fileName))
            {
                throw new ArgsErrorException(2, "The file you input doesn't exist!");
            }

            if (args.Length == 2 && args[0].ToLower() == "dll")
            {
                GenerateAssembly(fileName);
                Console.WriteLine("Assembly saved!");
                return;
            }

            switch (args [0].ToLower())
            {
            case "a":
            case "asp":
            case "aspnet":
                if (!SearchClasses(fileName, args.Length))
                {
                    GenerateAspNetTemplate(fileName, args [2]);
                }
                break;

            case "ra":
            case "action":
                if (!SearchClasses(fileName, args.Length))
                {
                    if (args.Length >= 4)
                    {
                        var    gen = new MvcActionGenerator(fileName, args [2], args [3]);
                        string s   = gen.ToString();
                        Console.WriteLine(s);
                    }
                    else
                    {
                        throw new ArgsErrorException(3, "Need class name and action name.");
                    }
                }
                break;

            case "rv":
            case "view":
                if (!SearchClasses(fileName, args.Length))
                {
                    if (args.Length >= 4)
                    {
                        string mpn = args.Length >= 5 ? args [4] : null;
                        var    gen = new MvcViewGenerator(fileName, args [2], args [3], mpn);
                        string s   = gen.ToString();
                        Console.WriteLine(s);
                    }
                    else
                    {
                        throw new ArgsErrorException(4, "Need class name and view name.");
                    }
                }
                break;

            case "fn":
            case "fullname":
                var assembly = Assembly.LoadFile(args [1]);
                Console.WriteLine(assembly.FullName);
                break;

            default:
                throw new ArgsErrorException(0, null);
            }
        }
Exemplo n.º 2
0
        private static void Process(string[] args)
        {
            if(args.Length > 0 && args[0].ToLower() == "m")
            {
                if(args.Length == 1)
                {
                    ShowTableList();
                }
                else
                {
                    GenerateModelFromDatabase(args[1]);
                }
                return;
            }

            if (args.Length < 2)
            {
                throw new ArgsErrorException(0, null);
            }

            var fileName = Path.GetFullPath(args[1]);

            if (!File.Exists(fileName))
            {
                throw new ArgsErrorException(2, "The file you input doesn't exist!");
            }

			if (args.Length == 2 && args[0].ToLower() == "dll") {
				GenerateAssembly(fileName);
				Console.WriteLine("Assembly saved!");
				return;
			}

			switch (args [0].ToLower ()) {
			case "a":
			case "asp":
			case "aspnet":
				if (!SearchClasses (fileName, args.Length)) {
					GenerateAspNetTemplate (fileName, args [2]);
				}
				break;
			case "ra":
			case "action":
				if (!SearchClasses (fileName, args.Length)) {
					if (args.Length >= 4) {
						var gen = new MvcActionGenerator (fileName, args [2], args [3]);
						string s = gen.ToString ();
						Console.WriteLine (s);
					} else {
						throw new ArgsErrorException (3, "Need class name and action name.");
					}
				}
				break;
			case "rv":
			case "view":
				if (!SearchClasses (fileName, args.Length)) {
					if (args.Length >= 4) {
						string mpn = args.Length >= 5 ? args [4] : null;
						var gen = new MvcViewGenerator (fileName, args [2], args [3], mpn);
						string s = gen.ToString ();
						Console.WriteLine (s);
					} else {
						throw new ArgsErrorException (4, "Need class name and view name.");
					}
				}
				break;
			case "fn":
			case "fullname":
				var assembly = Assembly.LoadFile (args [1]);
				Console.WriteLine (assembly.FullName);
				break;
			default:
				throw new ArgsErrorException (0, null);
			}
        }
Exemplo n.º 3
0
        private static void Process(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Code Generator For DbEntry.Net http://dbentry.codeplex.com.");
                Console.WriteLine("Modified by Elton FAN, http://elton.io/");
                return;
            }

            if (args[0].ToLower() == "m")
            {
                if (args.Length < 3)
                {
                    ShowTableList();
                }
                else
                {
                    var basePath = args[1];
                    var parts    = args[2].Split(new string[] { ",", ";", "|" }, StringSplitOptions.RemoveEmptyEntries);

                    GenerateModelFromDatabase(basePath, parts);
                }
                return;
            }

            if (args.Length < 2)
            {
                throw new ArgsErrorException(0, null);
            }

            var fileName = Path.GetFullPath(args[1]);

            if (!File.Exists(fileName))
            {
                throw new ArgsErrorException(2, "The file you input doesn't exist!");
            }

            if (args.Length == 2 && args[0].ToLower() == "dll")
            {
                GenerateAssembly(fileName);
                Console.WriteLine("Assembly saved!");
                return;
            }

            switch (args [0].ToLower())
            {
            case "a":
            case "asp":
            case "aspnet":
                if (!SearchClasses(fileName, args.Length))
                {
                    GenerateAspNetTemplate(fileName, args [2]);
                }
                break;

            case "ra":
            case "action":
                if (!SearchClasses(fileName, args.Length))
                {
                    if (args.Length >= 4)
                    {
                        var    gen = new MvcActionGenerator(fileName, args [2], args [3]);
                        string s   = gen.ToString();
                        Console.WriteLine(s);
                    }
                    else
                    {
                        throw new ArgsErrorException(3, "Need class name and action name.");
                    }
                }
                break;

            case "rv":
            case "view":
                if (!SearchClasses(fileName, args.Length))
                {
                    if (args.Length >= 4)
                    {
                        string mpn = args.Length >= 5 ? args [4] : null;
                        var    gen = new MvcViewGenerator(fileName, args [2], args [3], mpn);
                        string s   = gen.ToString();
                        Console.WriteLine(s);
                    }
                    else
                    {
                        throw new ArgsErrorException(4, "Need class name and view name.");
                    }
                }
                break;

            case "fn":
            case "fullname":
                var assembly = Assembly.LoadFile(args [1]);
                Console.WriteLine(assembly.FullName);
                break;

            default:
                throw new ArgsErrorException(0, null);
            }
        }