public void ExportsWithNativeAndSingleNamedBindingsCanGetViaNameOrNative()
        {
            var exports = new[]
            {
                new ExportInfo
                {
                    IsShared = true,
                    Type     = typeof(NinjectTests),
                    Metadata = new[]
                    {
                        new Dictionary <string, object>
                        {
                        },
                        new Dictionary <string, object>
                        {
                            { "ContractName", "A" },
                        },
                    }
                }
            };

            IKernel kernel = new StandardKernel();

            kernel.BindExports(exports);

            var a = kernel.Get <NinjectTests>("A");
            var b = kernel.Get <NinjectTests>();

            Assert.AreEqual(a, b);
        }
        public IExportProvider Initialize()
        {
            var kernel = new StandardKernel();

            kernel.BindExports(typeof(MainWindow).Assembly);

            var exportProvider = new ExportProvider(kernel);

            kernel.Bind <IExportProvider>().ToConstant(exportProvider);
            kernel.Bind(syntax => syntax
                        .From(typeof(CoordinatesToPointConverter).Assembly)
                        .Select(type => typeof(IValueConverter).IsAssignableFrom(type))
                        .BindToSelf());

            _kernel = kernel;
            return(exportProvider);
        }
        public void ExportsWithNativeAndMultipleNamedBindingsCanGetViaNameOnly()
        {
            var exports = new[]
            {
                new ExportInfo
                {
                    IsShared = true,
                    Type     = typeof(NinjectTests),
                    Metadata = new[]
                    {
                        new Dictionary <string, object>
                        {
                        },
                        new Dictionary <string, object>
                        {
                            { "ContractName", "A" },
                        },
                        new Dictionary <string, object>
                        {
                            { "ContractName", "B" },
                        },
                    }
                }
            };

            IKernel kernel = new StandardKernel();

            kernel.BindExports(exports);

            var a = kernel.Get <NinjectTests>("A");
            var b = kernel.Get <NinjectTests>("B");

            Assert.AreEqual(a, b);

            try
            {
                var self = kernel.Get <NinjectTests>();
                Assert.Inconclusive("Should have thrown...");
            }
            catch (ActivationException)
            {
            }
        }
        public void ExportsWithSingleNamedBindingsCanGetViaNameOrNative()
        {
            var exports = new[]
            {
                new ExportInfo
                {
                    IsShared = true,
                    Type     = typeof(NinjectTests),
                    Metadata = new[]
                    {
                        new Dictionary <string, object>
                        {
                            { "ContractName", "A" },
                        },
                        new Dictionary <string, object>
                        {
                            { "ContractType", typeof(NinjectTests) },
                            { "ContractName", "A" },
                        },
                        new Dictionary <string, object>
                        {
                            { "ContractType", typeof(INotifyPropertyChanged) },
                            { "ContractName", "B" },
                        },
                    }
                }
            };

            IKernel kernel = new StandardKernel();

            kernel.BindExports(exports);

            var self = kernel.Get <NinjectTests>();
            var a    = kernel.Get <NinjectTests>("A");
            var b    = kernel.Get <INotifyPropertyChanged>();
            var c    = kernel.Get <INotifyPropertyChanged>("B");

            Assert.AreEqual(self, a);
            Assert.AreEqual(self, b);
            Assert.AreEqual(self, c);
        }