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


C# Funq.Resolve方法代码示例

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


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

示例1: Configure

        public override void Configure(Funq.Container container)
        {
            const Feature disableFeatures = Feature.Jsv | Feature.Soap;

            SetConfig(new EndpointHostConfig
            {
                EnableFeatures = Feature.All.Remove(disableFeatures),
                DebugMode = true,
                GlobalResponseHeaders =
                {
                    { "Access-Control-Allow-Origin", "*" },
                    { "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" },
                }
            });

            container.Register<IResourceManager>(new ConfigurationResourceManager());
            container.Register<IValidator<Todo>>(new TodoValidator());

            container.Register(c => new Config(c.Resolve<IResourceManager>()));
            var appConfig = container.Resolve<Config>();

            container.Register<IDbConnectionFactory>(c =>
                new OrmLiteConnectionFactory(appConfig.ConnectionString, SqlServerOrmLiteDialectProvider.Instance));

            ConfigureDatabase.Init(container.Resolve<IDbConnectionFactory>());

            Routes
                .Add<Todos>("/todos")
                .Add<Todos>("/todos/{Id}");

            log.InfoFormat("AppHost Configured: " + DateTime.Now);
        }
开发者ID:seba-i,项目名称:Template,代码行数:32,代码来源:AppHost.cs

示例2: AddDummyUserIfRequired

        public static void AddDummyUserIfRequired(Funq.Container container)
        {
            // create a dummy user
            var fac = container.Resolve<IDbConnectionFactory> ();
            using (var db = fac.OpenDbConnection ()) {

                if (db.FirstOrDefault<DBUser> (u => u.Username == "dummy") == null) {

                    var user = new DBUser ();
                    user.Username = "dummy";
                    user.CreateCryptoFields ("foobar123");
                    user.FirstName = "John Dummy";
                    user.LastName = "Doe";
                    user.AdditionalData  = "Dummy user that is created when in development mode";
                    user.IsActivated = true;
                    user.IsVerified = true;
                    user.Manifest.LastSyncRevision = 0;
                    user.EmailAddress = "[email protected]";
                    db.Insert<DBUser> (user);
                    // insert some sample notes
                    var f = container.Resolve<IDbStorageFactory> ();
                    var key = user.GetPlaintextMasterKey ("foobar123");
                    var r = new RequestingUser {
                        Username = "dummy",
                        EncryptionMasterKey = key.ToHexString ()
                    };
                    using (var storage = f.GetDbStorage (r)) {
                        var sample_notes = new DiskStorage ();
                        sample_notes.SetPath ("../../../sample_notes/");
                        sample_notes.CopyTo (storage);
                    }

                }
            }
        }
开发者ID:rashoodkhan,项目名称:Rainy,代码行数:35,代码来源:Main.cs

示例3: ConfigureContainer

        /// <summary>
        /// The configure container.
        /// </summary>
        /// <param name="container">
        /// The container.
        /// </param>
        public override void ConfigureContainer(Funq.Container container)
        {
            container.Register<ISearcher>(ExamineManager.Instance.SearchProviderCollection["GravyframeNewsSearcher"]);
            container.Register<INodeFactoryFacade>(new NodeFactoryFacade());
            container.Register<INewsConfiguration>(
                new NewsConfiguration(container.Resolve<INodeFactoryFacade>(), 1069));

            container.Register<NewsDao<UmbracoNews>>(
                new NewsDao(
                    container.Resolve<INewsConfiguration>(),
                    container.Resolve<INodeFactoryFacade>(),
                    container.Resolve<ISearcher>()));

            container.Register<IResponseHydrogenationTaskList<NewsRequest, NewsResponse<UmbracoNews>>>(
                new NewsResponseHydrogenationTaskList(container));
        }
开发者ID:gravypower,项目名称:Gravyframe,代码行数:22,代码来源:UmbracoNewsConfigurationStrategy.cs

