internal static void Initialize(params Profile[] profiles)
        {
            var profilesList = new List <Profile>
            {
                new TimeTrackerProfile(),
                new TimeTrackerResourcesProfile()
            };

            profilesList.AddRange(profiles);

            var kernel = new StandardKernel(
                new WorkflowNinjectModule(),
                new AutoMapperModule(profilesList.ToArray()));

            ManualDependencyResolver.SetKernel(kernel);
        }
Beispiel #2
0
        /// <summary>
        ///     Creates the kernel that will manage your application.
        /// </summary>
        /// <returns>The created kernel.</returns>
        public static IKernel CreateKernel(params INinjectModule[] modules)
        {
            var kernel = new StandardKernel(modules);

            try
            {
                kernel.Bind <Func <IKernel> >().ToMethod(ctx => () => new Bootstrapper().Kernel);

                ManualDependencyResolver.SetKernel(kernel);                                 // Manual
                // ReSharper disable once AccessToDisposedClosure
                ServiceLocator.SetLocatorProvider(() => new NinjectServiceLocator(kernel)); // Log4Net
                GlobalConfiguration.Configuration.DependencyResolver =
                    new global::Ninject.Web.WebApi.NinjectDependencyResolver(kernel);       // Web API

                return(kernel);
            }
            catch
            {
                kernel.Dispose();
                throw;
            }
        }