当前位置: 首页>>代码示例>>C#>>正文


C# Funq.RegisterAutoWired方法代码示例

本文整理汇总了C#中Funq.RegisterAutoWired方法的典型用法代码示例。如果您正苦于以下问题:C# Funq.RegisterAutoWired方法的具体用法?C# Funq.RegisterAutoWired怎么用?C# Funq.RegisterAutoWired使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Funq的用法示例。


在下文中一共展示了Funq.RegisterAutoWired方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Configure

        public override void Configure(Funq.Container container)
        {
            container.Register<IDbConnectionFactory>(
                    c =>
                        new OrmLiteConnectionFactory("~/App_Data/db.sqlite".MapHostAbsolutePath(),
                            SqliteDialect.Provider)
                        {
                            ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
                        });

            container.RegisterAutoWired<JournalService>();
            container.RegisterAutoWired<SessionService>();

            using (var db = container.Resolve<IDbConnectionFactory>().Open())
            {
                db.DropAndCreateTable<Journal>();
                db.DropAndCreateTable<Session>();
                db.DropAndCreateTable<Task>();
                db.DropAndCreateTable<JournalNote>();
                db.DropAndCreateTable<SessionNote>();

                //Seed Lists
                db.InsertAll(SeedData.JournalSeed);
                db.InsertAll(SeedData.JournalNoteSeed);
                db.InsertAll(SeedData.SessionSeed);
                db.InsertAll(SeedData.TaskSeed);
                db.InsertAll(SeedData.SessionNoteSeed);
            }
        }
开发者ID:KyleGobel,项目名称:Systematize,代码行数:29,代码来源:AppHost.cs

示例2: Configure

        public override void Configure(Funq.Container container)
        {
            container.RegisterAutoWired<PlayersRepository>();

            Plugins.Add(new ValidationFeature());

            container.RegisterValidators(typeof(AppHost).Assembly);
        }
开发者ID:TaiAivaras,项目名称:angularjs-dotnet-book,代码行数:8,代码来源:AppHost.cs

示例3: RegisterDependencies

        private void RegisterDependencies(Funq.Container container)
        {
            var ormLiteConnectionFactory =
                new OrmLiteConnectionFactory(System.IO.Path.GetFullPath("~/../../../App_Data/data.db"), SqliteDialect.Provider);

            container.Register<IDbConnectionFactory>(ormLiteConnectionFactory);
            container.RegisterAutoWired<CommandRepository>();
        }
开发者ID:arifkh,项目名称:GettingDressed,代码行数:8,代码来源:CommandService.cs

示例4: Configure

            public override void Configure(Funq.Container container)
            {
                //var dbConnectionFactory = new OrmLiteConnectionFactory
                //        (WebConfigurationManager.ConnectionStrings["snomed"].ToString(),
                //        SqlServerOrmLiteDialectProvider.Instance);
                //container.Register<IDbConnectionFactory>(dbConnectionFactory);
                //using (var db = dbConnectionFactory.Open())
                //{
                //    db.CreateTable<Concept>();
                //}

                container.RegisterAutoWired<DataRepository>();
            }
开发者ID:danlulu,项目名称:SNOMED-CT-SearchTool,代码行数:13,代码来源:Global.asax.cs

示例5: Configure

 public override void Configure(Funq.Container container)
 {
     Plugins.Add(new CorsFeature());
     //GlobalRequestFilters.Add((httpReq, httpRes, requestDto) =>
     //{
     //    if (httpReq.HttpMethod == "OPTIONS")
     //    {
     //        httpRes.EndRequest();
     //    }
     //});
     var dbConnectionFactory = new OrmLiteConnectionFactory(HttpContext.Current.Server.MapPath("~/App_Data/wordData.txt"), SqliteDialect.Provider);
     container.Register<IDbConnectionFactory>(dbConnectionFactory);
     container.RegisterAutoWired<DataRepository>();
 }
开发者ID:gendary,项目名称:FlashCard,代码行数:14,代码来源:Global.asax.cs

示例6: Configure

        public override void Configure(Funq.Container container)
        {
            //Set JSON web services to return idiomatic JSON camelCase properties
            JsConfig.EmitCamelCaseNames = true;

            //Register Typed Config some services might need to access
            var appConfig = new AppConfig(new AppSettings());

            //appconfig will contain properties from web.config
            container.Register(appConfig);

            //inform api that this will be using BasicAuth to authenticate/authorize users
            Plugins.Add(new AuthFeature(
                () => new AuthUserSession(),
                new IAuthProvider[] { new BasicAuthProvider(), }));

            //add registration functionality (user will need admin role to access this)
            Plugins.Add(new RegistrationFeature());

            //add validation using fluent validation package
            Plugins.Add(new ValidationFeature());

            //register service to validate
            container.RegisterValidators(typeof(AwardService).Assembly);

            if (appConfig.UseRedis){
                //setup cache client to user redis
                container.Register<IRedisClientsManager>(c => new PooledRedisClientManager(appConfig.RedisReadWriteHosts.ToArray()));
                container.Register<ICacheClient>(c => c.Resolve<IRedisClientsManager>().GetCacheClient());

                //setup redis for authentication repository
                container.Register<IUserAuthRepository>(c => new RedisAuthRepository(c.Resolve<IRedisClientsManager>()));
            }
            else
            {
                //setup cache client to be InMemory
                container.Register<ICacheClient>(c => new MemoryCacheClient());

                //setup authentication repository to be InMemory
                container.Register<IUserAuthRepository>(c => new InMemoryAuthRepository());
            }
            

            //seed possible users
            SeedUsers(container.Resolve<IUserAuthRepository>());

            //register any repository classes here
            container.RegisterAutoWired<AwardRepository>();
        }