示例4: Configure

        public override void Configure(Funq.Container container)
        {
            //Resource manager
            container.Register<IResourceManager>(new ConfigurationResourceManager());
            var appSettings = container.Resolve<IResourceManager>();

            Plugins.Add(new SessionFeature());

            string redis = appSettings.GetString("redis_connection_string");
            container.Register<IRedisClientsManager>(c => new BasicRedisClientManager(redis));

            // Register storage for user sessions 
            container.Register<ICacheClient>(c => c.Resolve<IRedisClientsManager>().GetCacheClient()).ReusedWithin(Funq.ReuseScope.None);
            container.Register<ISessionFactory>(c => new SessionFactory(c.Resolve<ICacheClient>()));

            // Set JSON web services to return idiomatic JSON camelCase properties
            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;

            // Validation
            Plugins.Add(new ValidationFeature());
            container.RegisterValidators(typeof(Namespace_ApiProject).Assembly);

            Plugins.Add(new AuthFeature(() => new CustomUserSession(),
                                        new IAuthProvider[]
                                        {
                                            new FbOAuth2Provider(appSettings),
                                            new VkOAuth2Provider(appSettings),
                                        }));
            
            //container.Register<ICacheClient>(new MemoryCacheClient());
            Plugins.Add(new ServiceStack.Api.Swagger.SwaggerFeature());

            container.Adapter = new StructureMapContainerAdapter();
        }
开发者ID:Ontropix,项目名称:whowhat,代码行数:34,代码来源:ServiceStackConfigurator.cs

示例5: 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

示例6: ConfigureAuth

		/* Uncomment to enable ServiceStack Authentication and CustomUserSession */
		private void ConfigureAuth(Funq.Container container)
		{
			var appSettings = new AppSettings();

			//Default route: /auth/{provider}
			Plugins.Add(new AuthFeature(() => new CustomUserSession(),
				new IAuthProvider[] {
					new AcmeCredentialsAuthProvider(appSettings), 
				})); 

			//Default route: /register
			Plugins.Add(new RegistrationFeature()); 

			//Requires ConnectionString configured in Web.Config
			var connectionString = ConfigurationManager.ConnectionStrings["SSHelloWorldAuth"].ConnectionString;
			container.Register<IDbConnectionFactory>(c =>
				new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider));

			container.Register<IUserAuthRepository>(c =>
				new OrmLiteAuthRepository(c.Resolve<IDbConnectionFactory>()));

			var authRepo = (OrmLiteAuthRepository)container.Resolve<IUserAuthRepository>();
			authRepo.CreateMissingTables();

            // CreateUser(authRepo, 1, "testuser", null, "Test2#4%");
		}
开发者ID:kshkrao3,项目名称:Enehana.CodeSamples,代码行数:27,代码来源:AppHost.cs

示例7: Configure

        public override void Configure(Funq.Container container)
        {
            //Set JSON web services to return idiomatic JSON camelCase properties
            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;
            ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
            var appSettings = new AppSettings();
            var connString = appSettings.Get("SQLSERVER_CONNECTION_STRING",
                                             ConfigUtils.GetConnectionString("UserAuth"));
            container.Register<IDbConnectionFactory>(
                new OrmLiteConnectionFactory(connString, SqlServerDialect.Provider));

            //Using an in-memory cache
            container.Register<ICacheClient>(new MemoryCacheClient());
            ConfigureAuth(container);
            var dbFactory = container.Resolve<IDbConnectionFactory>();
            dbFactory.Run(d => d.CreateTableIfNotExists<UserAuth>());
            dbFactory.Run(db => db.CreateTableIfNotExists<Message>());
            dbFactory.Run(d => d.CreateTableIfNotExists<Device>());

            SetConfig(new EndpointHostConfig
            {
                DefaultContentType = ContentType.Json,
                EnableFeatures = Feature.All.Remove(Feature.Html).Remove(Feature.Xml),
                AppendUtf8CharsetOnContentTypes = new HashSet<string> { ContentType.Json }
            });
            //Or if Haz Redis
            //container.Register<ICacheClient>(new PooledRedisClientManager());
        }
开发者ID:joshua1,项目名称:MvcPortal,代码行数:28,代码来源:AppHost.cs

