public MyRegistry() { //设置config var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); _configuration = builder.Build(); var moduleSettings = new List <HandlerOptions>(); _configuration.GetSection("HandlerAction").Bind(moduleSettings); // moduleSettings = moduleSettings.FindAll(c => c.IsOpen == true); AssemblyName assemblyName = new AssemblyName("Hyc.AppServices"); foreach (var handler in moduleSettings) { Type type = Assembly.Load(assemblyName).GetType(handler.ActionName); IJob obj = (IJob)Activator.CreateInstance(type); if (obj == null) { Console.WriteLine($"服务{handler.ActionName}不存在"); continue; } try { IRunAction irun = new FactoryAction(handler.Interval.ToString()).Intit(); irun.Run(obj, handler); } catch (Exception ex) { Console.WriteLine($"服务{handler.ActionName}出现异常:{ex.ToString()}"); } } }
void Object_InstanceAction(Type requestedType, object instance, string name, FactoryAction action) { if (_factory_NotificationOrderingTest_typeList != null) { lock (_factory_NotificationOrderingTest_typeList) _factory_NotificationOrderingTest_typeList.Push(typeof(Object)); } }
void IClassWithID_InstanceAction(Type requestedType, IClassWithID instance, string name, FactoryAction action) { if (_factory_NotificationOrderingTest_typeList != null) { lock (_factory_NotificationOrderingTest_typeList) _factory_NotificationOrderingTest_typeList.Push(typeof(IClassWithID)); } }
void ClassWithDefaultConstructor_InstanceAction(Type requestedType, ClassWithDefaultConstructor instance, string name, FactoryAction action) { if (_factory_NotificationOrderingTest_typeList != null) { lock (_factory_NotificationOrderingTest_typeList) _factory_NotificationOrderingTest_typeList.Push(typeof(ClassWithDefaultConstructor)); } }
void Factory_CopierorTests_InstanceAction_TrackCallOrdering(Type requestedType, Factory_CopyConstructorTests.Item2 instance, string name, FactoryAction action) { Assert.IsNull(Interlocked.CompareExchange<Type>(ref _tracking, typeof(Item), null)); }
void Factory_CopierorTests_InstanceAction_ItemSubclass_TrackCallOrdering(Type requestedType, Factory_CopyConstructorTests.ItemSubclass instance, string name, FactoryAction action) { Assert.AreEqual(Interlocked.CompareExchange<Type>(ref _tracking, null, typeof(Item)), typeof(Item)); }