本文整理汇总了C#中Funq类的典型用法代码示例。如果您正苦于以下问题:C# Funq类的具体用法?C# Funq怎么用?C# Funq使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Funq类属于命名空间,在下文中一共展示了Funq类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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));
}
示例2: Configure
public override void Configure(Funq.Container container)
{
PathProvider.BinaryPath = "~".MapAbsolutePath();
ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;
RequestBinders.Add(typeof(CommitAttempt), request => new CommitAttempt()
{
UserAgent = request.Headers["User-Agent"],
RawBody = request.GetRawBody()
});
Routes
.Add<CommitAttempt>("/commit")
.Add<CommitMessages>("/commits")
.Add<MessageErrors>("/errors")
// //.Add<CommitMessage>("/commitMessage")
;
var redisFactory = new PooledRedisClientManager("localhost:6379");
container.Register<IRedisClientsManager>(redisFactory);
//var mqHost = new RedisMqHost(redisFactory);
var mqHost = new RedisMqServer(redisFactory);
container.Register<IMessageService>(mqHost);
container.Register(mqHost.MessageFactory);
mqHost.RegisterHandler<CommitAttempt>(ServiceController.ExecuteMessage);
//mqHost.RegisterHandler<CommitMessage>(ServiceController.ExecuteMessage);
mqHost.Start();
}
示例3: Configure
public override void Configure(Funq.Container container)
{
var appConfig = (TsonServiceConfig)this.Container.Resolve<ITsonServiceConfig>();
JsConfig.EmitCamelCaseNames = true;
SetConfig(
new HostConfig
{
EnableFeatures = Feature.All & ~Feature.Soap,
DefaultContentType = "application/json",
AppendUtf8CharsetOnContentTypes = new HashSet<string>
{
"application/json", "application/xml"
},
#if DEBUG
DebugMode = true,
#else
DebugMode = false,
#endif
});
log.Info(appConfig.ToString());
Plugins.Add(new ToolBelt.ServiceStack.CorsFeature(
allowOrigins: appConfig.CorsAllowedOrigins,
allowHeaders: ToolBelt.ServiceStack.CorsFeature.DefaultHeaders + ",Accept",
exposeHeaders: true,
allowCredentials: false
));
}
示例4: 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<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));
}
示例5: Configure
/// <summary>
/// AppHostHttpListenerBase method.
/// </summary>
/// <param name="container">SS's funq container</param>
public override void Configure(Funq.Container container) {
EndpointHostConfig.Instance.GlobalResponseHeaders.Clear();
//Signal advanced web browsers what HTTP Methods you accept
//base.SetConfig(new EndpointHostConfig());
Routes.Add<PlainText>("/test/plaintext", "GET");
}
示例6: Configure
public override void Configure(Funq.Container container)
{
//register any dependencies your services use, e.g:
//container.Register<ICacheClient>(new MemoryCacheClient());
Plugins.Add (new SwaggerFeature ());
Routes.Add<LocationRequest> ("/Location/Update/", "POST");
SetConfig (new EndpointHostConfig {
DebugMode = true
});
this.PreRequestFilters.Add ((req, resp) => {
});
this.RequestFilters.Add ((IHttpRequest httpReq, IHttpResponse httpResp, object requestDto) => {
var appSettings = new AppSettings ();
if (httpReq.Headers ["Authorization-API"] == null) {
throw HttpError.Unauthorized ("No Authorization Header provided");
}
string storedAPIKey = appSettings.Get ("GeoAPIKey", "");
string passedAPIKey = httpReq.Headers ["Authorization-API"];
if (String.IsNullOrEmpty (storedAPIKey)) {
throw HttpError.Unauthorized ("API Key not configured");
} else if (storedAPIKey != passedAPIKey) {
throw HttpError.Unauthorized ("API Key passed from the client was not found");
}
});
}
示例7: 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<Todo>("/todos")
.Add<Todo>("/todos/{Id}");
//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.Register<IRedisClientsManager>(c => new PooledRedisClientManager("ec2-54-247-0-119.eu-west-1.compute.amazonaws.com:6379"));
//container.Register<ICacheClient>(c => (ICacheClient)c.Resolve<IRedisClientsManager>().GetCacheClient());
//Set MVC to use the same Funq IOC as ServiceStack
ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
}
示例8: Configure
public override void Configure(Funq.Container container)
{
//Set JSON web services to return idiomatic JSON camelCase properties
ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;
var dataFilePath = AppDomain.CurrentDomain.GetData("DataDirectory").ToString() + "\\data.db";
container.Register<IDbConnectionFactory>(new OrmLiteConnectionFactory(dataFilePath, SqliteOrmLiteDialectProvider.Instance));
new DataSeeder().Seed(); //Comment out to stop resetting the data
//Configure User Defined REST Paths
Routes
.Add<Hello>("/hello")
.Add<Hello>("/hello/{Name*}");
//Uncomment to change the default ServiceStack configuration
//SetConfig(new EndpointHostConfig {
// EnableFeatures = Feature.All.Remove(Feature.Metadata)
//});
//Enable Authentication
//ConfigureAuth(container);
//Register all your dependencies
container.Register(new TodoRepository());
//Set MVC to use the same Funq IOC as ServiceStack
ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
}
示例9: 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);
}
示例10: Configure
public override void Configure(Funq.Container container)
{
// To hook in windsor as default container
var windsorContainer = new WindsorContainer();
Container.Adapter = new WindsorContainerAdapter(windsorContainer);
//Set JSON web services to return idiomatic JSON camelCase properties
ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;
//Configure User Defined REST Paths
Routes
.Add<HelloRequest>("/hello")
.Add<HelloRequest>("/hello/{Name*}");
//Uncomment to change the default ServiceStack configuration
SetConfig(new EndpointHostConfig {
DebugMode = true //Show StackTraces when developing
//EnableFeatures = Feature.Json | Feature.Metadata
});
//Register all your dependencies
//Using an in-memory cache
windsorContainer.Register(Component.For<ICacheClient>().ImplementedBy<MemoryCacheClient>());
this.RequestFilters.Add((request, response, requestDto) =>
{
var x = 1;
});
this.ResponseFilters.Add((request, response, responseDto) =>
{
var x = 1;
});
}
示例11: Configure
public override void Configure(Funq.Container container)
{
SetConfig(new EndpointHostConfig { ServiceStackHandlerFactoryPath = "api"});
container.Register<IRedisClientsManager>(c => new PooledRedisClientManager());
container.Register<IRepository>(c => new Repository(c.Resolve<IRedisClientsManager>()));
}
示例12: Configure
public override void Configure(Funq.Container container)
{
//Set JSON web services to return idiomatic JSON camelCase properties
ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;
// ServiceStack.Text.JsConfig.EmitLowercaseUnderscoreNames = true;
//Configure User Defined REST Paths
//Routes
// .Add<Hello>("/hello")
// .Add<Hello>("/hello/{Name*}");
//Uncomment to change the default ServiceStack configuration
//SetConfig(new EndpointHostConfig {
//});
//Enable Authentication
//ConfigureAuth(container);
//Register all your dependencies
//container.Register(new TodoRepository());
container.Register<IRedisClientsManager>(new BasicRedisClientManager("localhost:6379"));
//Set MVC to use the same Funq IOC as ServiceStack
ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
}
示例13: Configure
public override void Configure(Funq.Container container)
{
container.Register(this.buildManager);
//this.Routes.Add<IEnumerable<TinyBuildStatus>>("/status")
// .Add<TinyBuildStatus>("/status/{Id}");
}
示例14: Configure
public override void Configure(Funq.Container container)
{
container.RegisterAutoWiredAs<Login, ILogin>();
container.RegisterAutoWiredAs<LabsNews, ILabsNews>();
container.RegisterAutoWiredAs<NewsletterDal, INewsletterDal>();
container.RegisterAutoWiredAs<NewsStorage, INewsStorage>();
}
示例15: Configure
public override void Configure(Funq.Container container)
{
Plugins.Add(new CorsFeature());
Plugins.Add(new SwaggerFeature());
//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*}");
//Uncomment to change the default ServiceStack configuration
//SetConfig(new HostConfig
//{
//});
//Enable Authentication
//ConfigureAuth(container);
//Register all your dependencies
container.Register(new TodoRepository());
//Set MVC to use the same Funq IOC as ServiceStack
ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
}