示例8: Configure

            public override void Configure(Funq.Container container)
            {
                Routes
                    .Add<Hello>("/hello")
                    .Add<Hello>("/hello/{Name}");
                helloService = container.Resolve<HelloService>();

                AuthFeature authFeature = new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] {new BasicAuthProvider(), new TwitterAuthProvider(new AppSettings()),});
                //authFeature.HtmlRedirect
                Plugins.Add(authFeature);
                MemoryCacheClient memoryCacheClient = new MemoryCacheClient();
                container.Register<ICacheClient>(memoryCacheClient);

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

                string hash;
                string salt;
                string password = "password";
                new SaltedHash().GetHashAndSaltString(password, out hash, out salt);
                userRepository.CreateUserAuth(
                    new UserAuth {
                        Id = 1,
                        DisplayName = "JoeUser",
                        Email = "[email protected]",
                        UserName = "juser",
                        FirstName = "Joe",
                        LastName = "User",
                        PasswordHash = hash,
                        Salt = salt,
                    }, password);
                //IHttpResult authenticationRequired = helloService.AuthenticationRequired(); // ????
            }
开发者ID:Bhavesh-Patel,项目名称:Jukebox,代码行数:33,代码来源:Program.cs

示例9: Configure

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

            container.Register<ICacheClient>(new MemoryCacheClient());
            container.Register<IDbConnectionFactory>(
                new OrmLiteConnectionFactory(ConfigurationManager.ConnectionStrings["Db"].ToString(), SqlServerDialect.Provider));

            Plugins.Add(new ValidationFeature());
            container.RegisterValidators(typeof(MeetingValidator).Assembly);

            //https://github.com/ServiceStack/ServiceStack/wiki/Authentication-and-authorization#userauth-persistence---the-iuserauthrepository
            //Use ServiceStacks authentication/authorization persistence

            var userRep = new OrmLiteAuthRepository(container.Resolve<IDbConnectionFactory>());
            container.Register<IUserAuthRepository>(userRep);
            userRep.CreateMissingTables(); //Create missing Auth

            var appSettings = new AppSettings();
            Plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[]
                {
                    new CredentialsAuthProvider(),
                    new GoogleOpenIdOAuthProvider(appSettings),
                }));

            Plugins.Add(new RegistrationFeature());

            //Set MVC to use the same Funq IOC as ServiceStack
            ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
        }
开发者ID:paaschpa,项目名称:MidwestGeeks,代码行数:31,代码来源:AppHost.cs

示例10: ConfigureAuth

        /* Example ServiceStack Authentication and CustomUserSession */
        private void ConfigureAuth(Funq.Container container)
        {
            var appSettings = new AppSettings();

            //Default route: /auth/{provider}
            Plugins.Add(new AuthFeature(() => new CustomUserSession(),
                new IAuthProvider[] {
                    new CredentialsAuthProvider(appSettings),
                    new FacebookAuthProvider(appSettings),
                    new TwitterAuthProvider(appSettings),
                    new BasicAuthProvider(appSettings),
                }));

            //Default route: /register
            Plugins.Add(new RegistrationFeature());

            //Requires ConnectionString configured in Web.Config
            var connectionString = ConfigurationManager.ConnectionStrings["AppDb"].ConnectionString;
            container.Register<IDbConnectionFactory>(c =>
                new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider));

            container.Register<IUserAuthRepository>(c =>
                new OrmLiteAuthRepository(c.Resolve<IDbConnectionFactory>()));

            container.Resolve<IUserAuthRepository>().InitSchema();
        }
开发者ID:chennysnow,项目名称:SimpleDemo,代码行数:27,代码来源:AppHost.cs

示例11: Configure

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

            var connectionString = ConfigurationManager.ConnectionStrings["conString"].ToString();
            Register<IDbConnectionFactory>(new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider));

            var appSettings = new AppSettings();
            Plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[]
                {
                    new CredentialsAuthProvider(),
                    new FacebookAuthProvider(appSettings),
                    new GoogleOpenIdOAuthProvider(appSettings),
                }));

            Plugins.Add(new RegistrationFeature());

            var userRep = new OrmLiteAuthRepository(container.Resolve<IDbConnectionFactory>());
            container.Register<IUserAuthRepository>(userRep);
            var redisCon = ConfigurationManager.AppSettings["redisUrl"].ToString();
            container.Register<IRedisClientsManager>(new PooledRedisClientManager(20, 60, redisCon));
            container.Register<ICacheClient>(c => (ICacheClient)c.Resolve<IRedisClientsManager>().GetCacheClient());

            userRep.CreateMissingTables();
            //Set MVC to use the same Funq IOC as ServiceStack
            ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
        }
