Ejemplo n.º 1
0
        public static int ExtractArguements(IEnumerable <string> args, out Dictionary <string, string> opts, out Dictionary <string, string> pars, AccumInfo myLog)
        {
            int rVal = 0;

            opts = new Dictionary <string, string>();
            pars = new Dictionary <string, string>();
            foreach (string stgVal in args)
            {
                string nam = stgVal;
                try {
                    bool isOpt = false;
                    if (nam[0].Equals('-'))
                    {
                        isOpt = true;
                        nam   = nam.Substring(1);
                    }
                    int    eqIdx;
                    string val = "";
                    if ((nam.Length >= 1) && (eqIdx = nam.IndexOf("=")) > 0)
                    {
                        val = nam.Substring(eqIdx + 1);
                        nam = nam.Substring(0, eqIdx);
                    }
                    Dictionary <string, string> targ = (isOpt) ? opts : pars;
                    if (targ.ContainsKey(nam))
                    {
                        targ[nam] = val;
                    }
                    else
                    {
                        targ.Add(nam, val);
                    }
                    if (isOpt && nam.Equals("ThRoW"))    // to test aborting
                    {
                        int iv = int.Parse(val);
                        if (iv != 0)
                        {
                        }
                        throw new Exception(val);
                    }
                }
                catch (Exception exc) {
                    if (rVal == 0)
                    {
                        rVal = exc.HResult;
                    }
                    string msg = ExceptionMsg(exc, "FileSystemOps.FilterFSInfo.opts");
                    //Console.WriteLine(msg);
                    myLog(msg);
                }
            }

            if (opts.ContainsKey("v"))    // simple verbose
            {
                foreach (string stg in opts.Keys)
                {
                    Console.WriteLine("o {0,-10} = '{1}'", stg, opts[stg]);
                }
                foreach (string stg in pars.Keys)
                {
                    Console.WriteLine("p {0,-10} = '{1}'", stg, pars[stg]);
                }
            }

            return(rVal);
        }
Ejemplo n.º 2
0
 public FileSystemOps(AccumInfo errorLog)
 {
     myLog = errorLog ?? myAccumInfo;
 }