开发者ID:arron-green,项目名称:ServiceStack.Example,代码行数:49,代码来源:AppHost.cs

示例7: Configure

 public override void Configure(Funq.Container container)
 {
     Plugins.Add(new CorsFeature());
     RequestFilters.Add((httpReq, httpRes, requestDto) =>
     {
         //Handles Request and closes Responses after emitting global HTTP Headers
         if (httpReq.HttpMethod == "OPTIONS")
             httpRes.EndRequest();
     });
     var dbConnectionFactory =
         new OrmLiteConnectionFactory(HttpContext.Current.Server.MapPath("~/App_Data/bookData.txt"),
             SqliteDialect.Provider);
     container.Register<IDbConnectionFactory>(dbConnectionFactory);
     container.RegisterAutoWired<DataRepository>();
 }
开发者ID:robertohernando,项目名称:Building-Web-Applications-with-Open-Source-Software-on-Windows,代码行数:15,代码来源:Global.asax.cs

示例8: Configure

            public override void Configure(Funq.Container container)
            {
                Plugins.Add(new CorsFeature());
                PreRequestFilters.Add((httpReq, httpRes) =>
                {
                    if (httpReq.Verb == "OPTIONS")
                        httpRes.EndRequest();
                });

                var dbConnectionFactory =
                    new OrmLiteConnectionFactory(HttpContext.Current.Server.MapPath("~/App_Data/bookdata.txt"),
                        SqliteDialect.Provider);

                container.Register<IDbConnectionFactory>(dbConnectionFactory);
                container.RegisterAutoWired<DataRepository>();
            }
开发者ID:ov3rs33r,项目名称:BookStoreManager,代码行数:16,代码来源:Global.asax.cs

示例9: Configure

            public override void Configure(Funq.Container container)
            {
                container.RegisterAutoWired<DataRepository>();

                Plugins.Add(new CorsFeature(
                    allowOriginWhitelist: new[] { "http://localhost:36085", "http://localhost", "http://hwl59427d", "http://edwaitingtimes-test", "http://edwaitingtimes" },
                    allowedHeaders: "Content-Type",
                    allowCredentials: true
                    ));

                // Globally enable CORS for all OPTION requests
                this.PreRequestFilters.Add((httpReq, httpRes) =>
                {
                    //Handles Request and closes Responses after emitting global HTTP Headers
                    if (httpReq.Verb == "OPTIONS")
                        httpRes.EndRequest();
                });

                //Set JSON web services to return idiomatic JSON camelCase properties
                ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;
            }
开发者ID:danlulu,项目名称:FHIRWebService,代码行数:21,代码来源:Global.asax.cs

示例10: Configure

            public override void Configure(Funq.Container container)
            {
                //to inject third-party IoC (for example for NInject use SrviceStack.ContainerAdapter.NInject)
                //IKernel kernel=new StandartKernel();
                //kernel.Bind<TrackedDataRepository>().ToSelf();
                //container.Adapter=new NinjectContainerAdapter(kernel);  -> provide a adapter layer for NInject to use in Funq

                Plugins.Add(new AuthFeature(() => new AuthUserSession(),
                            new IAuthProvider[] { new BasicAuthProvider() ,
                                new TwitterAuthProvider(new AppSettings())}));

                Plugins.Add(new RegistrationFeature());

                //register validators
                Plugins.Add(new ValidationFeature());
                container.RegisterValidators(typeof(Common.Entry).Assembly, typeof(EntryService).Assembly);

                //request logs
                Plugins.Add(new RequestLogsFeature()); // added ability to view request via http:/..../requestlogs

                //cache registration
                container.Register<ICacheClient>(new MemoryCacheClient());
                container.Register<IRedisClientsManager>(new PooledRedisClientManager("localhost:6379"));
                //container.Register<ICacheClient>(r => (ICacheClient)r.Resolve<IRedisClientsManager>().GetCacheClient());

                var userRepository = new InMemoryAuthRepository();
                container.Register<IUserAuthRepository>(userRepository);

                string hash;
                string salt;
                new SaltedHash().GetHashAndSaltString("password1", out hash, out salt);

                userRepository.CreateUserAuth(new UserAuth()
                {
                    Id = 1,
                    DisplayName = "Joe user",
                    Email = "[email protected]",
                    UserName = "jsuser",
                    LastName = "jname",
                    PasswordHash = hash,
                    Salt = salt,
                    Roles = new List<string> { RoleNames.Admin }//,
                    //Permissions = new List<string> { "GetStatus", "AddStatus" }
                }, "password1");

                //automatically inject in all public properties
                container.RegisterAutoWired<TrackedDataRepository>().ReusedWithin(Funq.ReuseScope.Default);
                container.RegisterAutoWired<TrackedDataRepository2>().ReusedWithin(Funq.ReuseScope.Default);

                var dbConFactory = new OrmLiteConnectionFactory(HttpContext.Current.Server.MapPath("~/App_Data/data.txt"), SqliteDialect.Provider)
                {
                    ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
                };
                container.Register<IDbConnectionFactory>(dbConFactory);

                SetConfig(new EndpointHostConfig { DebugMode = true });

                var mqService = new RedisMqServer(container.Resolve<IRedisClientsManager>());
                mqService.RegisterHandler<Entry>(ServiceController.ExecuteMessage);
                mqService.Start();

                //install Razor
                Plugins.Add(new RazorFormat());
            }
开发者ID:OleksandrKulchytskyi,项目名称:NServiceStack-Test,代码行数:64,代码来源:Global.asax.cs


注:本文中的Funq.RegisterAutoWired方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。