public TService Get <TService>() where TService : class
 {
     try {
         return(kernel.Get <TService> ());
     } catch (ActivationException err) {
         throw WrapExn(err);
     }
 }
Example #2
0
        public IFile CreateFile(int id, string filename, string fileType)
        {
            IRequest req = Kernel.CreateRequest(typeof(IFile), null, new IParameter[] { new Parameter("id", id, false), new Parameter("filename", filename, false) }, false, false);

            if (!Kernel.CanResolve(req))
            {
                Kernel.Bind <IFile>().To <LastOpenFiles>().Named("LastOpenedFile").WithConstructorArgument("id", id).WithConstructorArgument("filename", filename);
                Kernel.Bind <IFile>().To <File>().Named("MostRecentFile").WithConstructorArgument("id", id).WithConstructorArgument("filename", filename);
            }

            IFile file = Kernel.Get <IFile>(fileType);

            Kernel.Unbind <IFile>();

            return(file);
        }
 public TodoCRUDManagerTests(bool isIntegration = false)
 {
     // this constructor allows for integration test reuse
     if (isIntegration)
     {
         // Implicit self binding allows us to get a concrete class with fulfilled dependencies
         // https://github.com/ninject/ninject/wiki/dependency-injection-with-ninject
         Ninject.IKernel kernel = DependencyInjectionLoader.BuildKernel();
         manager  = kernel.Get <TodoCRUDManager>();
         dataPrep = new TodoDataPrep(true);
     }
     else
     {
         manager = mockContainer.Instance;
         // dataPrep non-persistant by default in base class
     }
 }
Example #4
0
        public Controls.ITabItem CreateTabItem(string filename, IHighlightsHelper hightlightsHelper)
        {
            IRequest req = Kernel.CreateRequest(typeof(ITabItem), null, new IParameter[] { new Parameter("filename", filename, false), new Parameter("hightlightsHelper", hightlightsHelper, false) }, false, false);

            if (!Kernel.CanResolve(req))
            {
                Kernel.Bind <ITabItem>()
                .To <FileWatcherTabItem>()
                .WithConstructorArgument("filename", filename)
                .WithConstructorArgument("hightlightsHelper", hightlightsHelper);
            }

            ITabItem tab = Kernel.Get <ITabItem>();

            Kernel.Unbind <ITabItem>();

            return(tab);
        }
 public OxTailHelpers.ISaveExpressionMessage CreateWindow()
 {
     return(Kernel.Get <ISaveExpressionMessage>());
 }
Example #6
0
 public IFindWindow CreateWindow()
 {
     return(Kernel.Get <IFindWindow>("Find"));
 }
 protected override System.Web.Mvc.IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType)
 {
     return(controllerType == null
     ? null
     : (System.Web.Mvc.IController)ninjectKernel.Get(controllerType));
 }
 public IExpressionBuilderWindow CreateWindow()
 {
     return(Kernel.Get <IExpressionBuilderWindow>("ExpressionBuilder"));
 }
Example #9
0
        protected override void OnStartup(StartupEventArgs e)
        {
            Kernel = new StandardKernel();

            // Split the kernel loading into seperate modules that contain logically related content
            // There is some overlapping dependencies at the moment that I'd like to refactor.
            // And should you Ninject your Ninject modules?
            Kernel.Load(new INinjectModule[] { new MasterModule(this) });

            MainWindow mainWindow = Kernel.Get<MainWindow>();
            mainWindow.Show();
        }
Example #10
0
 public IWindow CreateWindow(string window)
 {
     return(Kernel.Get <IWindow>(window));
 }