protected override IEnumerable <FilterAttribute> GetControllerAttributes(ControllerContext controllerContext, ActionDescriptor actionDescriptor) { foreach (var controllerAttribute in base.GetControllerAttributes(controllerContext, actionDescriptor)) { kernel.Inject(controllerAttribute); yield return(controllerAttribute); } }
internal static void Inject(object target) { if (kernel != null) { kernel.Inject(target); } }
public static void Inject(object instance) { IKernel kernel = Kernel; IParameter[] array = (IParameter[])new Parameter[0]; kernel.Inject(instance, array); }
public IEnumerable <FilterInfo> GetFilters(HttpConfiguration configuration, HttpActionDescriptor actionDescriptor) { #if RELEASE try { #endif var controllerFilters = actionDescriptor.ControllerDescriptor.GetFilters().Select(instance => new FilterInfo(instance, FilterScope.Controller)); var actionFilters = actionDescriptor.GetFilters().Select(instance => new FilterInfo(instance, FilterScope.Action)); var filters = controllerFilters.Concat(actionFilters); var filterInfos = filters as FilterInfo[] ?? filters.ToArray(); foreach (var f in filterInfos) { // Injection _kernel.Inject(f.Instance); } return(filterInfos); #if RELEASE } catch (Exception ex) { Tracing.Err.TraceEvent(TraceEventType.Error, 0, ex.ToString()); if (ConfigUtil.DiagnosticsMode) { //For use on Test Server throw; } throw; } #endif }
private static void ExecuteCommand(object arg) { var command = (CommandBase)arg; try { // The kernel will inject dependencies to the command. kernel.Inject(command); } catch (Exception ex) { Console.WriteLine($"Failed to resolve command dependencies: {ex.Message}"); returnValue = 1; return; } try { // Actual work is done here. command.Execute(); } catch (Exception ex) { // Ideally this code should never execute. Console.WriteLine(ex.Message); if (command.Verbose) { Console.WriteLine(Environment.NewLine + "=== Exception ==="); Console.WriteLine(ex.ToString()); } returnValue = 1; } }
/// <summary> /// Starts the application. /// </summary> public void Application_Start() { lock (this) { kernel = this.CreateKernel(); kernel.Bind<IResolutionRoot>().ToConstant(kernel); kernel.Bind<IDependencyResolver>().To<NinjectDependencyResolver>(); kernel.Bind<IFilterProvider>().To<NinjectFilterAttributeFilterProvider>(); kernel.Bind<IFilterProvider>().To<NinjectFilterProvider>(); kernel.Bind<RouteCollection>().ToConstant(RouteTable.Routes); kernel.Bind<HttpContext>().ToMethod(ctx => HttpContext.Current).InTransientScope(); kernel.Bind<HttpContextBase>().ToMethod(ctx => new HttpContextWrapper(HttpContext.Current)).InTransientScope(); kernel.Bind<ModelValidatorProvider>().To<NinjectDataAnnotationsModelValidatorProvider>(); ModelValidatorProviders.Providers.Remove(ModelValidatorProviders.Providers.OfType<DataAnnotationsModelValidatorProvider>().Single()); DependencyResolver.SetResolver(this.CreateDependencyResolver()); RemoveDefaultAttributeFilterProvider(); kernel.Inject(this); if (kernel.Settings.Get("ReleaseScopeAtRequestEnd", true)) { OnePerRequestModule.StartManaging(kernel); } this.OnApplicationStarted(); } }
/// <summary> /// Returns the filters that are associated with this action method. /// </summary> /// <param name="configuration">The HTTP configuration.</param> /// <param name="actionDescriptor">The action descriptor.</param> /// <returns> /// The filters that are associated with this action method. /// </returns> public IEnumerable <FilterInfo> GetFilters(HttpConfiguration configuration, HttpActionDescriptor actionDescriptor) { if (configuration == null) { throw new ArgumentNullException("configuration"); } if (actionDescriptor == null) { throw new ArgumentNullException("actionDescriptor"); } var controllerFilters = actionDescriptor.ControllerDescriptor.GetFilters() .Select(instance => new FilterInfo(instance, FilterScope.Controller)); var actionFilters = actionDescriptor.GetFilters() .Select(instance => new FilterInfo(instance, FilterScope.Action)); var filters = controllerFilters.Concat(actionFilters).ToList(); foreach (var filter in filters) { _kernel.Inject(filter.Instance); } return(filters); }
/// <summary> /// Starts the application. /// </summary> public void Application_Start() { lock (this) { kernel = this.CreateKernel(); kernel.Components.RemoveAll<IMissingBindingResolver>(); kernel.Components.Add<IMissingBindingResolver, ControllerMissingBindingResolver>(); kernel.Components.Add<IMissingBindingResolver, SelfBindingResolver>(); kernel.Bind<RouteCollection>().ToConstant(RouteTable.Routes); kernel.Bind<HttpContext>().ToMethod(ctx => HttpContext.Current).InTransientScope(); kernel.Bind<HttpContextBase>().ToMethod(ctx => new HttpContextWrapper(HttpContext.Current)).InTransientScope(); kernel.Bind<IFilterInjector>().To<FilterInjector>().InSingletonScope(); ControllerBuilder.Current.SetControllerFactory(this.CreateControllerFactory()); kernel.Inject(this); if (kernel.Settings.Get("ReleaseScopeAtRequestEnd", true)) { OnePerRequestModule.StartManaging(kernel); } this.OnApplicationStarted(); } }
public DeviceSanityCheckSubStateActionTests() { linkRequest = new LinkRequest() { //LinkObjects = new LinkRequestIPA5Object //{ // LinkActionResponseList = new List<XO.Responses.LinkActionResponse>() //}, Actions = new List <LinkActionRequest>() { new LinkActionRequest() { MessageID = RandomGenerator.BuildRandomString(8), Timeout = 10000, DeviceRequest = new LinkDeviceRequest() { DeviceIdentifier = new LinkDeviceIdentifier() { Manufacturer = "DeviceMockerInc", Model = "DeviceMokerModel", SerialNumber = "CEEEDEADBEEF" } } } } }; //linkRequest.LinkObjects = SampleBuilder.LinkObjectsForEvents(); //linkRequest.LinkObjects.LinkActionResponseList[0].MessageID = "Authentication"; //linkRequest.LinkObjects.LinkActionResponseList[0].DeviceResponse.Devices = new List<LinkDeviceResponse>() //{ // new LinkDeviceResponse() // { // Manufacturer = "NoDevice", // CardWorkflowControls = new LinkCardWorkflowControls() // { // CardCaptureTimeout = 10, // ManualCardTimeout = 5 // } // } //}; //mockLoggingClient = new Mock<ILoggingServiceClient>(); mockDeviceCancellationBroker = new Mock <IDeviceCancellationBroker>(); mockSubController = new Mock <IDeviceSubStateController>(); //mockSubController.SetupGet(e => e.LoggingClient).Returns(mockLoggingClient.Object); mockSubController.Setup(e => e.GetDeviceCancellationBroker()).Returns(mockDeviceCancellationBroker.Object); subject = new DeviceSanityCheckSubStateAction(mockSubController.Object); asyncManager = new DeviceSubStateMachineAsyncManager(ref mockSubController, subject); using (kernel = new StandardKernel()) { kernel.Bind <DeviceGetStatusSubStateAction>().ToSelf(); kernel.Inject(subject); } }
/// <summary> /// Starts the application. /// </summary> /// <param name="createKernelCallback">The create kernel callback function.</param> public void Initialize(Func<IKernel> createKernelCallback) { kernelInstance = createKernelCallback(); kernelInstance.Components.GetAll<INinjectHttpApplicationPlugin>().Map(c => c.Start()); kernelInstance.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>(); kernelInstance.Inject(this); }
/// <summary> /// Run an existing object through the container and perform injection on it. /// </summary> /// <param name="instance">The existing instance to be injected.</param> protected override void DoInjectInstance(object instance) { if (_kernel == null) { throw new ObjectDisposedException("container"); } _kernel.Inject(instance); }
/// <summary> /// Starts the application. /// </summary> /// <param name="createKernelCallback">The create kernel callback function.</param> public void Initialize(Func <IKernel> createKernelCallback) { kernelInstance = createKernelCallback(); kernelInstance.Components.GetAll <INinjectHttpApplicationPlugin>().Map(c => c.Start()); kernelInstance.Bind <IHttpModule>().To <HttpApplicationInitializationHttpModule>(); kernelInstance.Inject(this); }
protected override void BuildUp(object instance) { if (instance == null) { throw new ArgumentNullException(nameof(instance)); } kernel.Inject(instance); }
private void AddBindings() { kernel.Bind <IUnitOfWork>().To <UnitOfWork>(); kernel.Bind <IUserService>().To <UserService>().WithConstructorArgument("unit", m => m.Kernel.Get <IUnitOfWork>()); kernel.Bind <IStoryService>().To <StoryService>().WithConstructorArgument("unit", m => m.Kernel.Get <IUnitOfWork>()); kernel.Bind <IGroupService>().To <GroupService>().WithConstructorArgument("unit", m => m.Kernel.Get <IUnitOfWork>()); kernel.Inject(Membership.Provider); }
private void AddBindings() { ninjectKernel.Bind <IUserRepository>().To <SQLUserRepository>(); ninjectKernel.Bind <ICarRepository>().To <SQLCarRepository>(); //ninjectKernel.Bind<IUserRepository>().To<EFUserRepository>(); ninjectKernel.Inject(Membership.Provider); }
public static void Inject(object obj) { if (_kernel == null) { throw new NullReferenceException("IKernel Container is null"); } _kernel.Inject(obj); }
public void InjectPropertiesOn(object obj) { if (_kernel == null) { throw new NinjectDependencyInjectorHasNotBeenInitialized(); } _kernel.Inject(obj); }
//Определяем все привязки private void AddBindings() { ninjectKernel.Bind <IUsersRepository>().To <EFUsersRepository>(); ninjectKernel.Bind <IFriendsRepository>().To <EFFriendsRepository>(); ninjectKernel.Bind <IFriendRequestsRepository>().To <EFFriendRequestsRepository>(); ninjectKernel.Bind <IMessagesRepository>().To <EFMessagesRepository>(); ninjectKernel.Bind <EFDbContext>().ToSelf().WithConstructorArgument("connectionString", ConfigurationManager.ConnectionStrings[0].ConnectionString); ninjectKernel.Inject(Membership.Provider); }
public void Inject <T>(T existing) { if (existing == null) { throw new ArgumentNullException("existing"); } _kernel.Inject(existing); }
//Определим все привязки private void AddBindings() { ninjectCernel.Bind <IUsersRepository>().To <EFUsersRepository>(); ninjectCernel.Bind <IGameResultsRepository>().To <EFGameResultsRepository>(); ninjectCernel.Bind <IGameSettingsRepository>().To <EFGameSettingsRepository>(); ninjectCernel.Bind <EFDbContext>().ToSelf().WithConstructorArgument( "connectionString", ConfigurationManager.ConnectionStrings[0].ConnectionString); ninjectCernel.Inject(Membership.Provider); }
// inject /// <summary> /// Injects the specified instance. /// </summary> /// <typeparam name="TService">The type of the service.</typeparam> /// <param name="instance">The instance.</param> /// <returns></returns> public TService Inject <TService>(TService instance) where TService : class { if (instance == null) { return(null); } _container.Inject(instance, new IParameter[0]); return(instance); }
public override IEnumerable <Filter> GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor) { var filters = base.GetFilters(controllerContext, actionDescriptor); foreach (var filter in filters) { _kernel.Inject(filter.Instance); } return(filters); }
public TestAssistant() { _container = new StandardKernel(); IoC.GetInstance = (service, key) => _container.Get(service, key); IoC.GetAllInstances = (service) => _container.GetAll(service); IoC.BuildUp = (instance) => _container.Inject(instance); BindConfigs(); }
public new IEnumerable <FilterInfo> GetFilters(HttpConfiguration configuration, HttpActionDescriptor actionDescriptor) { var filters = base.GetFilters(configuration, actionDescriptor); foreach (var filter in filters) { _kernel.Inject(filter.Instance); } return(filters); }
public static CityMobileService GetInstance(IKernel kernelForInjection) { if (_instance == null) { _instance = new CityMobileService(); kernelForInjection.Inject(_instance); } return(_instance); }
static private void InjectUserControlsOf(this IKernel kernel, Control control) { kernel.Inject(control); var childrenControls = control.Controls.Cast <Control>(); foreach (var childControl in childrenControls) { InjectUserControlsOf(kernel, childControl); } }
/*----------------------------------------------------------------------------------------*/ #region Public Methods: Event Handlers /// <summary> /// Executed when the application's AppDomain is loaded. Creates the <see cref="IKernel"/> /// and requests injections for the application itself. /// </summary> public void Application_OnStart() { _kernel = CreateKernel(); _kernel.Load(new MonoRailModule()); ServiceProviderLocator.Instance.AddLocatorStrategy(new NinjectAccessorStrategy()); _kernel.Inject(this); OnApplicationStarted(); }
protected override ActionExecutedContext InvokeActionMethodWithFilters( ControllerContext controllerContext, IList <IActionFilter> filters, ActionDescriptor actionDescriptor, IDictionary <string, object> parameters) { foreach (IActionFilter actionFilter in filters) { _kernel.Inject(actionFilter); } return(base.InvokeActionMethodWithFilters(controllerContext, filters, actionDescriptor, parameters)); }
/*----------------------------------------------------------------------------------------*/ #region Public Methods /// <summary> /// Injects the specified instance by using the container's kernel. /// </summary> /// <param name="instance">The instance to inject.</param> public static void Inject(object instance) { if (_kernel == null) { throw new InvalidOperationException(String.Format( "The type {0} requested an injection, but no kernel has been registered for the web application.\r\n" + "Please ensure that your project defines a NinjectHttpApplication.", instance.GetType())); } _kernel.Inject(instance); }
protected override IEnumerable <ModelValidator> GetValidators(ModelMetadata metadata, ControllerContext context, IEnumerable <Attribute> attributes) { foreach (var modelValidator in base.GetValidators(metadata, context, attributes)) { var dataAnnotationsModelValidator = modelValidator as DataAnnotationsModelValidator; if (dataAnnotationsModelValidator != null) { var validationAttribute = getter(dataAnnotationsModelValidator); kernel.Inject(validationAttribute); } yield return(modelValidator); } }
private void AddBindings() { kernel.Bind <IDoctorRepository>().To <DoctorRepository>(); kernel.Bind <IPatientRepository>().To <PatientRepository>(); kernel.Bind <ISpecializationRepository>().To <SpecializationRepository>(); kernel.Bind <IVisitRepository>().To <VisitRepository>(); kernel.Bind <IVisitResultRepository>().To <VisitResultRepository>(); kernel.Bind <HContext>().ToSelf().WithConstructorArgument("Context", ConfigurationManager.ConnectionStrings[0].ConnectionString); kernel.Inject(Membership.Provider); }
public IEnumerable <FilterInfo> GetFilters(HttpConfiguration configuration, HttpActionDescriptor actionDescriptor) { var controllerFilters = actionDescriptor.ControllerDescriptor.GetFilters().Select(instance => new FilterInfo(instance, FilterScope.Controller)); var actionFilters = actionDescriptor.GetFilters().Select(instance => new FilterInfo(instance, FilterScope.Action)); var filters = controllerFilters.Concat(actionFilters); foreach (var f in filters) { _kernel.Inject(f.Instance); } return(filters); }
public DeviceRequestSubCompleteStateActionTests() { linkRequest = new LinkRequest() { //LinkObjects = new LinkRequestIPA5Object //{ // LinkActionResponseList = new List<XO.Responses.LinkActionResponse>() //}, //Actions = new List<LinkActionRequest>() //{ // new LinkActionRequest() // { // MessageID = Helpers.RandomGenerator.BuildRandomString(8), // Timeout = 10000 // } //} }; //linkRequest.LinkObjects = SampleBuilder.LinkObjectsForEvents(); //linkRequest.LinkObjects.LinkActionResponseList[0].MessageID = "Authentication"; //linkRequest.LinkObjects.LinkActionResponseList[0].DeviceResponse.Devices = new List<LinkDeviceResponse>() //{ // new LinkDeviceResponse() // { // Manufacturer = "NoDevice", // CardWorkflowControls = new LinkCardWorkflowControls() // { // CardCaptureTimeout = 10, // ManualCardTimeout = 5 // } // } //}; //mockLoggingClient = new Mock<ILoggingServiceClient>(); //mockConnector = new Mock<IListenerConnector>(); mockController = new Mock <IDeviceSubStateController>(); //mockController.SetupGet(e => e.LoggingClient).Returns(mockLoggingClient.Object); //mockController.SetupGet(e => e.Connector).Returns(mockConnector.Object); subject = new DeviceRequestCompleteSubStateAction(mockController.Object); asyncManager = new DeviceSubStateMachineAsyncManager(ref mockController, subject); using (kernel = new StandardKernel()) { kernel.Bind <DeviceGetStatusSubStateAction>().ToSelf(); kernel.Inject(subject); } }
static private void InjectUserControlsOf(this IKernel kernel, Control control) { //only user controls can have properties defined as n-inject-able if (control is UserControl) { Trace.TraceInformation("Injecting dependencies in User Control of type {0}", control.GetType()); kernel.Inject(control); } //A non user control can have children that are user controls and should be n-injected var childrenControls = control.Controls.Cast <Control>(); foreach (var childControl in childrenControls) { InjectUserControlsOf(kernel, childControl); } }
/// <summary> /// Starts the application. /// </summary> public void Application_Start() { lock (this) { _kernel = CreateKernel(); _kernel.Bind<RouteCollection>().ToConstant(RouteTable.Routes); _kernel.Bind<HttpContext>().ToMethod(ctx => HttpContext.Current).InRequestScope(); _kernel.Bind<HttpContextBase>().ToMethod(ctx => new HttpContextWrapper(HttpContext.Current)).InRequestScope(); ControllerBuilder.Current.SetControllerFactory(new NinjectControllerFactory(_kernel)); _kernel.Inject(this); OnApplicationStarted(); } }
/// <summary> /// Starts the application. /// </summary> public void Application_Start() { lock (this) { _kernel = CreateKernel(); _kernel.Bind<RouteCollection>().ToConstant(RouteTable.Routes); _kernel.Bind<HttpContext>().ToMethod(ctx => HttpContext.Current).InTransientScope(); _kernel.Bind<HttpContextBase>().ToMethod(ctx => new HttpContextWrapper(HttpContext.Current)).InTransientScope(); ControllerBuilder.Current.SetControllerFactory(CreateControllerFactory()); _kernel.Inject(this); if (_kernel.Settings.Get("ReleaseScopeAtRequestEnd", true)) { OnePerRequestModule.StartManaging(_kernel); } OnApplicationStarted(); } }
/// <summary> /// Starts the application. /// </summary> public void Application_Start() { lock (this) { _kernel = CreateKernel(); _kernel.Components.RemoveAll<IMissingBindingResolver>(); _kernel.Components.Add<IMissingBindingResolver, ControllerMissingBindingResolver>(); _kernel.Components.Add<IMissingBindingResolver, SelfBindingResolver>(); _kernel.Bind<RouteCollection>().ToConstant(RouteTable.Routes); _kernel.Bind<HttpContext>().ToMethod(ctx => HttpContext.Current).InTransientScope(); _kernel.Bind<HttpContextBase>().ToMethod(ctx => new HttpContextWrapper(HttpContext.Current)).InTransientScope(); _kernel.Bind<IFilterInjector>().To<FilterInjector>().InSingletonScope(); ControllerBuilder.Current.SetControllerFactory(CreateControllerFactory()); _kernel.Inject(this); OnApplicationStarted(); } }
public WebServiceBase(IKernel kernel) { if (kernel != null) kernel.Inject(this); }
/// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { // http://stackoverflow.com/questions/9693957/ninject-web-common-throwing-activationexception-trying-to-inject-dependencies-in kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel); kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>(); // NHibernate session factory kernel.Bind<ISessionFactory>().ToProvider<NHibernateSessionFactoryProvider>().InSingletonScope(); kernel.Bind<ISession>().ToMethod(context => context.Kernel.Get<ISessionFactory>().OpenSession()).InRequestScope(); kernel.Bind<IIntegrityServiceManager>().To<IntegrityServiceManager>().InRequestScope(); kernel.Bind<IUnitOfWorkManager>().To<UnitOfWorkManager>().InRequestScope(); // Bind the various domain model services and repositories that e.g. our controllers require kernel.Bind<IRoleService>().To<RoleService>().InRequestScope(); kernel.Bind<ICategoryService>().To<CategoryService>().InRequestScope(); kernel.Bind<IMembershipService>().To<MembershipService>().InRequestScope(); kernel.Bind<IPermissionService>().To<PermissionService>().InRequestScope(); kernel.Bind<ISettingsService>().To<SettingsService>().InRequestScope(); kernel.Bind<ITopicService>().To<TopicService>().InRequestScope(); kernel.Bind<ITopicTagService>().To<TopicTagService>().InRequestScope(); kernel.Bind<IPostService>().To<PostService>().InRequestScope(); kernel.Bind<ILocalizationService>().To<LocalizationService>().InRequestScope(); kernel.Bind<IVoteService>().To<VoteService>().InRequestScope(); kernel.Bind<IBadgeService>().To<BadgeService>().InRequestScope(); kernel.Bind<IMembershipUserPointsService>().To<MembershipUserPointsService>().InRequestScope(); kernel.Bind<ICategoryPermissionForRoleService>().To<CategoryPermissionForRoleService>().InRequestScope(); kernel.Bind<ICategoryNotificationService>().To<CategoryNotificationService>().InRequestScope(); kernel.Bind<ITopicNotificationService>().To<TopicNotificationService>().InRequestScope(); kernel.Bind<IPrivateMessageService>().To<PrivateMessageService>().InRequestScope(); kernel.Bind<ILoggingService>().To<LoggingService>().InRequestScope(); kernel.Bind<IEmailService>().To<EmailService>().InRequestScope(); kernel.Bind<IReportService>().To<ReportService>().InRequestScope(); kernel.Bind<IActivityService>().To<ActivityService>().InRequestScope(); kernel.Bind<IRoleRepository>().To<RoleRepository>().InRequestScope(); kernel.Bind<ICategoryRepository>().To<CategoryRepository>().InRequestScope(); kernel.Bind<IMembershipRepository>().To<MembershipRepository>().InRequestScope(); kernel.Bind<IPermissionRepository>().To<PermissionRepository>().InRequestScope(); kernel.Bind<ISettingsRepository>().To<SettingsRepository>().InRequestScope(); kernel.Bind<ITopicRepository>().To<TopicRepository>().InRequestScope(); kernel.Bind<ITopicTagRepository>().To<TopicTagRepository>().InRequestScope(); kernel.Bind<IPostRepository>().To<PostRepository>().InRequestScope(); kernel.Bind<ILocalizationRepository>().To<LocalizationRepository>().InRequestScope(); kernel.Bind<IVoteRepository>().To<VoteRepository>().InRequestScope(); kernel.Bind<IBadgeRepository>().To<BadgeRepository>().InRequestScope(); kernel.Bind<IMembershipUserPointsRepository>().To<MembershipUserPointsRepository>().InRequestScope(); kernel.Bind<ICategoryPermissionForRoleRepository>().To<CategoryPermissionForRoleRepository>().InRequestScope(); kernel.Bind<ICategoryNotificationRepository>().To<CategoryNotificationRepository>().InRequestScope(); kernel.Bind<ITopicNotificationRepository>().To<TopicNotificationRepository>().InRequestScope(); kernel.Bind<IPrivateMessageRepository>().To<PrivateMessageRepository>().InRequestScope(); kernel.Bind<IActivityRepository>().To<ActivityRepository>().InRequestScope(); kernel.Bind<IMVCForumAPI>().To<MVCForumAPI>().InRequestScope(); kernel.Bind<IPostAPI>().To<PostAPI>().InRequestScope(); kernel.Bind<ITopicAPI>().To<TopicAPI>().InRequestScope(); kernel.Bind<ICacheHelper>().To<CacheHelper>().InRequestScope(); kernel.Bind<ISessionHelper>().To<SessionHelper>().InRequestScope(); // Locate the membership objects defined via web.config and inject thereby setting any properties decorated with [Inject] // applying any ninjectified objects already established kernel.Inject(System.Web.Security.Membership.Provider); kernel.Inject(System.Web.Security.Roles.Provider); // Inject the objects passed by caller e.g. ServiceLocator foreach(var obj in _objectsToInject) { if (obj != null) { kernel.Inject(obj); } } }
/// <summary> /// Initializes a new instance of the <see cref="WpfBundle" /> class through injection with the provided kernel. /// </summary> /// <param name="kernel"></param> public WpfBundle(IKernel kernel) : base(kernel) { kernel.Inject(this.Gui); }
/// <summary> /// Initializes a new instance of the <see cref="ConsoleBundle" /> class. /// </summary> /// <param name="matrix"></param> public ConsoleBundle(IKernel kernel) : base(kernel) { kernel.Inject(this.Reader); }
/// <summary> /// Initializes a new instance of the <see cref="CoreBundle" /> class through injection with the provided kernel. /// </summary> /// <param name="kernel"></param> public CoreBundle(IKernel kernel) { kernel.Inject(this); }
/// <summary> /// Initializes a new instance of the <see cref="Context" /> class. Uses a Ninject kernel to inject the current instance. /// </summary> /// <param name="appKernel"></param> public Context(IKernel appKernel) : this() { appKernel.Inject(this); }
/// <summary> /// Initializes a new instance of the <see cref="InjectOnKernelExtension"/> class. /// </summary> /// <param name="kernel">The kernel.</param> public InjectOnKernelExtension(IKernel kernel) : base((a, r) => kernel.Inject(a, new RootActivityParameter(r))) { }
public sealed override bool OnStart() { Kernel = CreateKernel(); Kernel.Inject(this); return OnRoleStarted(); }