Beispiel #1
0
 public override void Configure(Funq.Container container)
 {
     container.RegisterAutoWiredAs<Login, ILogin>();
     container.RegisterAutoWiredAs<LabsNews, ILabsNews>();
     container.RegisterAutoWiredAs<NewsletterDal, INewsletterDal>();
     container.RegisterAutoWiredAs<NewsStorage, INewsStorage>();
 }
Beispiel #2
0
        public override void Configure(Funq.Container container)
        {
            //Set JSON web services to return idiomatic JSON camelCase properties
            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;
            container.DefaultReuse = ReuseScope.Request;
            container.Register<IBus>(NServiceBusConfig.Bus);
            container.RegisterAutoWiredAs<MasterContext, DbContext>();
            container.RegisterAutoWiredAs<BankAccountRepository, IBankAccountRepository>();

            /*
               var referencedTypes = BuildManager.GetReferencedAssemblies().OfType<Assembly>().Where(x => x.FullName.Contains("JK")).SelectMany(x => x.GetTypes());
            var implementations = referencedTypes.Where(x => !x.IsAbstract && !x.IsInterface);

            var interfacesWithOneImplementation =
                implementations.SelectMany(x => x.GetInterfaces())
                    .GroupBy(x => x)
                    .Where(x => x.Count() == 1)
                    .SelectMany(x => x)
                    .ToArray();

            var singleImplementations =
                from impl in implementations
                from iface in interfacesWithOneImplementation
                where impl.GetInterfaces().Contains(iface)
                select new { Type = impl, Interface = iface };

            var registerMethod = container.GetType().GetMethod("RegisterAutoWiredAs");

            foreach (var impl in singleImplementations)
            {
                var method = registerMethod.MakeGenericMethod(new[] { impl.Type, impl.Interface });
                method.Invoke(container, new object[0]);
            }
            */
        }
Beispiel #3
0
        public override void Configure(Funq.Container container)
        {
            container.RegisterAutoWiredAs<RegistrationRepository, IRegistrationRepository>();
            container.RegisterAutoWiredAs<GuidFactory, IGuidFactory>();

            Plugins.Add(new ValidationFeature());
            container.RegisterValidators(typeof (Global).Assembly);
        }
 private void InitializeContainer(Funq.Container container)
 {
     container.RegisterAutoWiredAs<PortfolioDetailsRepository, IPortfolioDetailsRepository>();
     container.RegisterAutoWiredAs<PortfolioDetailsManager, IPortfolioDetailsManager>();
     container.RegisterAutoWiredAs<EducationsRepository, IEducationsRepository>();
     container.RegisterAutoWiredAs<EducationsManager, IEducationsManager>();
     container.RegisterAutoWiredAs<ExperiencesRepository, IExperiencesRepository>();
     container.RegisterAutoWiredAs<ExperiencesManager, IExperiencesManager>();
     container.RegisterAutoWiredAs<SkillsRepository, ISkillsRepository>();
     container.RegisterAutoWiredAs<SkillsManager, ISkillsManager>();
     container.RegisterAutoWiredAs<ContactInformationsRepository, IContactInformationsRepository>();
     container.RegisterAutoWiredAs<ContactInformationsManager, IContactInformationsManager>();
 }
Beispiel #5
0
        public override void Configure(Funq.Container container)
        {
            ServiceStack.Text.JsConfig<Guid>.SerializeFn = guid => guid.ToString();
            ServiceStack.Text.JsConfig<Guid?>.SerializeFn = guid => guid.ToString();

            //Configure User Defined REST Paths
            //Routes
            //  .Add<Hello>("/hello")
            //  .Add<Hello>("/hello/{Name*}");

            //Uncomment to change the default ServiceStack configuration
            //SetConfig(new EndpointHostConfig {
            //});

            //Caching
            container.Register<IRedisClientsManager>(c =>
                new PooledRedisClientManager("localhost:6379"));
            container.Register<ICacheClient>(c =>
                (ICacheClient)c.Resolve<IRedisClientsManager>()
                .GetCacheClient())
                .ReusedWithin(Funq.ReuseScope.None);

            //Enable Authentication
            ConfigureAuth(container);

            //Register all your dependencies
            container.RegisterAutoWiredAs<TodoBizRepo, ITodoBizRepo>().ReusedWithin(ReuseScope.Request);

            //Set MVC to use the same Funq IOC as ServiceStack
            ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
        }
