public void CreateModelBinder() { var container = new StructureMapContainer(); IFeature coreServices = new Dolstagis.Web.Lifecycle.CoreServices(); coreServices.ContainerBuilder.SetupApplication(container); binder = container.Get<ModelBinder>(); }
private void ChangeTaddYoungVisitOneToCheckedIn() { StructureMapContainer.Configure( s => s.For <IVisitStatusRepository> ().Use(new VisitStatusRepository(SessionProvider))); TaddYoungVisitOne.CheckIn(new DateTime(2002, 3, 28, 9, 0, 0)); Session.SaveOrUpdate(TaddYoungVisitOne); }
private static void InicializadorInyectorDependencia() { var ioc = new StructureMapContainer(); ioc.Configure(); new StructureMapDependencyResolver(ObjectFactory.Container); new StructureMapFilterProvider(ObjectFactory.Container); }
public override IContainer CreateAndConfigureContainer(GetLoggerDelegate getLoggerDelegate, IDictionary<Type, Func<IDataAccessContext, IDataContext>> createDataContexts) { structureMapContainer = Configure.CreateAndConfigureContainer(getLoggerDelegate, createDataContexts, container => container.Configure(c => c.SetAllProperties(s => s.TypeMatches(type => container.Model.HasImplementationsFor(type)))), additionalRegistries.Concat(new[] { new CommonRegistry() }).ToArray()); return structureMapContainer; }
protected void Application_Start() { DependencyResolver.SetResolver(new StructureMapDependencyResolver(StructureMapContainer.Create())); XmlConfigurator.Configure(); AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); }
protected override void OnSetup() { base.OnSetup(); StructureMapContainer.Configure( x => x.Scan(scanner => { scanner.AssembliesFromApplicationBaseDirectory(p => (p.FullName == null) ? false : p.FullName.Contains("HL7Generator.Infrastructure")); scanner.LookForRegistries(); })); }
static IFetchDependencies create_container() { var structure_map_container = new Container(base_config); var container = new StructureMapContainer(structure_map_container); structure_map_container.Configure(x => { x.ForSingletonOf<IFetchDependencies>().Add(context => container); x.ForSingletonOf<IContainer>().Add(context => structure_map_container); }); return container; }
public void ShouldGetInstanceOfRegisteredType() { // Arrange var busContainer = new StructureMapContainer(); busContainer.AddHandler(typeof(IMessageHandler <MyMessage>), new MyMessageHandler()); // Act var result = busContainer.GetInstance(typeof(IMessageHandler <MyMessage>)); // Assert Assert.NotNull(result); Assert.Equal("MyMessageHandler", result.GetType().Name); }
public void ShouldGetAllHandlerReferences() { // Arrange var busContainer = new StructureMapContainer(); busContainer.AddHandler(typeof(IMessageHandler <MyMessage>), new MyMessageHandler()); // Act var result = busContainer.GetHandlerTypes(); // Assert Assert.NotNull(result); Assert.Equal(1, result.Count()); Assert.Equal("MyMessage", result.ToList()[0].MessageType.Name); Assert.Equal("MyMessageHandler", result.ToList()[0].HandlerType.Name); }
protected void Application_Start() { IIoCContainer container = new StructureMapContainer(); //IIoCContainer container = new AutofacContainer(); //IIoCContainer container = Activator.CreateInstance( // Type.GetType("DDD.Infrastructure.IoC.StructureMapContainer,DDD.Infrastructure") // ) as IIoCContainer; container.Add <ISimpleRepository, SimpleRepository>(); container.Add <ISimpleService, SimpleService>(); IoCEngine.Init(container); ControllerBuilder.Current.SetControllerFactory(new IoCControllerFactory()); AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); }
public void ShouldGetInstanceOfRegisteredTypeWithCtorParameters() { // Arrange var busContainer = new StructureMapContainer(); busContainer.AddHandler(typeof(IMessageHandler <MyMessage>), new MyMessageHandler2("TestName")); // Act var result = busContainer.GetInstance <IMessageHandler <MyMessage> >(new Dictionary <string, object> { { "name", "TestName" } }); // Assert Assert.NotNull(result); Assert.Equal("MyMessageHandler2", result.GetType().Name); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var container = new StructureMapContainer(); var config = Configuration.Default(container); GetAssemblies().ForEach(a => config.Register(a)); config.DefaultShowAs("window").SetViewBinder(new WpfViewBinder()); config.SetErrorPresenter<ErrorPresenter>(); config.AddPresenter<WindowPresenter>(); config.AddPresenter<MdiPresenter>(); "open routelog".Send(); "request login".Send(); }
protected virtual void SetupSystemAccountProvider() { var systemAccount = new SystemAccount("{2342-23434593-345345-345-345-3}", "sytemuser displayname", new EmailAddress("*****@*****.**"), "uri:FakeProvider", "FakeProvider"); using (ITransaction trans = Session.BeginTransaction()) { Session.SaveOrUpdate(systemAccount); trans.Commit(); } var systemAccountProviderMock = new Mock <ISystemAccountProvider> (); systemAccountProviderMock .SetupGet(x => x.SystemAccount) .Returns(systemAccount); StructureMapContainer.Configure(s => s .For <ISystemAccountProvider> () .Singleton() .Use(systemAccountProviderMock.Object)); }
public ClientFacade() { this.clientRepo = StructureMapContainer.GetContainer().GetInstance <IClientRepository>(); this.customerRepo = StructureMapContainer.GetContainer().GetInstance <ICustomerRepository>(); this.projectRepo = StructureMapContainer.GetContainer().GetInstance <IProjectRepository>(); }
public concerns_using_a_real_container() { the_container = ObjectFactory.Container; sut = new StructureMapContainer(the_container); }
protected concerns_using_a_fake_container() { the_container = container_mock.Object; sut = new StructureMapContainer(the_container); }
static InversionControl() { Current = new StructureMapContainer(); }
protected override void OnSetup() { base.OnSetup(); StructureMapContainer.Configure( c => { c.For <IAccessControlManager> ().Use(AccessControlManager); c.For <IVisitStatusRepository> ().Use(new VisitStatusRepository(SessionProvider)); c.For <IRuleCollectionFactory>().Use <RuleCollectionFactory>(); c.Scan(x => { // in the scan operation, include all needed dlls (Rem.*) // be cautious in the future - this could still pick up unwanted assemblies, // such as the stray test project that mistakenly ends up in the bin folder. // so consider those possibilities if errors pop up, and you're led here. x.AssembliesFromApplicationBaseDirectory(p => (p.FullName == null) ? false : p.FullName.Contains("Rem.")); x.ConnectImplementationsToTypesClosing(typeof(IRuleCollection <>)); x.ConnectImplementationsToTypesClosing(typeof(IRuleCollectionCustomizer <,>)); }); }); using (ITransaction trans = Session.BeginTransaction()) { SafeHarborAgency = BuildAgency(TreatmentProviderAgencyType, "Safe Harbor", "Safe Harbor"); AgencyAddressAndPhone safeHarborWayAgencyAddressAndPhone = SafeHarborAgency.AddAddressAndPhone( new AgencyAddress( AdministrationAgencyAddressType, new AddressBuilder().WithFirstStreetAddress("123 Safe Harbor Way").WithCityName("Columbia").WithStateProvince( MarylandStateProvince).WithPostalCode(new PostalCode("21046")))); safeHarborWayAgencyAddressAndPhone.AddPhone( new AgencyPhoneBuilder().WithAgencyPhoneType(TollFreeAgencyPhoneType).WithPhone( new PhoneBuilder().WithPhoneNumber(("555-555-5555")))); safeHarborWayAgencyAddressAndPhone.AddPhone( new AgencyPhoneBuilder().WithAgencyPhoneType(FaxAgencyPhoneType).WithPhone( new PhoneBuilder().WithPhoneNumber(("666-666-6666")))); SafeHarborAgency.AddIdentifier( new AgencyIdentifierBuilder().WithAgencyIdentifierType(NpiAgencyIdentifierType).WithIdentifierNumber("154975646")); SafeHarborAgency.AddAgencyAlias(new AgencyAliasBuilder().WithName("Safe Harbor Ent").Build()); LeoSmithStaff = BuildStaff(SafeHarborAgency, "Leo", "Smith"); WendyJonesStaff = BuildStaff(SafeHarborAgency, "Wendy", "Jones"); SheilaAndersonStaff = BuildStaff(SafeHarborAgency, "Sheila", "Anderson"); BethKnoxStaff = BuildStaff(SafeHarborAgency, "Beth", "Knox"); AnthonyBellStaff = BuildStaff(SafeHarborAgency, "Anthony", "Bell"); SafeHarborAgency.AddContact( new AgencyContactBuilder().WithAgencyContactType(CeoAgencyContactType).WithContactStaff(LeoSmithStaff).WithStatusIndicator(true)); SafeHarborAgency.AddContact( new AgencyContactBuilder().WithAgencyContactType(BillingAgencyContactType).WithContactStaff(BethKnoxStaff).WithStatusIndicator( false)); SafeHarborLocation = BuildLocation(SafeHarborAgency, "Safe Harbor Counseling Center"); BuildAlbertSmithPatient(); AlbertSmithPatientAllergyOne = BuildAllergy(AlbertSmithPatient, ActiveAllergyStatus, AllergenCodedConcept); AlbertSmithPatientMedicationOne = BuildMedication(AlbertSmithPatient, MedicationCodeCodedConcept); AlbertSmithPatientClinicalCaseOne = BuildClinicalCase(AlbertSmithPatient, SafeHarborLocation, 1); AlbertSmithPatientClinicalCaseTwo = BuildClinicalCase(AlbertSmithPatient, SafeHarborLocation, 2); AlbertSmithPatientClinicalCaseOneProblemOne = BuildProblem(AlbertSmithPatientClinicalCaseOne, ProblemCodeCodedConcept); AlbertSmithPatientClinicalCaseOneProblemTwo = BuildProblem(AlbertSmithPatientClinicalCaseOne, ProblemCodeCodedConcept); AlbertSmithPatientClinicalCaseOneProblemThree = BuildProblem(AlbertSmithPatientClinicalCaseOne, ProblemCodeCodedConcept); AlbertSmithPatientClinicalCaseOneProblemThree.UpdateProblemStatus(ActiveProblemStatus, DateTime.Now); AlbertSmithPatientClinicalCaseOneVisitOne = BuildScheduledVisit( LeoSmithStaff, new DateTimeRange(new DateTime(2002, 3, 28, 9, 0, 0), new DateTime(2002, 3, 28, 10, 0, 0)), AlbertSmithPatientClinicalCaseOne); AlbertSmithPatientClinicalCaseOneVisitTwo = BuildScheduledVisit( LeoSmithStaff, new DateTimeRange(new DateTime(2010, 3, 28, 9, 0, 0), new DateTime(2010, 3, 28, 10, 0, 0)), AlbertSmithPatientClinicalCaseOne); AlbertSmithPatientClinicalCaseOneVisitThree = BuildScheduledVisit( LeoSmithStaff, new DateTimeRange(new DateTime(2011, 3, 28, 9, 0, 0), new DateTime(2011, 3, 28, 10, 0, 0)), AlbertSmithPatientClinicalCaseOne, AlbertSmithPatientClinicalCaseOneProblemThree); AlbertSmithPatientClinicalCaseOneVisitFour = BuildCheckedInVisit( LeoSmithStaff, new DateTimeRange(new DateTime(2011, 3, 28, 9, 0, 0), new DateTime(2011, 3, 28, 10, 0, 0)), AlbertSmithPatientClinicalCaseOne); AlbertSmithPatientClinicalCaseOneVisitOneLabSpecimenOne = BuildLabSpecimen( AlbertSmithPatientClinicalCaseOneVisitOne, LabSpecimentActivityType); AlbertSmithPatientClinicalCaseOneVisitOneLabSpecimenTwo = BuildLabSpecimen( AlbertSmithPatientClinicalCaseOneVisitOne, LabSpecimentActivityType); AlbertSmithPatientClinicalCaseOneVisitOneLabSpecimenOneLabTestOne = BuildLabTest(AlbertSmithPatientClinicalCaseOneVisitOneLabSpecimenOne, LabTestNameCodedConcept); AlbertSmithPatientClinicalCaseOneVisitOneLabSpecimenOneLabTestTwo = BuildLabTest(AlbertSmithPatientClinicalCaseOneVisitOneLabSpecimenOne, LabTestNameCodedConcept); AlbertSmithPatientClinicalCaseOneVisitOneLabSpecimenOneLabTestOneLabResultOne = BuildLabResult(AlbertSmithPatientClinicalCaseOneVisitOneLabSpecimenOneLabTestOne, LabTestResultNameCodedConcept, 15.09); AlbertSmithPatientClinicalCaseOneVisitOneLabSpecimenOneLabTestOneLabResultTwo = BuildLabResult(AlbertSmithPatientClinicalCaseOneVisitOneLabSpecimenOneLabTestOne, LabTestResultNameCodedConcept, 19.67); AlbertSmithPatientClinicalCaseOneVisitFourImmunizationOne = BuildImmunization( AlbertSmithPatientClinicalCaseOneVisitFour, ImmunizationActivityType); AlbertSmithPatientClinicalCaseOneVisitFourImmunizationTwo = BuildImmunization( AlbertSmithPatientClinicalCaseOneVisitFour, ImmunizationActivityType, MmrVaccineCodedConcept); AlbertSmithPatientClinicalCaseOneVisitOneVitalSignOne = BuildVitalSign(AlbertSmithPatientClinicalCaseOneVisitOne, 3, 0, 50); BuildTaddYoungPatient(); TaddYoungPatientClinicalCaseOne = BuildClinicalCase(TaddYoungPatient, SafeHarborLocation, 1); TaddYoungVisitOne = BuildScheduledVisit( LeoSmithStaff, new DateTimeRange(new DateTime(2002, 3, 28, 9, 0, 0), new DateTime(2002, 3, 28, 10, 0, 0)), TaddYoungPatientClinicalCaseOne); ChangeTaddYoungVisitOneToCheckedIn(); TaddYoungVitalSignOne = BuildVitalSign(TaddYoungVisitOne, 3, 0, 50); trans.Commit(); } Session.Clear(); }
static void Start(IContainer container, Action<ExtensionInitializer> initializeAction) { _log.Debug("Parsing command line"); IEnumerable<Command> commands = CommandLine.Parse<Command>(init => { var containerConfigurator = new StructureMapContainerConfigurator(container); var containerAccess = new StructureMapContainer(container); container.Configure(x => { x.For<core.Container>().Singleton().Use(containerAccess); x.For<ContainerConfigurator>().Singleton().Use(containerConfigurator); }); var initializer = container.With(init).GetInstance<StructureMapExtensionInitializer>(); initializeAction(initializer); }).ToArray(); if (commands.Any()) { ExecuteCommands(commands); } else { _log.Warn("No commands specified"); } }
protected override void OnSetup() { base.OnSetup(); StructureMapContainer.Configure( s => s.For <IPatientFactory> ().Use(new PatientFactory(new PatientRepository(SessionProvider), new PatientUniqueIdentifierGenerator()))); }
public CustomerFacade(int clientId) : base(clientId) { customerRepository = StructureMapContainer.GetContainer().GetInstance <ICustomerRepository>(); projectRepository = StructureMapContainer.GetContainer().GetInstance <IProjectRepository>(); taskRepository = StructureMapContainer.GetContainer().GetInstance <ITaskRepository>(); }
static IoC() { Current = new StructureMapContainer(); }
public DeveloperFacade() { this.devRep = StructureMapContainer.GetContainer().GetInstance <IDeveloperRepository>(); this.taskRep = StructureMapContainer.GetContainer().GetInstance <ITaskRepository>(); }
public concerns_using_a_real_container() { the_container = new StructureMap.Container(); sut = new StructureMapContainer(the_container); }