开发者ID:paaschpa,项目名称:leaderboard,代码行数:28,代码来源:AppHost.cs

示例12: CreateMissingTables

        public void CreateMissingTables(Funq.Container container)
        {
            using (IDbConnection db = dbConnectionFactory.OpenDbConnection())
            {
                ((OrmLiteAuthRepository)container.Resolve<IUserAuthRepository>()).CreateMissingTables();

                db.CreateTableIfNotExists<CategoryModels>();
                db.CreateTableIfNotExists<BookModels>();
                db.CreateTableIfNotExists<BookPropertyModels>();
            }
        }
开发者ID:samranjbari,项目名称:MiniBookStore,代码行数:11,代码来源:DatabaseConfiguration.cs

示例13: Configure

        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<Hello>("/hello")
            //  .Add<Hello>("/hello/{Name*}")
              //.Add<Events>("/Events/")
              //.Add<Events>("/Events/{Lag*}");

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

            //Enable Authentication
            //ConfigureAuth(container);

              var appSettings = new AppSettings();

              string baseApiUrl = appSettings.Get("BaseApiUrl","foo");
            //Register all your dependencies
            //            container.Register<IJellybeanDispenser>(c => new VanillaJellybeanDispenser());
            //            container.Register(c => new SweetVendingMachine(c.Resolve<IJellybeanDispenser>()));
            //            container.Register(c => new SweetShop(c.Resolve<SweetVendingMachine>()));
            // See more at: http://anthonysteele.co.uk/the-funq-ioc-container#sthash.ketDSF72.dpuf
            container.Register<IAppConfig>(c=>new AppConfig());
            container.Register<IEventRepository>(c=> new EventRepository());
            container.Resolve<IEventRepository>().Config = container.Resolve<IAppConfig>();
               // container.Register(c => new TodoRepository());

            //Register a external dependency-free
            container.Register<ICacheClient>(new MemoryCacheClient());
            //Configure an alt. distributed persistent cache that survives AppDomain restarts. e.g Redis
            //container.Register<IRedisClientsManager>(c => new PooledRedisClientManager("localhost:6379"));

            //Set MVC to use the same Funq IOC as ServiceStack
            ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
        }
开发者ID:patriklindstrom,项目名称:AppEventViewer,代码行数:40,代码来源:AppHost.cs

示例14: Configure

        /// <summary>
        /// Configures the application host.
        /// </summary>
        /// <param name="container">The container.</param>
        public override void Configure(Funq.Container container)
        {
            // Set JSON web services to return idiomatic JSON camelCase properties
            ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;

            // Create the connection factory for our database.
            var factory = new OrmLiteConnectionFactory(WebConfigurationManager.ConnectionStrings["SquarePeg"].ConnectionString, MySqlDialect.Provider);

            // Register database.
            container.Register(c => factory.OpenDbConnection());

            // Register logging.
            container.Register<ILog>(c => LogManager.GetLogger(this.GetType()));

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

            // Register repositories
            container.Register<IBoardsRepository>(c => new BoardsRepository(container.Resolve<IDbConnection>()));

            // Register services.
            container.Register<IBoardsService>(
                c => new BoardsService(container.Resolve<IBoardsRepository>(), container.Resolve<ICacheClient>()));

            // Configure the authentiation.
            this.ConfigureAuth(container, factory);

            // Set the sharec container; this is used by other shared omponents such as aspects.
            SharedContainer.Container = container;

            // Set MVC to use the same Funq IOC as ServiceStack
            ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
        }
开发者ID:robertschultz,项目名称:squarepeg,代码行数:41,代码来源:AppHost.cs

示例15: 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


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