Beispiel #6
0
        public override void Configure(Funq.Container container) {
            //Set JSON web services to return idiomatic JSON camelCase properties
            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;

            //Configure User Defined REST Paths
            Routes
              .Add<Users>("/users")
              .Add<Users>("/users/{Username}");

            //Register all your dependencies		
            ;


            container.Register("authServer", c =>
                CryptoKeyPair.LoadCertificate(HostingEnvironment.MapPath("~/bin/Certificates/auth-server.pfx"), "p@ssw0rd"));
            container.Register("dataServer", c =>
                CryptoKeyPair.LoadCertificate(HostingEnvironment.MapPath("~/bin/Certificates/data-server.pfx"), "p@ssw0rd"));
            container.RegisterAutoWiredAs<FakeUserStore, IUserStore>();
        }
Beispiel #7
0
        public override void Configure(Funq.Container container)
        {
            //Set JSON web services to return idiomatic JSON camelCase properties
            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;

            //Configure User Defined REST Paths
            Routes
                .Add<Sms>("/sms")
                .Add<Schedule>("/schedule")
                .Add<Coordinator>("/coordinator");

            //Change the default ServiceStack configuration
            //SetConfig(new EndpointHostConfig {
            //    DebugMode = true, //Show StackTraces in responses in development
            //});

            //Enable Authentication
            //ConfigureAuth(container);

            //Register all your dependencies
            //container.Register(new TodoRepository());

            //Register In-Memory Cache provider.
            //For Distributed Cache Providers Use: PooledRedisClientManager, BasicRedisClientManager or see: https://github.com/ServiceStack/ServiceStack/wiki/Caching
            container.Register<ICacheClient>(new MemoryCacheClient());
            container.Register<ISessionFactory>(c =>
                new SessionFactory(c.Resolve<ICacheClient>()));

            container.RegisterAutoWiredAs<RavenDocStore, IRavenDocStore>();
            container.RegisterAutoWiredAs<DateTimeUtcFromOlsenMapping, IDateTimeUtcFromOlsenMapping>();
            container.RegisterAutoWiredAs<CoordinatorModelToMessageMapping, ICoordinatorModelToMessageMapping>();
            container.RegisterAutoWiredAs<CoordinatorApiModelToMessageMapping, ICoordinatorApiModelToMessageMapping>();
            container.RegisterAutoWiredAs<CurrentUser, ICurrentUser>();

            var busConfig = NServiceBus.Configure.With()
                .DefineEndpointName("SmsWeb")
                .DefaultBuilder()
                    .DefiningCommandsAs(t => t.Namespace != null && t.Namespace.EndsWith("Commands"))
                    .DefiningEventsAs(t => t.Namespace != null && t.Namespace.EndsWith("Events"))
                    .DefiningMessagesAs(t => t.Namespace == "SmsMessages")
                    .Log4Net()
                .XmlSerializer()
                .MsmqTransport()
                    .IsTransactional(true)
                    .PurgeOnStartup(false)
                .UnicastBus()
                    .LoadMessageHandlers();
            NServiceBus.Configure.Instance.Configurer.ConfigureComponent<RavenDocStore>(DependencyLifecycle.SingleInstance);
            NServiceBus.Configure.Instance.Configurer.ConfigureComponent<SmsScheduleStatusHandler>(DependencyLifecycle.InstancePerCall);
                    //.LoadMessageHandlers<SmsScheduleStatusHandler>();

            busConfig.Configurer.ConfigureComponent<DateTimeUtcFromOlsenMapping>(DependencyLifecycle.SingleInstance);

            var bus = busConfig.CreateBus().Start();//() => NServiceBus.Configure.Instance.ForInstallationOn<NServiceBus.Installation.Environments.Windows>().Install());

            //container.Register(new SmsScheduleStatusHandler(new RavenDocStore()));
            container.Register(bus);
            //Set MVC to use the same Funq IOC as ServiceStack
            ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
        }
 public override void Configure(Funq.Container container)
 {
     container.RegisterAutoWiredAs<InMemoryProjectModelRepo, IProjectModelRepository>();
     //container.Register(new InMemoryProjectModelRepo());
     //container.RegisterAs<InMemoryProjectModelRepo>();
 }
