Пример #1
0
		static void Main(string[] args)
		{
			DependencyInjectionContainer container = new DependencyInjectionContainer();

			container.Configure(c => c.Export(Types.FromThisAssembly()).ByInterfaces());

			var context = container.CreateContext();

			context.Export("baseUrl", (s, c) => BaseUrl);

			var projectProcessor = container.Locate<IProjectReadmeGenerator>(context);

			projectProcessor.GenerateReadme(BaseOutputDir, BaseProjectDir + "DependencyInjection/");
		}
Пример #2
0
        public void ContextConvertType()
        {
            DependencyInjectionContainer container = new DependencyInjectionContainer();

            container.Configure(c => c.Export<IntConstructorClass>().ByInterfaces());

            var context = container.CreateContext();

            context.Export("testValue", (s, c) => "5");

            var intClass = container.Locate<IIntConstructorClass>(injectionContext: context);

            Assert.NotNull(intClass);

            Assert.Equal(5, intClass.TestValue);
        }