本文整理汇总了C#中Funq.Container类的典型用法代码示例。如果您正苦于以下问题:C# Container类的具体用法?C# Container怎么用?C# Container使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Container类属于Funq命名空间,在下文中一共展示了Container类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Configure
public override void Configure(Container container)
{
SetConfig(new EndpointHostConfig
{
UseBclJsonSerializers = true,
});
}
开发者ID:jamez14,项目名称:pluralxamarin,代码行数:7,代码来源:TestConfigAppHostHttpListener.cs
示例2: Configure
public override void Configure(Container container)
{
HostConfig.Instance.DefaultRedirectPath = DefaultRedirectPath;
HostConfig.Instance.MapExceptionToStatusCode = new Dictionary<Type, int>
{
{typeof (InvalidOperationException), 422},
{typeof (ResourceNotFoundException), 404},
{typeof (FileNotFoundException), 404},
{typeof (DirectoryNotFoundException), 404},
{typeof (Implementations.Security.AuthenticationException), 401}
};
HostConfig.Instance.DebugMode = true;
HostConfig.Instance.LogFactory = LogManager.LogFactory;
// The Markdown feature causes slow startup times (5 mins+) on cold boots for some users
// Custom format allows images
HostConfig.Instance.EnableFeatures = Feature.Csv | Feature.Html | Feature.Json | Feature.Jsv | Feature.Metadata | Feature.Xml | Feature.CustomFormat;
container.Adapter = _containerAdapter;
Plugins.Add(new SwaggerFeature());
Plugins.Add(new CorsFeature(allowedHeaders: "Content-Type, Authorization"));
//Plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] {
// new SessionAuthProvider(_containerAdapter.Resolve<ISessionContext>()),
//}));
HostContext.GlobalResponseFilters.Add(new ResponseFilter(_logger).FilterResponse);
}
开发者ID:rsolmn,项目名称:MediaBrowser,代码行数:32,代码来源:HttpListenerHost.cs
示例3: Install
public void Install(Container container)
{
var userRepo = new InMemoryAuthRepository();
container.Register<IUserAuthRepository>(userRepo);
//HACK: Add default users
var users = new[]
{
new User("Admin", "AdminPassword"),
new User("cyberzed", "cyberzed")
};
foreach (var user in users)
{
string hash;
string salt;
new SaltedHash().GetHashAndSaltString(user.Password, out hash, out salt);
userRepo.CreateUserAuth(
new UserAuth
{
DisplayName = user.Username,
UserName = user.Username,
PasswordHash = hash,
Salt = salt
},
user.Password);
}
}
开发者ID:cyberzed,项目名称:ServiceStack_Intro,代码行数:31,代码来源:AuthInstaller.cs
示例4: Configure
public override void Configure(Container container)
{
JsConfig.EmitCamelCaseNames = true;
Plugins.Add(new RazorFormat());
//Comment out 2 lines below to change to use local FileSystem instead of S3
var s3Client = new AmazonS3Client(AwsConfig.AwsAccessKey, AwsConfig.AwsSecretKey, RegionEndpoint.USEast1);
VirtualFiles = new S3VirtualPathProvider(s3Client, AwsConfig.S3BucketName, this);
container.Register<IPocoDynamo>(c => new PocoDynamo(AwsConfig.CreateAmazonDynamoDb()));
var db = container.Resolve<IPocoDynamo>();
db.RegisterTable<Todos.Todo>();
db.RegisterTable<EmailContacts.Email>();
db.RegisterTable<EmailContacts.Contact>();
db.InitSchema();
//AWS Auth
container.Register<ICacheClient>(new DynamoDbCacheClient(db, initSchema:true));
container.Register<IAuthRepository>(new DynamoDbAuthRepository(db, initSchema:true));
Plugins.Add(CreateAuthFeature());
//EmailContacts
ConfigureSqsMqServer(container);
ConfigureEmailer(container);
Plugins.Add(new ValidationFeature());
container.RegisterValidators(typeof(EmailContacts.CreateContact).Assembly);
}
开发者ID:ServiceStackApps,项目名称:AwsApps,代码行数:27,代码来源:AppHost.cs
示例5: Configure
public override void Configure(Container container)
{
Plugins.Add(new RazorFormat());
Plugins.Add(new MsgPackFormat());
Plugins.Add(new SwaggerFeature { UseBootstrapTheme = true });
typeof(SwaggerResources)
.AddAttributes(new RestrictAttribute { VisibilityTo = RequestAttributes.None });
typeof(SwaggerResource)
.AddAttributes(new RestrictAttribute { VisibilityTo = RequestAttributes.None });
var metadata = (MetadataFeature)Plugins.First(x => x is MetadataFeature);
metadata.IndexPageFilter = page => {
page.OperationNames.Sort((x,y) => y.CompareTo(x));
};
container.Register<IDbConnectionFactory>(
new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider));
InitData(container);
SetConfig(new HostConfig {
DebugMode = true,
});
this.CustomErrorHttpHandlers[HttpStatusCode.ExpectationFailed] = new RazorHandler("/expectationfailed");
}
开发者ID:ricardoshimoda,项目名称:ServiceStack,代码行数:27,代码来源:AppHost.cs
示例6: Configure
/// <summary>
/// Configure the Web Application host.
/// </summary>
/// <param name="container">The IoC container.</param>
public override void Configure(Container container)
{
// Configure ServiceStack host
ConfigureHost(container);
// Configure JSON serialization properties
ConfigureSerialization(container);
// Configure application settings and configuration parameters
ConfigureApplication(container);
// Configure database schema synchronization
ConfigureDataSchema(container);
// Configure ServiceStack database connections
ConfigureDataConnection(container);
// Configure caching mechanism
ConfigureCache(container);
// Configure ServiceStack Authentication plugin
ConfigureUserAuth(container);
// Configure ServiceStack Fluent Validation plugin
ConfigureValidation(container);
// Configure ServiceStack Razor views
ConfigureView(container);
// Configure various system tools / features
ConfigureTools(container);
}
开发者ID:hhandoko,项目名称:sslakka_archive,代码行数:36,代码来源:AppHost.cs
示例7: Configure
public override void Configure(Container container)
{
LogManager.LogFactory = new ConsoleLogFactory();
SetConfig(new HostConfig
{
DebugMode = true,
EmbeddedResourceSources = { Assembly.GetExecutingAssembly() },
});
Plugins.Add(new RazorFormat
{
LoadFromAssemblies = { typeof(RockstarsService).Assembly }
});
Plugins.Add(new PostmanFeature());
Plugins.Add(new CorsFeature());
container.Register<IDbConnectionFactory>(
new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider));
using (var db = container.Resolve<IDbConnectionFactory>().OpenDbConnection())
{
db.CreateTableIfNotExists<Rockstar>();
db.InsertAll(RockstarsService.SeedData);
}
this.CustomErrorHttpHandlers[HttpStatusCode.NotFound] = new RazorHandler("/notfound");
this.CustomErrorHttpHandlers[HttpStatusCode.Unauthorized] = new RazorHandler("/login");
}
开发者ID:ServiceStackApps,项目名称:RazorRockstars,代码行数:29,代码来源:AppHost.cs
示例8: RegisterRepositories
private static void RegisterRepositories(Container container)
{
container.Register<IUserTokenRepository>(
c => new UserTokenRecordRepository(c.Resolve<IDataConnectionProvider>()));
container.Register<IServiceProviderRepository>(
c => new ServiceProviderRepository(c.Resolve<IDataConnectionProvider>()));
container.Register<IAuthProviderFactory>(
c => new AuthProviderFactory(c.Resolve<IEnumerable<IAuthProviderInstance>>()));
container.Register<IApplicationRepository>(
c => new ApplicationRepository(c.Resolve<IDataConnectionProvider>()));
container.Register<IApplicationServiceRepository>(
c => new ApplicationServiceRepository(c.Resolve<IDataConnectionProvider>()));
container.Register<IAccountApplicationRepository>(
c => new AccountApplicationRepository(c.Resolve<IDataConnectionProvider>()));
container.Register<IAccountRepository>(
c => new AccountRepository(c.Resolve<IDataConnectionProvider>()));
container.Register<IAccountUserRepository>(
c => new AccountUserRepository(c.Resolve<IDataConnectionProvider>()));
container.Register<IUserRepository>(
c => new UserRepository(c.Resolve<IDataConnectionProvider>()));
}
开发者ID:allenarthurgay,项目名称:FederatedOauthConsumer,代码行数:29,代码来源:Registration.cs
示例9: Configure
public override void Configure(Container container)
{
Plugins.Add(new SwaggerFeature());
Plugins.Add(new RazorFormat());
Plugins.Add(new RequestLogsFeature());
Plugins.Add(new ValidationFeature());
container.RegisterValidators(typeof(ContactsServices).Assembly);
container.Register<IDbConnectionFactory>(
c => new OrmLiteConnectionFactory("db.sqlite", SqliteDialect.Provider) {
ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
});
using (var db = container.Resolve<IDbConnectionFactory>().Open())
{
db.DropAndCreateTable<Email>();
db.DropAndCreateTable<Contact>();
db.Insert(new Contact { Name = "Kurt Cobain", Email = "[email protected]", Age = 27 });
db.Insert(new Contact { Name = "Jimi Hendrix", Email = "[email protected]", Age = 27 });
db.Insert(new Contact { Name = "Michael Jackson", Email = "[email protected]", Age = 50 });
}
UseDbEmailer(container);
//UseSmtpEmailer(container); //Uncomment to use SMTP instead
//ConfigureRabbitMqServer(container); //Uncomment to start accepting requests via Rabbit MQ
}
开发者ID:Gozhack,项目名称:EmailContacts,代码行数:29,代码来源:Global.asax.cs
示例10: Configure
/// <summary>
/// Application specific configuration
/// This method should initialize any IoC resources utilized by your web service classes.
/// </summary>
/// <param name="container"></param>
public override void Configure(Container container)
{
Plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] { new CustomAuthentication(), }));
container.Register<ICacheClient>(new MemoryCacheClient());
var userRepository = new InMemoryAuthRepository();
container.Register<IUserAuthRepository>(userRepository);
}
开发者ID:MBrekhof,项目名称:ssforms,代码行数:12,代码来源:AppHost.cs
示例11: Main
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var container = new Container();
Tepeyac.Funq.Registry.Register(container);
container.Register<IFiber>("GuiFiber", c => c.Resolve<IFiber>());
/*
container.Register<IFiber>("GuiFiber", c =>
{
var executor =
c.Resolve<IExecutor>() ??
new Executor();
var invoke = new SynchronizeInvoke(new WindowsFormsSynchronizationContext());
var fiber = new FormFiber(invoke, executor);
fiber.Start();
return fiber;
});
*/
container.Register<IBurritoDayView>(c =>
new BurritoDayView(c));
container.Resolve<IBurritoDayView>();
Application.Run();
}
开发者ID:ataranto,项目名称:tepeyac,代码行数:29,代码来源:Main.cs
示例12: Configure
public static void Configure(Container container, PhoneApplicationFrame root)
{
container.Register<IJiraService>(c => new JiraService{Store = c.Resolve<IDocumentStore>()});
container.Register<IScheduler>(c => new Scheduler());
container.Register(c => new SignInCommandHandler{Bus = c.Resolve<IBus>()});
container.Register(c => new SyncHandler{Bus = c.Resolve<IBus>(), Jira = c.Resolve<IJiraService>()});
container.Register(
c => new SyncProjectHandler
{
Bus = c.Resolve<IBus>(),
Store = c.Resolve<IDocumentStore>(),
Jira = c.Resolve<IJiraService>(),
Scheduler = c.Resolve<IScheduler>()
});
container.Register(c => new SyncNewlyDiscoveredProjectsByDefaultHandler {Bus = c.Resolve<IBus>()});
container.Register(c => new ProfileLoggedInEventHandler { Store = c.Resolve<IDocumentStore>() });
var bus = container.Resolve<IBus>();
bus.RegisterHandler<SignInCommandHandler, SignInCommand>();
bus.RegisterHandler<SyncHandler, ApplicationLoadedEvent>();
bus.RegisterHandler<ProfileLoggedInEventHandler, LoggedInEvent>();
bus.RegisterHandler<SyncHandler, LoggedInEvent>();
bus.RegisterHandler<SyncProjectHandler, ProjectsDiscoveredEvent>();
bus.RegisterHandler<SyncProjectHandler, SyncProjectCommand>();
bus.RegisterHandler<SyncNewlyDiscoveredProjectsByDefaultHandler, DiscoveredNewProjectEvent>();
}
开发者ID:aluetjen,项目名称:Wp7Jira,代码行数:29,代码来源:Module.cs
示例13: StatusItemBurritoDayView
public StatusItemBurritoDayView(Container container)
{
this.menu = new NSMenu();
this.menu.AddItem(this.refreshMenuItem);
this.menu.AddItem(this.launchMenuItem);
this.menu.AddItem(NSMenuItem.SeparatorItem);
this.menu.AddItem(this.durationMenuItem);
this.menu.AddItem(this.locationMenuItem);
this.menu.AddItem(this.separatorMenuItem);;
this.menu.AddItem(this.dismissMenuitem);
this.menu.AddItem(this.quitMenuItem);
this.launchMenuItem.Activated += delegate {
var handler = this.urlActivated;
if (handler != null)
{
handler(this, "http://isitburritoday.com");
}
};
this.quitMenuItem.Activated += (sender, e) =>
NSApplication.SharedApplication.Terminate(sender as NSObject);
this.presenters = new IDisposable[]
{
container.Resolve<BurritoDayPresenter, IBurritoDayView>(this),
container.Resolve<UrlActivationPresenter, IUrlActivationView>(this),
};
}
开发者ID:ataranto,项目名称:tepeyac,代码行数:33,代码来源:StatusItemBurritoDayView.cs
示例14: Configure
public override void Configure(Container container)
{
//Permit modern browsers (e.g. Firefox) to allow sending of any REST HTTP Method
base.SetConfig(new EndpointHostConfig
{
GlobalResponseHeaders =
{
{ "Access-Control-Allow-Origin", "*" },
{ "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" },
},
});
container.Register<IResourceManager>(new ConfigurationResourceManager());
container.Register(c => new ExampleConfig(c.Resolve<IResourceManager>()));
var appConfig = container.Resolve<ExampleConfig>();
container.Register<IDbConnectionFactory>(c =>
new OrmLiteConnectionFactory(
appConfig.ConnectionString.MapHostAbsolutePath(),
SqliteOrmLiteDialectProvider.Instance));
ConfigureDatabase.Init(container.Resolve<IDbConnectionFactory>());
//register different cache implementations depending on availability
const bool hasRedis = false;
if (hasRedis)
container.Register<ICacheClient>(c => new BasicRedisClientManager());
else
container.Register<ICacheClient>(c => new MemoryCacheClient());
log.InfoFormat("AppHost Configured: " + DateTime.Now);
}
开发者ID:nuxleus,项目名称:ServiceStack.Examples,代码行数:35,代码来源:AppHost.cs
示例15: Configure
public override void Configure(Container container)
{
this.RequestFilters.Add((req, res, dto) =>
{
var requestFilter = dto as RequestFilter;
if (requestFilter != null)
{
res.StatusCode = requestFilter.StatusCode;
if (!requestFilter.HeaderName.IsNullOrEmpty())
{
res.AddHeader(requestFilter.HeaderName, requestFilter.HeaderValue);
}
res.Close();
}
var secureRequests = dto as IRequiresSession;
if (secureRequests != null)
{
res.ReturnAuthRequired();
}
});
this.Container.Register<IDbConnectionFactory>(c =>
new OrmLiteConnectionFactory(
"~/App_Data/db.sqlite".MapHostAbsolutePath(),
SqliteOrmLiteDialectProvider.Instance));
this.Container.Register<ICacheClient>(new MemoryCacheClient());
var dbFactory = this.Container.Resolve<IDbConnectionFactory>();
dbFactory.Exec(dbCmd => dbCmd.CreateTable<Movie>(true));
var resetMovies = this.Container.Resolve<ResetMoviesService>();
resetMovies.Post(null);
}
开发者ID:nguyennamtien,项目名称:ServiceStack,代码行数:35,代码来源:Global.asax.cs
示例16: Configure
public override void Configure(Container container)
{
if (EnableRazor)
Plugins.Add(new RazorFormat());
Plugins.Add(new SwaggerFeature());
Plugins.Add(new RequestInfoFeature());
Plugins.Add(new RequestLogsFeature());
Plugins.Add(new ServerEventsFeature());
Plugins.Add(new ValidationFeature());
container.RegisterValidators(typeof(AutoValidationValidator).Assembly);
container.Register<IDbConnectionFactory>(
new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider));
using (var db = container.Resolve<IDbConnectionFactory>().OpenDbConnection())
{
db.DropAndCreateTable<Rockstar>(); //Create table if not exists
db.Insert(Rockstar.SeedData); //Populate with seed data
}
SetConfig(new HostConfig {
AdminAuthSecret = "secret",
DebugMode = true,
});
}
开发者ID:jin29neci,项目名称:ServiceStack,代码行数:28,代码来源:AppHost.cs
示例17: Configure
public override void Configure(Container container)
{
JsConfig.DateHandler = JsonDateHandler.ISO8601;
container.Register<IDbConnectionFactory>(c =>
new OrmLiteConnectionFactory(
"~/App_Data/db.sqlite".MapHostAbsolutePath(),
SqliteOrmLiteDialectProvider.Instance));
var resetMovies = container.Resolve<ResetMoviesService>();
resetMovies.Post(null);
Routes
.Add<Movie>("/movies")
.Add<Movie>("/movies/{Id}")
.Add<Movies>("/movies")
.Add<Movies>("/movies/genres/{Genre}");
SetConfig(new EndpointHostConfig
{
GlobalResponseHeaders = {
{ "Access-Control-Allow-Origin", "*" },
{ "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" },
{ "Access-Control-Allow-Headers", "Content-Type, X-Requested-With" },
},
//EnableFeatures = onlyEnableFeatures,
//DebugMode = true, //Show StackTraces for easier debugging
});
}
开发者ID:asunar,项目名称:ServiceStack.Examples,代码行数:30,代码来源:Global.asax.cs
示例18: Configure
/// <summary>
/// Application specific configuration
/// This method should initialize any IoC resources utilized by your web service classes.
/// </summary>
/// <param name="container"></param>
public override void Configure(Container container)
{
LogManager.LogFactory = new DebugLogFactory();
OracleDialect.Provider.NamingStrategy = new OrmLiteNamingStrategyBase();
container.Register<IDbConnectionFactory>(new OrmLiteConnectionFactory(ConfigUtils.GetAppSetting("connectionString"), OracleOrmLiteDialectProvider.Instance));
using (var db = container.Resolve<IDbConnectionFactory>().OpenDbConnection())
{
db.CreateTableIfNotExists<Campaign>();
}
OrmLiteConfig.InsertFilter = (dbCmd, row) =>
{
var auditRow = row as IAudit;
if (auditRow == null) return;
var now = SystemClock.Instance.Now;
var milliseconds = now.Ticks / NodaConstants.TicksPerMillisecond;
auditRow.CreatedDate = auditRow.ModifiedDate = milliseconds;
};
OrmLiteConfig.UpdateFilter = (dbCmd, row) =>
{
var auditRow = row as IAudit;
if (auditRow == null) return;
var now = SystemClock.Instance.Now;
var milliseconds = now.Ticks / NodaConstants.TicksPerMillisecond;
auditRow.ModifiedDate = milliseconds;
};
}
开发者ID:stephenpatten,项目名称:SSORM4.0.43OracleRepo,代码行数:36,代码来源:AppHost.cs
示例19: Configure
public override void Configure(Container container)
{
Plugins.Add(new AuthFeature(() => new CustomUserSession(),
new AuthProvider[] {
new CredentialsAuthProvider(), //HTML Form post of UserName/Password credentials
new BasicAuthProvider(), //Sign-in with Basic Auth
}));
container.Register<ICacheClient>(new MemoryCacheClient());
var userRep = new InMemoryAuthRepository();
container.Register<IUserAuthRepository>(userRep);
string hash;
string salt;
new SaltedHash().GetHashAndSaltString("test1", out hash, out salt);
userRep.CreateUserAuth(new UserAuth {
Id = 1,
DisplayName = "DisplayName",
Email = "[email protected]",
UserName = "test1",
FirstName = "FirstName",
LastName = "LastName",
PasswordHash = hash,
Salt = salt,
}, "test1");
}
开发者ID:Qasemt,项目名称:NServiceKit,代码行数:27,代码来源:AppHost.cs
示例20: Configure
public override void Configure(Container container)
{
//Permit modern browsers (e.g. Firefox) to allow sending of any REST HTTP Method
base.SetConfig(new EndpointHostConfig
{
GlobalResponseHeaders =
{
{ "Access-Control-Allow-Origin", "*" },
{ "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, PATCH" },
},
DefaultContentType = ContentType.Json
});
var config = new AppConfig(new ConfigurationResourceManager());
container.Register(config);
OrmLiteConfig.DialectProvider= FirebirdOrmLiteDialectProvider.Instance;
IDbConnectionFactory dbFactory = new OrmLiteConnectionFactory(
ConfigUtils.GetConnectionString("ApplicationDb"));
container.Register<Factory>(
new Factory(){
DbFactory=dbFactory
}
);
ConfigureAuth(container);
log.InfoFormat("AppHost Configured: " + DateTime.Now);
}
开发者ID:aicl,项目名称:Aicl.Galapago,代码行数:32,代码来源:AppHost.cs
注:本文中的Funq.Container类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论