public void AddFactory() { var factory = MockDependencyFactory(_contract); _dependencies.AddFactory(factory.Object); _dependencies.Contains(_contract).Should().BeTrue(); }
public static DependencyCollection AddMapper(this DependencyCollection collection) { var contract = typeof(IMapper <>); var implementation = typeof(CompiledMapper <>); collection.AddFactory(new GenericFactory(contract, implementation, DependencyLifetime.Singleton)); return(collection); }
public static DependencyCollection AddEmitter(this DependencyCollection collection) { collection .AddFactory(new PipelineFactory(PipelineTypes.Command)) .AddFactory(new PipelineFactory(PipelineTypes.Notification)) .AddFactory(new PipelineFactory(PipelineTypes.Query)) .AddScoped <Emitter>(); return(collection); }
public void TryRegister(DependencyCollection collection, Type implementation) { var contracts = ReflectionUtils.GetGenericInterfaceImplementations(implementation, _processorTypes); if (contracts.Length == 0) { return; } if (implementation.IsGenericTypeDefinition) { var contract = contracts[0]; collection.AddFactory(new GenericFactory(contract, implementation, _lifetime)); } else { contracts.Add(implementation); collection.AddDependency(contracts.ToArray(), implementation, _lifetime); } }