﻿using System;
using Ninject;
using Ninject.Parameters;

namespace Prism.Ninject
{
    public static class NinjectExtensions
    {
        public static bool IsRegistered<TService>(this IKernel kernel)
        {
            return kernel.IsRegistered(typeof(TService));
        }

        public static bool IsRegistered(this IKernel kernel, Type type)
        {
            return kernel.CanResolve(kernel.CreateRequest(type, _ => true, new IParameter[] { }, false, false));
        }

        public static void RegisterTypeIfMissing<TFrom, TTo>(this IKernel kernel, bool asSingleton)
        {
            kernel.RegisterTypeIfMissing(typeof(TFrom), typeof(TTo), asSingleton);
        }

        public static void RegisterTypeIfMissing(this IKernel kernel, Type from, Type to, bool asSingleton)
        {
            // Don't do anything if there are already bindings registered
            if (kernel.IsRegistered(from))
            {
                return;
            }

            // Register the types
            var binding = kernel.Bind(from).To(to);
            if (asSingleton)
            {
                binding.InSingletonScope();
            }
            else
            {
                binding.InTransientScope();
            }
        }
    }
}
﻿using System;
using Ninject;
using Ninject.Modules;
using Ninject.Parameters;

namespace Prism.Ninject
{
    public static class NinjectExtensions
    {
        public static bool IsRegistered<TService>(this IKernel kernel)
        {
            return kernel.IsRegistered(typeof(TService));
        }

        public static bool IsRegistered(this IKernel kernel, Type type)
        {
            return kernel.CanResolve(kernel.CreateRequest(type, _ => true, new IParameter[] { }, false, false));
        }

        public static void RegisterTypeIfMissing<TFrom, TTo>(this IKernel kernel, bool asSingleton)
        {
            kernel.RegisterTypeIfMissing(typeof(TFrom), typeof(TTo), asSingleton);
        }

        public static void RegisterTypeIfMissing(this IKernel kernel, Type from, Type to, bool asSingleton)
        {
            // Don't do anything if there are already bindings registered
            if (kernel.IsRegistered(from))
            {
                return;
            }

            // Register the types
            var binding = kernel.Bind(from).To(to);
            if (asSingleton)
            {
                binding.InSingletonScope();
            }
            else
            {
                binding.InTransientScope();
            }
        }
        public static void RegisterTypeForNavigation<T>(this NinjectModule ninjectModule)
        {
            ninjectModule.Bind<object>().To<T>().Named(typeof(T).Name);
        }

        public static void RegisterTypeForNavigation<T>(this IKernel kernel)
        {
            kernel.Bind<object>().To<T>().Named(typeof(T).Name);
        }
    }
}
Add RegisterTypeForNavigation to IKernel and NinjectModule
Add RegisterTypeForNavigation to IKernel and NinjectModule

Add extensions for RegisterTypeForNavigation to IKernel  and Ninjectmodule, similar to the method available on Container for Unity/MEF.
