Ejemplo n.º 1
0
        private void OwinStartup(IAppBuilder app)
        {
            HttpConfiguration   config = new HttpConfiguration();
            IDependencyResolver resolver;

#if true
            Unity.IUnityContainer uc = new Unity.UnityContainer();

            uc.RegisterInstance(typeof(IPlop), new Plop());
            resolver = new UnityResolver(uc);
#else
            Autofac.ContainerBuilder builder = new Autofac.ContainerBuilder();

            builder.RegisterApiControllers(typeof(WorkerRole).Assembly);
            builder.RegisterInstance(new Plop()).As <IPlop>();
            Autofac.IContainer container = builder.Build();

            app.UseAutofacMiddleware(container);
            app.UseAutofacWebApi(config);
            resolver = new AutofacWebApiDependencyResolver(container);
#endif

            config.DependencyResolver = resolver;
            config.MapHttpAttributeRoutes();
            config.EnsureInitialized();

            app.UseWebApi(config);
        }
Ejemplo n.º 2
0
        static void Main()
        {
            Unity.UnityContainer container = new Unity.UnityContainer();
            Unity.ServiceLocation.UnityServiceLocator unityServiceLocator = new Unity.ServiceLocation.UnityServiceLocator(container);

            //Registrar tipos de operaciones con entidades
            container.RegisterInstance <FUMIT.Entidades.FumitDbContext>(new Entidades.FumitDbContext());
            container.RegisterType <AccesoDatos.IClientes, ClientesRepositorio>();
            container.RegisterType <AccesoDatos.ISucursales, SucursalesRepositorio>();
            container.RegisterType <IProgramacionServicios, ProgramacionServiciosRepositorio>();
            container.RegisterType <IProgramacionServiciosCliente, ProgramacionServiciosClienteRepositorio>();
            container.RegisterType <ICiclosFacturacion, CiclosFacturacionRepositorio>();
            container.RegisterType <IServiciosProgramados, ServiciosProgramadosRepositorio>();
            container.RegisterType <IServicio, ServiciosRepositorio>();
            container.RegisterType <IContactos, ContactosRepositorio>();
            container.RegisterType <IVSProgramacionServiciosCliente, VSProgramacionServiciosClienteRepositorio>();
            container.RegisterType <ICicloFacturacionClientes, CiclosFactuacionClienteRepositorio>();
            container.RegisterType <IEquipos, EquiposRepositorio>();
            container.RegisterType <ITipoEquipos, TipoEquiposRepositorio>();
            container.RegisterType <IAsignacionesEquipo, AsignacionesEquipoRepositorio>();
            container.RegisterType <IMantenimientos, MantenimientosRepositorio>();
            container.RegisterType <IMantenimientosEquipo, MantenimientosEquipoRepositorio>();
            container.RegisterType <ICalendarioSemanalServicios, CalendarioSemanalServiciosRepositorio>();
            container.RegisterType <IOperadores, OperadoresRepositorio>();
            container.RegisterType <ITickets, TicketsRepositorio>();
            container.RegisterType <IContenedoresTicket, ContenedoresTicketRepositorio>();

            //Se registra ExceptionManager
            Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionManager manager = Exceptions.ExceptionHandlingPolicies.InicializarPoliticas();
            container.RegisterInstance(manager, new SingletonLifetimeManager());

            //Se registra service locator
            ServiceLocator.SetLocatorProvider(() => unityServiceLocator);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            PantallaPrincipal pantallaPrincipal = new PantallaPrincipal();
            //pantallaPrincipal.tsbEstado
            var notificador = new NotificadorBarraEstado(pantallaPrincipal.statusStrip1);

            notificador.ControlMostrarMensajes = pantallaPrincipal.tsbEstado;

            container.RegisterInstance <INotificador>("BarraDeEstado", notificador, new SingletonLifetimeManager());

            Application.Run(pantallaPrincipal);
        }
Ejemplo n.º 3
0
        private static void RegisterAutoMapper(Unity.UnityContainer container)
        {
            var config = new MapperConfiguration(cfg => { cfg.CreateMap <CustomerVehicle, SaveCustomerVehicleRequest>(); });

            var mapper = config.CreateMapper();

            container.RegisterInstance(mapper);
        }
Ejemplo n.º 4
0
        private static void RegisterTelemetryClient(Unity.UnityContainer container)
        {
            var telemetryClient = new TelemetryClient {
                InstrumentationKey = Key
            };

            container.RegisterInstance(telemetryClient, new ContainerControlledLifetimeManager());
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            Dataflow dataflow      = new Dataflow();
            var      notifyService = new StockQuoteService(dataflow);
            //=======================================================================================================
            // Call this before you initialize a new BackgroundJobServer()
            var container = new Unity.UnityContainer();

            GlobalConfiguration.Configuration.UseActivator(new UnityJobActivator(container));
            container.RegisterInstance <IDataflow>(dataflow);
            container.RegisterInstance <INotifyService>(notifyService);
            //=======================================================================================================
            JobStorage storage = new MemoryStorage(new MemoryStorageOptions());

            LogProvider.SetCurrentLogProvider(new ColouredConsoleLogProvider());
            var serverOptions = new BackgroundJobServerOptions()
            {
                ShutdownTimeout = TimeSpan.FromSeconds(5)
            };
            var server = new BackgroundJobServer(serverOptions, storage);

            JobStorage.Current = storage;

            Log("Hangfire Server started. Press any key to exit...", LogLevel.Fatal);
            //=======================================================================================================
            //ServiceHost host = new ServiceHost(typeof(StockQuoteService), new Uri("http://localhost:12345/StockQuoteService.svc"));
            //host.Open();
            var host = new ServiceHost(typeof(StockQuoteService), new Uri("http://localhost:12345/StockQuoteService.svc"));
            //object instanceService = Activator.CreateInstance(typeof(StockQuoteService), dataflow);
            //IServiceBehavior instanceBehavior = Activator.CreateInstance(typeof(StockQuoteServiceBehavior), instanceService) as IServiceBehavior;
            object           instanceService  = Activator.CreateInstance(typeof(StockQuoteService), dataflow);
            IServiceBehavior instanceBehavior = Activator.CreateInstance(typeof(StockQuoteServiceBehavior), notifyService) as IServiceBehavior;

            host.Description.Behaviors.Add(instanceBehavior);
            host.Open();
            SesionSocketRunConsole.Start();
            //=======================================================================================================

            BackgroundJob.Enqueue <JobTest>(x => x.Execute("Hello, world!"));
            //=======================================================================================================
            Console.WriteLine("Enter to exit ...");
            Console.ReadLine();
        }
