private static void CmdTips() { IndexConfigs configs = IndexConfigHelper.IndexConfigs; Console.WriteLine("命令\t索引名"); foreach (var indexConfig in configs) { var config = (IndexConfig)indexConfig; Console.WriteLine(string.Format("{0}\t{1}", config.IndexType, config.Alias)); } Console.WriteLine(); }
public IndexerContainer(ILog log) { _log = log; IndexConfigs indexConfigs = IndexConfigHelper.IndexConfigs; if (_iocContainer == null && indexConfigs != null && indexConfigs.Count > 0) { var builder = new ContainerBuilder(); //已加载 //var fromTypes = AppDomain.CurrentDomain.GetAssemblies() // .SelectMany(a => a.GetTypes()); //注册文件 var assemblys = new DirectoryInfo(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "DevelopmentLayer\\") .GetFiles("*.dll").Select(r => Assembly.LoadFrom(r.FullName)).ToArray(); List <Type> types = new List <Type>(); foreach (var assembly in assemblys) { types.AddRange(assembly.GetTypes()); } var fromTypes = types; //注入 foreach (var indexConfig in indexConfigs) { var config = (IndexConfig)indexConfig; var fromType = fromTypes.FirstOrDefault(n => n.FullName == config.TypeName); if (fromType == null) { _log.Error(config.IndexType + " 的实现" + config.TypeName + " 未找到!"); continue; } builder .RegisterType(fromType) .As <IIndexer>() .Named <IIndexer>(config.IndexType.ToLower()); } _iocContainer = builder.Build(); } }
public InitTaskManager(ILog log) { _log = log; _configs = IndexConfigHelper.IndexConfigs; _taskFactory = new TaskFactory(); }