string getCmdCfg(string cmdName, string key) { Dictionary <string, string> tmp = _config.Parse <Dictionary <string, string> >(cmdName + ".sql"); if (tmp != null && tmp.ContainsKey(key)) { return(tmp[key]); } return(null); }
object[] objectCfg(string objectID) { string key = objectID; Dictionary <string, object> cfg = _config.Parse <Dictionary <string, object> >(key); if (cfg != null) { if (cfg.ContainsKey("$ref")) { cfg = _config.Parse <Dictionary <string, object> >(cfg["$ref"].ToString()); } return(new object[] { cfg.ContainsKey("Type")?cfg["Type"].ToString():null , cfg.ContainsKey("Dll")?cfg["Dll"].ToString():null , cfg.ContainsKey("Args")?(ArrayList)cfg["Args"]:null , cfg.ContainsKey("Url")?cfg["Url"].ToString():null , cfg.ContainsKey("SoapHeader")?(Dictionary <string, object>)cfg["SoapHeader"]:null , cfg.ContainsKey("DyDll")?cfg["DyDll"].ToString():null , cfg.ContainsKey("Fields")?(Dictionary <string, object>)cfg["Fields"]:null //Do not make aliases, it is the first time to create an object with the alias will fail, it is recommended to store the Config object as a database }); } return(null); }
object[] objectCfg(string objectID) { string key = objectID; Dictionary <string, object> cfg = _config.Parse <Dictionary <string, object> >(key); if (cfg != null) { if (cfg.ContainsKey("$ref")) { cfg = _config.Parse <Dictionary <string, object> >(cfg["$ref"].ToString()); } return(new object[] { cfg.ContainsKey("Type")?cfg["Type"].ToString():null , cfg.ContainsKey("Dll")?cfg["Dll"].ToString():null , cfg.ContainsKey("Args")?(ArrayList)cfg["Args"]:null , cfg.ContainsKey("Url")?cfg["Url"].ToString():null , cfg.ContainsKey("SoapHeader")?(Dictionary <string, object>)cfg["SoapHeader"]:null , cfg.ContainsKey("DyDll")?cfg["DyDll"].ToString():null , cfg.ContainsKey("Fields")?(Dictionary <string, object>)cfg["Fields"]:null //不作別名,是以別名第一次創建對象會失敗,建議以資料庫形式儲存Config對象 }); } return(null); }
public void EncryptDB(string db) { FileConfig config = ((FileConfig)ObjectFactory.Instance.Config); string configName = DATABASE_CFG_PREFIX + db; Dictionary <string, object> cfg = config.Parse <Dictionary <string, object> >(configName); if (!cfg.ContainsKey("$ref")) { ArrayList args = cfg["Args"] as ArrayList; string type = args[0].ToString(); if (!type.StartsWith("$")) { args[0] = "$" + type; args[1] = Encrypt(args[1].ToString()); } } }
public string DecryptDB(string db, bool save) { FileConfig config = ((FileConfig)ObjectFactory.Instance.Config); string configName = DATABASE_CFG_PREFIX + db; Dictionary <string, object> cfg = config.Parse <Dictionary <string, object> >(configName); if (cfg == null) { return("null"); } if (!cfg.ContainsKey("$ref")) { ArrayList args = cfg["Args"] as ArrayList; string type = args[0].ToString(); string conn = args[1].ToString(); return(conn); } else { return(DecryptDB(cfg["$ref"].ToString(), false)); } }
public T Get <T>(string configFile, string key, char splitKey) { T ret = default(T); Dictionary <string, object> dic = _config.Parse <Dictionary <string, object> >(configFile); string[] keys = key.Split(new char[] { splitKey }); for (int i = 0; i < keys.Length; i++) { string itemKey = keys[i]; if (dic == null || !dic.ContainsKey(itemKey)) { break; } if (i != keys.Length - 1) //不是最後一個 { dic = dic[itemKey] as Dictionary <string, object>; } else { ret = (T)dic[itemKey]; } } return(ret); }