Example #1
0
        public bool CheckArg(ArgOption argOption)
        {
            bool isExist = false;

            isExist = args.Where(i => GetKeyWithOutPrefix(i.ToString()).StartsWith(argOption.ToString())).FirstOrDefault() != null;
            return(isExist);
        }
Example #2
0
        public void RegisterArg <T>(ArgOption argOption)
        {
            if (argsMap == null)
            {
                argsMap = new Dictionary <string, object>();
            }
            Object o;

            if (typeof(T) == typeof(string) || typeof(T) == typeof(String))
            {
                o = NULLSTRING;
            }
            else
            {
                o = (T)Activator.CreateInstance(typeof(T));
            }
            argsMap.Add(argOption.ToString().ToLower(), o);
        }
Example #3
0
        public T GetArg <T>(ArgOption argOption)
        {
            Object obj = new object();

            argsMap.TryGetValue(argOption.ToString().ToLower(), out obj);
            if (obj == null)
            {
                throw new Exception("Plesae RegisterArg Before Call GetArg Method");
            }

            Type valueType = obj.GetType();

            if ((obj.GetType() == typeof(string) || obj.GetType() == typeof(String)) && typeof(T) == typeof(bool))
            {
                obj = !isNullString(obj.ToString());
            }
            return((T)obj);
        }
Example #4
0
 private string GetKeyWithPrefix(ArgOption argOption)
 {
     return(prefix + argOption.ToString().ToLower());
 }