public bool CheckArg(ArgOption argOption) { bool isExist = false; isExist = args.Where(i => GetKeyWithOutPrefix(i.ToString()).StartsWith(argOption.ToString())).FirstOrDefault() != null; return(isExist); }
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); }
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); }
private string GetKeyWithPrefix(ArgOption argOption) { return(prefix + argOption.ToString().ToLower()); }