static WindsorContainer Windsor(string cfgFileFilter = "", bool reUse = true) { string cfgFileFilterKey = string.IsNullOrWhiteSpace(cfgFileFilter) ? filterAll : cfgFileFilter; if (reUse && windsorMap.ContainsKey(cfgFileFilterKey)) { return(windsorMap[cfgFileFilterKey]); } //需要重新创建 string asseblyDir = Utils.ExeAssemblyPath; string[] cfgFiles = Directory.GetFiles(asseblyDir, "*" + windsorConfigFileExt); WindsorContainer wc = new WindsorContainer(); foreach (var cf in cfgFiles) { if (cfgFileFilterKey.Equals(filterAll) || cf.Contains(cfgFileFilterKey)) { wc.Install(Configuration.FromXmlFile(cf)); if (Lgr.IsInfoEnabled) { Lgr.Info(string.Format("\r\n...Castel.Windsor Install IOC in file : {0}.", cf)); } } } if (!windsorMap.ContainsKey(cfgFileFilterKey)) { windsorMap[cfgFileFilterKey] = wc; } return(wc); }
public T Resolve <T>(string key) { try { return(curWc.Resolve <T>(key)); } catch (Exception ex) { Lgr.Error(ex); } return(default(T)); }