示例#1
0
        public static ArgumentObject Parse(string[] args)
        {
            argumentList argList = new argumentList();

            for (int idx = 0; idx < args.Length; idx++)
            {
                string str = args[idx];
                switch (str)
                {
                case "ani":
                    if (argList.mn != string.Empty)
                    {
                        throw new Exception("ani/nvl selector has already been set in this parameter list.");
                    }
                    argList.mn = "ani";
                    break;

                case "nvl":
                    if (argList.mn != string.Empty)
                    {
                        throw new Exception("ani/nvl selector has already been set in this parameter list.");
                    }
                    argList.mn = "nvl";
                    break;

                case "ints":
                    if (argList.mn != string.Empty)
                    {
                        throw new Exception("MN Flag already set.");
                    }
                    argList.mn = "ints";
                    break;

                case "-add":

                    break;

                case "-aS":
                    if (argList.mn != string.Empty)
                    {
                        throw new Exception("ani/nvl selector has already been set in this parameter list.");
                    }
                    argList.mn = "ani";
                    argList.aS = true;
                    break;

                case "-nS":
                    if (argList.mn != string.Empty)
                    {
                        throw new Exception("ani/nvl selector has already been set in this parameter list.");
                    }
                    argList.mn = "nvl";
                    argList.nS = true;
                    break;

                case "-d":
                    argList.d = true;
                    break;

                case "-mt":
                    argList.mt = true;
                    break;

                case "-cc":
                    argList.cc = true;
                    break;

                case "-skip":
                    argList.c = true;
                    break;

                case "-c":
                    argList.c = true;
                    break;

                case "-h":
                    argList.h = true;
                    break;

                case "-s":
                    argList.s = true;
                    break;

                case "-gS":
                    argList.gS = true;
                    break;

                case "-hS":
                    argList.hS = true;
                    break;

                case "-tS":
                    argList.tS = true;
                    break;

                case "-e":
                    argList.e = true;
                    break;

                case "-help":
                    argList.help = true;
                    break;

                case "-l":
                    argList.l = true;
                    idx++;
                    string k = args[idx];
                    if (k[0] == '\"')
                    {
                        argList.export = SearchForPath(args, idx);
                    }
                    else
                    {
                        argList.export = k;
                    }

                    if (argList.export[0] == '.' && (argList.export[1] == '/' || argList.export[1] == '\\'))
                    {
                        argList.export = new string(argList.export.Skip(2).ToArray()).InsertAtFront(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar);
                    }
                    break;

                case "-range":
                    idx++;
                    string[] range = args[idx].Split('-');
                    argList.vRange     = true;
                    argList.VideoRange = new int[2] {
                        int.Parse(range[0]) - 1, int.Parse(range[1]) - 1
                    };
                    if (argList.VideoRange[0] < 1 || argList.VideoRange[1] < 1)
                    {
                        throw new ArgumentException("x^1 or x^2 can not be less than 1.");
                    }
                    break;

                case "-resume":
                    argList.resume = true;
                    break;

                case "-stream":
                    argList.stream = true;
                    break;

                default:
                    argList.term += argList.term.Length > 0 ? $" {str}" : str;
                    break;
                }
            }

            if (argList.term.Length > 1)
            {
                if (argList.term[0] == '.' && (argList.term[1] == '/' || argList.term[1] == '\\'))
                {
                    argList.term = new string(argList.term.Skip(2).ToArray()).InsertAtFront(Directory.GetCurrentDirectory());
                }
            }

            return(new ArgumentObject(argList));
        }
示例#2
0
        public ArgumentObject(Object[] arr)
        {
            arguments = new argumentList();
            foo       = typeof(argumentList).GetFields(BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic);
            for (int idx = 0; idx < arr.Length; idx++)
            {
                if (arr[idx] as string == "-vRange" || arr[idx] as string == "-range")
                {
                    idx++;
                    string[] range = (arr[idx] as string).Split('-');
                    arguments.vRange     = true;
                    arguments.VideoRange = new int[2] {
                        int.Parse(range[0]) - 1, int.Parse(range[1])
                    };
                    continue;
                }
                else if (arr[idx] as string == "-l")
                {
                    idx++;
                    string k = arr[idx] as string;
                    if (k[0] == '\"')
                    {
                        string[] arre = new string[arr.Length - idx];
                        for (int d = idx; d < arr.Length; d++)
                        {
                            arre[d] = arr[d] as string;
                        }
                        arguments.export = SearchForPath(arre, 0);
                    }
                    else
                    {
                        arguments.export = k;
                    }

                    if (arguments.export[0] == '.' && (arguments.export[1] == '/' || arguments.export[1] == '\\'))
                    {
                        arguments.export = new string(arguments.export.Skip(2).ToArray()).InsertAtFront(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar);
                    }
                    continue;
                }
                string arrs = new string(arr[idx].ToString().Skip(1).ToArray());

                IEnumerable <FieldInfo> e = foo.Where(x => x.Name == arrs && (arr[idx] as string)[0] == '-');
                if (e.Count() <= 0)
                {
                    switch ((string)arr[idx])
                    {
                    case "nvl":
                        arguments.mn = "nvl";
                        continue;

                    case "ani":
                        arguments.mn = "ani";
                        continue;

                    case "man":
                        arguments.mn = "man";
                        continue;

                    default:
                        arguments.term += $"{arr[idx] as string} ";
                        continue;
                    }
                }

                e.First().SetValue(arguments, true);
            }
        }
示例#3
0
 public ArgumentObject(argumentList args)
 {
     foo       = typeof(argumentList).GetFields(BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic);
     arguments = args;
 }