Beispiel #9
0
        private void registerSqlDataStore(Funq.Container container)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["Kleine"].ConnectionString;

            container.Register<OrmLiteConnectionFactory>(c => new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider));

            // register each individual repository
            container.RegisterAutoWiredAs<BaseSqlRepository<DueDate>, IRepository<DueDate>>();
            container.RegisterAutoWiredAs<ProfileSqlRepository, IProfileRepository>();
            container.RegisterAutoWiredAs<PredictionSqlRepository, IPredictionRepository>();
            container.RegisterAutoWiredAs<CookieTrackerSqlRepository, ICookieTrackerRepository>();
            container.RegisterAutoWiredAs<ResultsSqlRepository, IResultsRepository>();
            // register the main repository that has a reference to each repository
            container.RegisterAutoWiredAs<SqlRepositories, IRepositories>();
        }
Beispiel #10
0
 private void registerNotifications(Funq.Container container)
 {
     container.Register<EnvironmentSettings>(environmentSettings);
     container.RegisterAutoWiredAs<NotificationService, INotification>();
 }
Beispiel #11
0
        private void registerInMemoryStore(Funq.Container container)
        {
            // used for mocking database from dictionaries - need single "source" of each data type
            data = new InMemoryData();
            // register our data instance
            container.Register<InMemoryData>(data);
            container.Register<Dictionary<int, DueDate>>(data.DueDateData);

            // register repositories and autowire their dependencies
            container.RegisterAutoWiredAs<BaseMemoryRepository<DueDate>, IRepository<DueDate>>();
            container.RegisterAutoWiredAs<ProfileRepository, IProfileRepository>();
            container.RegisterAutoWiredAs<PredictionRepository, IPredictionRepository>();
            container.RegisterAutoWiredAs<CookieTrackerRepository, ICookieTrackerRepository>();
            container.RegisterAutoWiredAs<ResultsRepository, IResultsRepository>();

            container.RegisterAutoWiredAs<MemoryRepositories, MemoryRepositories>();
            container.RegisterAutoWiredAs<MemoryRepositories, IRepositories>();
        }
 void InitializeContainer(Funq.Container container)
 {
     container.RegisterAutoWiredAs<ElementsRepository, IElementsRepository>();
     container.RegisterAutoWiredAs<ElementsManager, IElementsManager>();
 }
            public override void Configure(Funq.Container container)
            {
                NRefactoryUtils.LoadReferencesInBackground();

                if (useInMemoryDataStore)
                    container.RegisterAutoWiredAs<InMemoryProjectModelRepo, IProjectModelRepository>();
                //else
                //    container.RegisterAutoWiredAs<PersistedProjectModelRepo, IProjectModelRepository>();

                // overkill for now...
                //SetConfig(new EndpointHostConfig()
                //{
                //    RawHttpHandlers = { httpRequest => httpRequest.}
                //});
                
                // adapted from https://github.com/ServiceStack/ServiceStack/wiki/Request-and-response-filters
                this.ResponseFilters.Add((httpReq, httpResp, dto) =>
                {
                    if (httpReq.ResponseContentType == ContentType.Json)
                    {
                        var helloResponse = dto as HelloResponse;
                        if (helloResponse != null && helloResponse.Result.ToLower().Contains("paul"))
                        {
                            httpResp.Write("{ \"Result\": \"Paul is da maaaan!!!!\" }");
                            httpResp.Close();
                        }

                        var fileOperationResponse = dto as FileOperationResponse;
                        if (fileOperationResponse != null)
                        {
                            string json = JsonConvert.SerializeObject(fileOperationResponse);
                            //string jsonResponse = string.Format("{{ \"autocomplete\": {0} }}", completionJson);
                            httpResp.Write(json);
                            httpResp.Close();
                        }

                        if (dto is ApiError)
                        {
                            //httpResp.Write(NO_RESULTS_RESPONSE);
                            string errorJson = JsonConvert.SerializeObject(dto);
                            httpResp.Write(errorJson);
                            httpResp.Close();
                        }
                    }
                });

                Routes
                    // Local test URL:  http://localhost:1337/api/autocomplete/478/174/424/21/1
                    // OR:  http://localhost:1337/api/autocomplete?iuserid=478&iprojectid=174&ifileid=423&irow=21&icolumn=1&format=json
                    // OR:  http://localhost:1337/api/autocomplete?iuserid=478&iprojectid=174&ifileid=423&irow=36&icolumn=1&format=json
                    // 
                    .Add<AutoCompleteRequest>("/api/autocomplete/{UserId}/{ProjectId}/{FileId}/{Line}/{Column}")
                    .Add<AutoCompleteRequest>("/api/autocomplete/{UserId}/{ProjectId}/{FileId}")
                    .Add<AutoCompleteRequest>("/api/autocomplete")
                    .Add<Hello>("/hello")
                    .Add<Hello>("/hello/{Name}");
            }