本文整理匯總了C#中SimpleInjector.Container.Verify方法的典型用法代碼示例。如果您正苦於以下問題:C# Container.Verify方法的具體用法?C# Container.Verify怎麽用?C# Container.Verify使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SimpleInjector.Container
的用法示例。
在下文中一共展示了Container.Verify方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: RegisterServices
public void RegisterServices(Container container)
{
//Config
container.RegisterWebApiRequest<IDbSettings>(() => new DbSettings(ConnectionName));
//DbContext
container.RegisterWebApiRequest<ISmsContext>(() => new SmsContext(container.GetInstance<IDbSettings>()));
//Services
container.Register<IExternalSmsService, ExternalSmsService>();
container.Register<IInternalSmsService, InternalSmsService>();
//Data
container.Register<ISmsRepository, SmsRepository>();
//Reference Generator
container.Register<IReferenceGenerator, CryptographicReferenceGenerator>();
//Error Engine
container.Register<IErrorEngine, TwilioErrorEngine>();
//Config
container.Register<ITwilioSettings>(() => (TwilioSettings)(dynamic)ConfigurationManager.GetSection("twilioSettings"));
container.Register<ITwilioNumbers>(() => (TwilioNumbersSettings)(dynamic)ConfigurationManager.GetSection("twilioNumbers"));
container.Register<ISmsServiceSettings>(() => (SmsServiceSettings)(dynamic)ConfigurationManager.GetSection("smsServiceSettings"));
//SMS Provider
container.Register<ISmsProvider, TwilioProvider>();
container.Verify();
}
示例2: RegisterServices
public void RegisterServices(Container container)
{
//Config
container.RegisterWebApiRequest<IDbSettings>(() => new DbSettings(Constants.ConnectionName));
//DbContext
container.RegisterWebApiRequest<IPropertyMatrixContext>(() => new PropertyMatrixContext(container.GetInstance<IDbSettings>()));
//Services
container.Register<IPriceRangeService, PriceRangeService>();
container.Register<IQuoteService, QuoteService>();
container.Register<IAppointmentService, AppointmentService>();
container.Register<ISearchService, SearchService>();
//Data
container.Register<IPriceRangeRepository, PriceRangeRepository>();
container.Register<IQuoteRepository, QuoteRepository>();
container.Register<IAppointmentRepository, AppointmentRepository>();
container.Register<ISearchRepository, SearchRepository>();
//Mapping
container.Register<IMapToExisting<PriceRange, PriceRange>, PriceRangeMapper>();
//Reference Generator
container.Register<IReferenceGenerator, CryptographicReferenceGenerator>();
container.Verify();
}
示例3: Configuration
// Invoked once at startup to configure your application.
public void Configuration(IAppBuilder builder)
{
var config = new HttpConfiguration();
// Create the container as usual.
var container = new Container();
// Register your types, for instance using the RegisterWebApiRequest
// extension from the integration package:
container.RegisterWebApiRequest<IUserRepository, SqlUserRepository>();
// This is an extension method from the integration package.
container.RegisterWebApiControllers(config);
container.Verify();
config.DependencyResolver =
new SimpleInjectorWebApiDependencyResolver(container);
config.MapHttpAttributeRoutes();
//config.Routes.MapHttpRoute("Default", "", new { controller = "OEmbed" });
//config.Formatters.XmlFormatter.UseXmlSerializer = true;
//config.Formatters.Remove(config.Formatters.JsonFormatter);
////config.Formatters.Remove(config.Formatters.XmlFormatter);
// config.Formatters.JsonFormatter.UseDataContractJsonSerializer = true;
builder.UseWebApi(config);
//builder.Use(async (context, next) => {
// using (container.BeginExecutionContextScope())
// {
// await next();
// }
//});
}
示例4: ConfigureSimpleInjector
//Register Container for classes that use dependecy Injection
private Container ConfigureSimpleInjector(IAppBuilder app)
{
var container = new Container();
container.Options.DefaultScopedLifestyle = new ExecutionContextScopeLifestyle();
container.Register<IUserStore<User, int>, UserStore>(Lifestyle.Scoped);
container.Register<IDatabaseFactory, DatabaseFactory>(Lifestyle.Scoped);
container.Register<IUnitOfWork, UnitOfWork>();
container.Register<IAuthRepository, AuthRepository>();
container.Register<ICommentRepository, CommentRepository>();
container.Register<IUserRepository, UserRepository>();
container.Register<ICompanyProfileRepository, CompanyProfileRepository>();
container.Register<IInsuranceAgentProfileRepository, InsuranceAgentProfileRepository>();
container.Register<ILeadProductRepository, LeadProductRepository>();
container.Register<ILeadTransactionRepository, LeadTransactionRepository>();
container.Register<IReviewPostRepository, ReviewPostRepository>();
app.Use(async (context, next) => {
using (container.BeginExecutionContextScope())
{
await next();
}
});
container.Verify();
return container;
}
示例5: Configuration
public static Container Configuration(Container kernel)
{
kernel.Register<ICommercialRepository, CommercialRepository>(Lifestyle.Singleton);
kernel.Verify();
return kernel;
}
示例6: Initialize
public static void Initialize()
{
var container = new Container();
container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();
// Chamada dos módulos do Simple Injector
InitializeContainer(container);
// Necessário para registrar o ambiente do Owin que é dependência do Identity
// Feito fora da camada de IoC para não levar o System.Web para fora
container.RegisterPerWebRequest(() =>
{
if (HttpContext.Current != null && HttpContext.Current.Items["owin.Environment"] == null && container.IsVerifying())
{
return new OwinContext().Authentication;
}
return HttpContext.Current.GetOwinContext().Authentication;
});
container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
container.Verify();
DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
}
示例7: Main
static void Main(string[] args)
{
// 1. Create a new Simple Injector container
var container = new Container();
// 2. Configure the container (register)
container.Register<IMongoProvider, MongoProvider>(Lifestyle.Singleton);
container.Register<IInputProvider, MongoInputProvider>();
container.Register<IOutputProvider, MongoOutputProvider>();
container.Register<IParseProvider,ConsoleParseProvider>();
container.Register<IMathProvider, DefaultMathProviderProvider>();
// 3. Optionally verify the container's configuration.
container.Verify();
/*
var calc = new Calculator(
new MongoInputProvider(new MongoProvider("localhost:\\mongo")), //<===
new MongoOutputProvider(new MongoProvider("localhost:\\mongo")),//<===
new ConsoleParseProvider(),
new DefaultMathProviderProvider()
);
*/
var calc = container.GetInstance<Calculator>();
calc.MainLoop();
Console.ReadLine();
}
示例8: Register
public static void Register()
{
// Create the container as usual.
Container container = new Container();
// services
container.Register<IManagerCustomerRepository, ManagerCustomerRepository>();
// data
// Register your types, for instance using the RegisterWebApiRequest
// extension from the integration package:
container.RegisterMvcControllers(
System.Reflection.Assembly.GetExecutingAssembly());
container.RegisterMvcAttributeFilterProvider();
// This is an extension method from the integration package.
// verify its all ok
container.Verify();
// add dependency
DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
}
示例9: OnStart
protected override void OnStart(string[] args)
{
_container = new Container();
_container.RegisterSingleton<IAchievementPushService, AchievementPushService>();
_container.RegisterSingleton<IAchievementService, AchievementService>();
_container.RegisterSingleton<IActivityGroupingService, ActivityGroupingService>();
_container.RegisterSingleton<IDatabaseService, DatabaseService>();
_container.RegisterSingleton<IFitocracyService, FitocracyService>();
_container.RegisterSingleton<IScrapingService, ScrapingService>();
_container.RegisterSingleton<IUserPullService, UserPullService>();
_container.RegisterSingleton<IWebRequestService, WebRequestService>();
_container.RegisterSingleton<IWorkoutPullService, WorkoutPullService>();
_container.RegisterCollection<IAchievementProvider>(
GetType().Assembly.GetTypes()
.Where(typeof (IAchievementProvider).IsAssignableFrom)
.Where(type => type.IsClass));
_container.RegisterDecorator<IWebRequestService, ThrottledWebRequestDecorator>(Lifestyle.Singleton);
_container.Verify();
_cancelSource = new CancellationTokenSource();
_task = Task.Factory.StartNew(Run, _cancelSource.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
}
示例10: Register
public static void Register(HttpConfiguration config)
{
using (var container = new Container())
{
container.Options.DefaultScopedLifestyle = new WebApiRequestLifestyle();
// Chamada dos módulos do Simple Injector
BootStrapper.RegisterServices(container);
// Necessário para registrar o ambiente do Owin que é dependência do Identity
// Feito fora da camada de IoC para não levar o System.Web para fora
container.RegisterPerWebRequest(() =>
{
if (HttpContext.Current != null && HttpContext.Current.Items["owin.Environment"] == null && container.IsVerifying())
{
return new OwinContext().Authentication;
}
return HttpContext.Current.GetOwinContext().Authentication;
});
// This is an extension method from the integration package.
container.RegisterWebApiControllers(config);
container.Verify();
GlobalConfiguration.Configuration.DependencyResolver =
new SimpleInjectorWebApiDependencyResolver(container);
}
}
示例11: Application_Start
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
// Simple Injection Setup
var container = new Container();
// SI Controllers Dependency Injection
container.Register<IUserHelper, UserHelper>(Lifestyle.Singleton);
container.Register<IConfigurationHelper, ConfigurationHelper>(Lifestyle.Singleton);
container.Register<IErrorSignaler, ErrorSignaler>(Lifestyle.Singleton);
container.Register<IAddressResource, AddressResource>(Lifestyle.Singleton);
container.Register<IHobbyResource, HobbyResource>(Lifestyle.Singleton);
container.Register<IEducationResource, EducationResource>(Lifestyle.Singleton);
container.Register<IUsersResource, UsersResource>(Lifestyle.Singleton);
container.Register<IMediaResource, MediaResource>(Lifestyle.Singleton);
container.Register<INotificationResource, NotificationResource>(Lifestyle.Singleton);
// SI Token Identity Registers
container.Register<IdentityDbContext<BlogUser>, BlogIdentityDbContext>(Lifestyle.Singleton);
container.Register<IUserStore<BlogUser>, BlogUserStore>(Lifestyle.Singleton);
container.Register<IBlogDbRepository, BlogDbRepository>(Lifestyle.Singleton);
container.Register<BlogUserManager, BlogUserManager>(Lifestyle.Singleton);
// SI Registrations
container.RegisterMvcControllers(System.Reflection.Assembly.GetExecutingAssembly());
container.RegisterMvcIntegratedFilterProvider();
container.Verify();
// Register the dependency resolver.
DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
}
示例12: Main
private static void Main()
{
// Create a new Simple Injector container
Container container = new Container();
// Configure the Container
ConfigureContainer(container);
// Optionally verify the container's configuration to check for configuration errors.
container.Verify();
HostFactory.Run(config =>
{
// Pass it to Topshelf
config.UseSimpleInjector(container);
config.Service<Service>(s =>
{
// Let Topshelf use it
s.ConstructUsingSimpleInjector();
s.WhenStarted((service, control) => service.Start());
s.WhenStopped((service, control) => service.Stop());
//s.WhenPaused((service, control) => service.Pause());
});
config.SetServiceName("My.Cool.Service");
config.SetDisplayName("My Cool Service");
config.SetDescription("What is my purpose?");
});
}
示例13: RegisterComponents
public static Container RegisterComponents()
{
// Set up the localdb data directory.
var dataDirectory = (string)AppDomain.CurrentDomain.GetData("DataDirectory");
dataDirectory = Path.Combine(dataDirectory, "..\\..\\Database");
dataDirectory = Path.GetFullPath(dataDirectory);
AppDomain.CurrentDomain.SetData("DataDirectory", dataDirectory);
// Create the container and register all the api controllers.
var container = new Container();
container.RegisterWebApiControllers(GlobalConfiguration.Configuration);
// Model.Api Registrations
container.Register<IAuthenticationService, AuthenticationService>();
container.Register<IChannelService, ChannelService>();
container.Register<IUserItemService, UserItemService>();
container.Register<IRegistrationService, RegistrationService>();
// Model.Persistence Registations
container.Register(
() => new SqlHelper(ConfigurationManager.AppSettings["persistence"]),
Lifestyle.Singleton);
container.Register<IRssService, RssService>();
container.Register<IUserService, UserService>();
// Verify that everything is wired up properly.
container.Verify();
// Register the container as the default dependency resolver.
GlobalConfiguration.Configuration.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container);
return container;
}
示例14: Initialize
public static void Initialize()
{
var config = GlobalConfiguration.Configuration;
var container = new Container();
container.Options.PropertySelectionBehavior = new ImportPropertySelectionBehavior();
Configure(container);
try
{
container.Verify();
}
catch (Exception e)
{
Trace.TraceError("Failed to initialize IoC container: {0}", e);
throw;
}
config.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container);
container.RegisterWebApiFilterProvider(config);
try
{
new TraceListenersInitializer(container.GetInstance<IPortalMiddleendSettings>(), container.GetInstance<IEmailSenderService>()).Initialize();
}
catch (Exception e)
{
Trace.TraceError("Failed to initialize trace listeners: {0}", e);
throw;
}
}
示例15: RegisterServices
public void RegisterServices(Container container)
{
//Services
container.Register<IEmailService, EmailService>();
container.Register<IBusinessHoursService, BusinessHoursService>();
container.Register<ISmsService, SmsService>();
container.Register<IRestService, RestService>();
//Validator
container.Register<IMobileNumberValidator, MobileNumberValidator>();
//Gmail
container.Register<IEmailProvider, GmailProvider>();
container.Register<IMailAdapter, LimiLabsAdapter>();
container.Register<IOAuth2Authenticator, OAuth2Authenticator>();
//Config
container.Register<IMailboxConfiguration>(() => (MailboxConfigurationSettings)(dynamic)ConfigurationManager.GetSection("mailboxConfigurations"));
container.Register<IMailboxLabels>(() => (MailboxLabelSettings)(dynamic)ConfigurationManager.GetSection("mailboxLabelSettings"));
container.Register<IGmailSettings>(() => (GmailSettings)(dynamic)ConfigurationManager.GetSection("gmailSettings"));
container.Register<ISmsFactoryServiceSettings>(() => (SmsFactoryServiceSettings)(dynamic)ConfigurationManager.GetSection("smsFactoryServiceSettings"));
container.Register<IApiAuthenticationSettings>(() => (ApiAuthenticationSettings)(dynamic)ConfigurationManager.GetSection("apiSecuritySettings"));
container.Register<IServiceUrlSettings>(() => (ServiceUrlSetting)(dynamic)ConfigurationManager.GetSection("serviceUrls"));
container.Register<ISmsSettings>(() => (SmsSettings)(dynamic)ConfigurationManager.GetSection("smsSettings"));
container.Register<IBusinessHoursSettings>(() => (BusinessHoursSettings)(dynamic)ConfigurationManager.GetSection("businessHoursSettings"));
//CertificatePath
container.Register<ICertificatePath>(() => new CertificatePath { Value = HostingEnvironment.MapPath(container.GetInstance<IGmailSettings>().ServiceAccountCertPath) });
container.Verify();
}