Ejemplo n.º 6
0
        private static void RegisterAutoMapper(Unity.UnityContainer container)
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <GetAppointmentSlotsRequest, CDKGetAppointmentSlotsRequest>();
            });
            var mapper = config.CreateMapper();

            container.RegisterInstance(mapper);
        }
Ejemplo n.º 7
0
        private static void RegisterAutoMapper(Unity.UnityContainer container)
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <DealerConfigurationCreateRequest, DealerConfiguration>();
                cfg.CreateMap <DealerConfigurationUpdateRequest, DealerConfiguration>();
                cfg.CreateMap <DealerConfiguration, DealerConfigurationResponse>();
                cfg.CreateMap <DealerConfiguration, DealerInvitationContentResponse>();
            });
            var mapper = config.CreateMapper();

            container.RegisterInstance(mapper);
        }
Ejemplo n.º 8
0
        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="container">The unity container to configure.</param>
        public static void RegisterTypes(Unity.UnityContainer container)
        {
            switch (ChooseMovieStoreFromConfig())
            {
            case MovieStoreFlag.Datastore:
                container.RegisterInstance(
                    new DatastoreMovieStore(ProjectId));
                break;

                //case MovieStoreFlag.MySql:
                //    container.RegisterType<IMovieStore, DbMovieStore>();
                //    break;

                //case MovieStoreFlag.SqlServer:
                //    container.RegisterType<IMovieStore, DbMovieStore>();
                //    break;
            }

            container.RegisterInstance <ImageUploader>(
                new ImageUploader(
                    GetConfigVariable("GoogleCloudSamples:BucketName")
                    )
                );
        }
Ejemplo n.º 9
0
        private static void RegisterAutoMapper(Unity.UnityContainer container)
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <SaveCustomerVehicleRequest, Customer>();
                cfg.CreateMap <SaveCustomerVehicleRequest, CustomerVehicle>();
                cfg.CreateMap <Customer, RegisterCustomerRequest>()
                .ForMember(dest => dest.RoofTopId, opt => opt.ResolveUsing(src => src.RooftopId))
                .ForMember(dest => dest.EmailAddress, opt => opt.ResolveUsing(src => src.CustomerEmail));
                cfg.CreateMap <CustomerVehicle, RegisterCustomerRequest>()
                .ForMember(dest => dest.RegistrationNumber, opt => opt.ResolveUsing(src => src.RegistrationNo))
                .ForMember(dest => dest.VehicleId, opt => opt.ResolveUsing(src => src.VehicleNo));
                cfg.CreateMap <Customer, GetCustomerVehicleResponse>();
                cfg.CreateMap <CustomerVehicle, GetCustomerVehicleResponse>();
                cfg.CreateMap <Customer, VerifyCustomerRequest>()
                .ForMember(dest => dest.RoofTopId, opt => opt.ResolveUsing(src => src.RooftopId));
                cfg.CreateMap <SaveCustomerVehicleRequest, Invitation>()
                .ForMember(dest => dest.ContactDetail, opt => opt.ResolveUsing(src => src.PhoneNumber));
                cfg.CreateMap <CreateServiceBookingRequest, ServiceBookings>();
                cfg.CreateMap <CreateServiceBookingResponse, ServiceBookings>()
                .ForMember(dest => dest.BookingReference, opt => opt.ResolveUsing(src => src.WipNo.ToString()));
                cfg.CreateMap <CreateServiceBookingRequest, CDKCreateServiceBookingRequest>();
                cfg.CreateMap <Customer, CDKCreateServiceBookingRequest>()
                .ForMember(dest => dest.MobileTelNo, opt => opt.ResolveUsing(src => src.PhoneNumber))
                .ForMember(dest => dest.EmailAddress, opt => opt.ResolveUsing(src => src.CustomerEmail));
                cfg.CreateMap <CustomerVehicle, CDKCreateServiceBookingRequest>()
                .ForMember(dest => dest.VehicleRegistrationNo, opt => opt.ResolveUsing(src => src.RegistrationNo))
                .ForMember(dest => dest.VehMakeCode, opt => opt.ResolveUsing(src => src.MakeCode))
                .ForMember(dest => dest.VehModelCode, opt => opt.ResolveUsing(src => src.ModelCode))
                .ForMember(dest => dest.VehVariantCode, opt => opt.ResolveUsing(src => src.VariantCode));
            });

            var mapper = config.CreateMapper();

            container.RegisterInstance(mapper);
        }
Ejemplo n.º 10
0
        private static void RegisterSendGridClient(Unity.UnityContainer container)
        {
            var sendGridClient = new SendGridClient(SendGridAPIKey);

            container.RegisterInstance <ISendGridClient>(sendGridClient, new ContainerControlledLifetimeManager());
        }