public void IOCFactoryTest() { //无参构造函数测试 var f = new IOCFactory(); Assert.IsNotNull(f.Assemblies); Assert.AreEqual(0, f.Assemblies.Length); Assert.IsNull(f.Container); Assert.IsNull(f.Builder); f.Dispose(); //操作选项传递测试 var op = new FactoryOption(); f = new IOCFactory(op, this.GetType().Assembly); Assert.IsNotNull(f.Assemblies); Assert.AreEqual(op, f.Option); Assert.IsNull(f.Container); Assert.IsNull(f.Builder); f.Dispose(); //测试无任何操作 op = new FactoryOption { InitOption = InitOptionEnum.None }; f = new IOCFactory(op, this.GetType().Assembly); Assert.IsNotNull(f.Assemblies); Assert.AreEqual(op, f.Option); Assert.IsNull(f.Container); Assert.IsNull(f.Builder); f.Dispose(); }
/// <summary> /// 提供初始化操作选项和,程序集构造IOC工厂 /// </summary> /// <param name="option">工厂选项</param> /// <param name="assemblyNames">程序集名称</param> public IOCFactory(FactoryOption option, params string[] assemblyNames) { this.Option = option; this.Assemblies = ToAssenbly(assemblyNames); }
/// <summary> /// 通过提供工厂选项和程序集构造IOC工厂 /// </summary> /// <param name="option">工厂选项</param> /// <param name="assemblies">程序集</param> public IOCFactory(FactoryOption option, params Assembly[] assemblies) { this.Option = option; this.Assemblies = assemblies; }
/// <summary> /// /// </summary> /// <param name="jObject"></param> /// <returns></returns> public override TOption ObtainCustomObject(JObject jObject) { return(FactoryOption <TOption, TEnum> .GenerateOption(jObject.Value <string>("OptionType"))); }