Exemplo n.º 1
0
 public static void RegistarInyecciones(IServiceCollection services)
 {
     InjectionContainer.InyectarQL(services);
     InjectionContainer.InyectarServiciosApp(services);
     InjectionContainer.InyectarRepositorio(services);
     InjectionContainer.InyectarContext(services);
 }
Exemplo n.º 2
0
        public void TestBindWhenComplexConditionByMemberName()
        {
            var container = new InjectionContainer(ResolutionMode.RETURN_NULL);

            container.Bind <IMockInterface>().To <MockIClass>().When(context =>
                                                                     context.memberName.Equals("property2")
                                                                     );
            container.Bind <IMockInterface>().To <MockIClass>().When(context =>
                                                                     context.memberName.Equals("field2")
                                                                     );
            container.Bind <MockClassToDepend>().ToSelf().When(context =>
                                                               context.member.Equals(InjectionMember.Method) &&
                                                               context.memberName.Equals("field2")
                                                               );
            container.Bind <MockClassInjectAll>().ToSingleton();

            var instance = container.Resolve <MockClassInjectAll>();

            Assert.IsNull(instance.property1);
            Assert.AreEqual(typeof(MockIClass), instance.property2.GetType());
            Assert.IsNull(instance.property3);

            Assert.IsNull(instance.field1);
            Assert.AreEqual(typeof(MockIClass), instance.field2.GetType());
            Assert.IsNull(instance.field3);

            Assert.AreNotEqual(instance.property2, instance.field2);

            Assert.IsNull(instance.fieldFromConstructor1);
            Assert.IsNull(instance.fieldFromConstructor2);

            Assert.IsNull(instance.fieldFromMethod1);
            Assert.IsNotNull(instance.fieldFromMethod2);
        }
        public void RegisterAOT_T_Correct()
        {
            //Arrange
            var container = new InjectionContainer();
            ICommandDispatcher dispatcher;
            someClass          sc = new someClass();

            //Act
            container
            .RegisterAOT <UnityContainerAOT>()
            .RegisterAOT <EventContainerAOT>()
            .RegisterAOT <CommanderContainerAOT>()
            .RegisterCommand <TestCommand1>()
            .Bind <Transform>().ToPrefab("06_Commander/Prism");
            container.PoolCommands();

            dispatcher = container.GetCommandDispatcher();
            dispatcher.Dispatch <TestCommand1>(sc);
            //Assert
            Assert.AreEqual(
                true,
                dispatcher != null &&
                sc.id == 1 &&
                container.GetTypes <Transform>().Count == 1 &&
                ((PrefabInfo)container.GetTypes <Transform>()[0].value).path == "06_Commander/Prism");
        }
Exemplo n.º 4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services
            .AddMvc(i => i.Filters.Add(typeof(ValidateModelFilterAttribute)))
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddEntityFrameworkNpgsql()
            .AddDbContext <RestaurantContext>(opt =>
                                              opt.UseNpgsql(Configuration.GetConnectionString("Restaurant")));

            services.AddAutoMapper(s => s.AddProfile(new DtoMapper()));

            InjectionContainer.DoInjection(services);

            services.AddSwaggerGen(c =>
                                   c.SwaggerDoc("v1",
                                                new Info
            {
                Title       = "Gerenciador de Restaurante",
                Version     = "v1",
                Description = "API do Sistema Gerenciador de Restaurantes",
                Contact     = new Contact
                {
                    Name = "Ronaldo  Ribeiro",
                    Url  = "https://github.com/ronaldosjr/Restaurant"
                }
            }));
        }
Exemplo n.º 5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services
            .AddMvc(i => i.Filters.Add(typeof(ValidateModelFilterAttribute)))
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddMvc().AddJsonOptions(options => {
                options.SerializerSettings.ContractResolver      = new CamelCasePropertyNamesContractResolver();
                options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            });

            services.AddEntityFrameworkNpgsql()
            .AddDbContext <SalesContext>(opt =>
                                         opt.UseNpgsql(Configuration.GetConnectionString("Sales")));

            services.AddAutoMapper(s => s.AddProfile(new DtoMapper()));

            InjectionContainer.DoInjection(services);

            services.AddSwaggerGen(c =>
                                   c.SwaggerDoc("v1",
                                                new Info
            {
                Title       = "Gerenciador de Vendas",
                Version     = "v1",
                Description = "API do Sistema Gerenciador de Vendas",
                Contact     = new Contact
                {
                    Name = "Ronaldo  Ribeiro",
                    Url  = "https://github.com/ronaldosjr/SegImob"
                }
            }));
        }
Exemplo n.º 6
0
        public async Task <ActionResult> Information()
        {
            //类型列表
            int parentid = TypeInfoParentIds.Information;
            var list     = await InjectionContainer.Resolve <ITypeInfoStorage>().GetListAsync(parentid);

            ViewBag.TypeList = list.Where(i => i.parentid == parentid).OrderBy(i => i.sort).Select(i => new
            {
                i.typeid,
                i.text
            });
            // 分页列表
            var pageList = await InjectionContainer.Resolve <IArticleStorage>().GetPagedListAsync(1, 10, "", list.Count() > 0 ? list.First().typeid : 0, -1, -1, -1, "created_DESC");

            ViewBag.InformationList = new
            {
                list  = pageList.RowSet.Select(i => Projections.GetArticleProjection(i)),
                count = pageList.Count
            };
            //热点阅读
            var hotList = await InjectionContainer.Resolve <IArticleStorage>().GetPagedListAsync(1, 6, "", 0, 1, -1, -1, "created_DESC");

            ViewBag.HotList = pageList.RowSet.Select(i => Projections.GetArticleProjection(i));

            return(View());
        }
Exemplo n.º 7
0
        //injeccion de dependencias
        private static void RegistrarInyecciones(IServiceCollection services, IConfiguration Configuration)
        {
            InjectionContainer.InyectarDbSettings(services, Configuration);

            InjectionContainer.InyectarDbContext(services);
            InjectionContainer.InyectarRepositorio(services);
            InjectionContainer.InyectarServicios(services);
        }
Exemplo n.º 8
0
        public void TestResolutionModeReturnNullNotBound()
        {
            var container = new InjectionContainer(ResolutionMode.RETURN_NULL);

            var instance = container.Resolve <MockClassManyInterfaces>();

            Assert.IsNull(instance);
        }
Exemplo n.º 9
0
        public void WhenDataStoreInConfigIsMain_InitializesDataStore()
        {
            ConfigurationManager.AppSettings["DataStoreType"] = "Main";

            var ioc = new InjectionContainer();
            var accountDataStore = ioc.GetProvider().GetRequiredService <IAccountDataStore>();

            Assert.IsType <AccountDataStore>(accountDataStore);
        }
Exemplo n.º 10
0
        public void TestResolutionModeReturnNullBound()
        {
            var container = new InjectionContainer(ResolutionMode.ALWAYS_RESOLVE);

            container.Bind <IMockInterface1>().ToSingleton <MockClassManyInterfaces>();

            var instance = container.Resolve <IMockInterface1>();

            Assert.NotNull(instance);
        }
Exemplo n.º 11
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //CORS
            services.AddCors();

            services.AddControllers();

            InjectionContainer.InjectEntities(services, this.Configuration);

            InjectionContainer.AddAuthentication(services, this.Configuration);
        }
Exemplo n.º 12
0
        public async Task AuthenticateAsync(HttpAuthenticationContext context, CancellationToken cancellationToken)
        {
            //判断是否匿名访问的接口或控制器
            if (!context.ActionContext.ActionDescriptor.GetCustomAttributes <AllowAnonymousAttribute>(false).Any() &&
                !context.ActionContext.ControllerContext.ControllerDescriptor.GetCustomAttributes <AllowAnonymousAttribute>(false).Any())
            {
                string token = "";
                //从url中获取token
                var qs = context.Request.GetQueryNameValuePairs().ToDictionary(i => i.Key, i => i.Value);
                if (qs.ContainsKey("token"))
                {
                    token = qs["token"];
                }
                else
                {
                    var httpContext = context.Request.GetHttpContext();
                    token = httpContext.Request["token"];
                }
                if (string.IsNullOrWhiteSpace(token) || Regex.Matches(token, @"\.").Count != 4)
                {
                    throw new HttpResponseException(HttpStatusCode.Unauthorized);
                }

                //解析token荷载部分
                JwePayload payload = null;
                try
                {
                    payload = JweProvider.Decode(token, JwtCommon.SignKey);
                }
                catch (Exception e)
                {
                    LogProvider.Error.Error(e, "解析jwepayload失败");
                }
                if (payload == null)
                {
                    throw new HttpResponseException(HttpStatusCode.Unauthorized);
                }
                //判断是否过期
                if (payload.IsExpires())
                {
                    throw new HttpResponseException(HttpStatusCode.Unauthorized);
                }
                var user = await InjectionContainer.Resolve <IUserStorage>().GetAsync(payload.uid);

                if (user == null)
                {
                    throw new HttpResponseException(HttpStatusCode.Unauthorized);
                }
                //保存user
                context.Request.Properties.Add(HttpPropertyKeys.AuthorizedUser, user);
                //保存jwe payload
                context.Request.Properties.Add(HttpPropertyKeys.JwePayload, payload);
            }
        }
Exemplo n.º 13
0
        public void TestResolveToNamespaceTransient()
        {
            var container = new InjectionContainer();

            container.Bind <IMockInterface>().ToNamespace("Adic.Tests");
            var instance = container.ResolveAll <IMockInterface>();

            Assert.AreEqual(3, instance.Length);
            Assert.IsTrue(instance[0] is MockIClass);
            Assert.IsTrue(instance[1] is MockIClassWithoutAttributes);
            Assert.IsTrue(instance[2] is MockIClassWithAttributes);
        }
Exemplo n.º 14
0
        public void TestResolveFromFactoryInstance()
        {
            var container = new InjectionContainer();

            container.Bind <MockIClassWithAttributes>().ToFactory(new MockFactory());
            var instance = container.Resolve <MockIClassWithAttributes>();

            Assert.NotNull(instance);
            Assert.AreEqual("Created from a Factory", instance.field1);
            Assert.AreEqual("Created from a Factory", instance.field2);
            Assert.AreEqual("Created from a Factory", instance.field3);
        }
        public void Inject_SomeClass_Correct()
        {
            //Arrange
            var         container = new InjectionContainer();
            someClass_c c         = new someClass_c();

            //Act
            container.Inject(c);
            //Assert
            Assert.AreEqual(
                true,
                c.b != null);
        }
        public void Resolve_SomeClass_Correct()
        {
            //Arrange
            var container = new InjectionContainer();
            //Act
            var instance = container.Resolve <someClass_c>();

            //Assert
            Assert.AreEqual(
                true,
                instance != null &&
                instance.b != null);
        }
Exemplo n.º 17
0
        public void TestBindWhenIntoByType()
        {
            var container = new InjectionContainer();

            container.Bind <IMockInterface>().To <MockIClassWithAttributes>().WhenInto(typeof(MockClassVerySimple));
            container.Bind <IMockInterface>().To <MockIClassWithoutAttributes>().WhenInto(typeof(MockClassSimple));

            var instance1 = container.Resolve <MockClassVerySimple>();
            var instance2 = container.Resolve <MockClassSimple>();

            Assert.AreEqual(typeof(MockIClassWithAttributes), instance1.field.GetType());
            Assert.AreEqual(typeof(MockIClassWithoutAttributes), instance2.field.GetType());
        }
Exemplo n.º 18
0
        public void TestBindAsIdentifier()
        {
            var container = new InjectionContainer();

            container.Bind <IMockInterface>().To <MockIClassWithAttributes>();
            container.Bind <IMockInterface>().To <MockIClassWithoutAttributes>().As("singleton");
            container.Bind <IMockInterface>().To <MockIClass>().As("test");

            var instance = container.Resolve <MockClassSimple>();

            Assert.AreEqual(typeof(MockIClassWithAttributes), instance.field.GetType());
            Assert.AreEqual(typeof(MockIClassWithoutAttributes), instance.property.GetType());
        }
        public void Dispose_Clearn_Correct()
        {
            //Arrange
            var container = new InjectionContainer();

            //Act
            container.Dispose();
            //Assert
            Assert.AreEqual(
                true,
                container.binder == null &&
                container.cache == null);
        }
Exemplo n.º 20
0
        /// <summary>
        /// 使用指定验证类验证对应的实体
        /// 若验证不同过,则抛出第一个错误异常
        /// </summary>
        /// <typeparam name="V">验证类</typeparam>
        /// <typeparam name="E">实体类</typeparam>
        /// <param name="entity"></param>
        public static void ThrowIfInValidate <V, E>(E entity)
            where V : AbstractValidator <E>
        {
            var validator = InjectionContainer.Resolve <V>();
            var result    = validator.Validate(entity);

            if (!result.IsValid)
            {
                //抛出第一个验证错误信息 //error.PropertyName
                var error = result.Errors[0];
                throw new ArgumentException(error.ErrorMessage);
            }
        }
Exemplo n.º 21
0
        public void TestResolutionModeReturnNullSingleton()
        {
            var container = new InjectionContainer(ResolutionMode.RETURN_NULL);

            container.Bind <IMockInterface>().ToSingleton <MockIClassWithAttributes>();

            var instance = container.Resolve <IMockInterface>();

            Assert.IsNotNull(instance);
            Assert.AreEqual(typeof(MockIClassWithAttributes), instance.GetType());
            Assert.Null(((MockIClassWithAttributes)instance).field4);
            Assert.Null(((MockIClassWithAttributes)instance).property4);
        }
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            var userManager = InjectionContainer.Get <IUserManager>();

            if (!userManager.IsLoggedIn)
            {
                return(false);
            }

            var roles = userManager.CurrentUser.Bonde.Rolles.Select(r => r.Kode);

            return(RolesArray.Any(roles.Contains));
        }
Exemplo n.º 23
0
        public void TestBindAsIdentifier()
        {
            var container = new InjectionContainer();

            container.Bind<IMockInterface>().To<MockIClassWithAttributes>();
            container.Bind<IMockInterface>().To<MockIClassWithoutAttributes>().As("singleton");
            container.Bind<IMockInterface>().To<MockIClass>().As("test");

            var instance = container.Resolve<MockClassSimple>();

            Assert.AreEqual(typeof(MockIClassWithAttributes), instance.field.GetType());
            Assert.AreEqual(typeof(MockIClassWithoutAttributes), instance.property.GetType());
        }
Exemplo n.º 24
0
        public void TestResolveMultiple()
        {
            var container = new InjectionContainer();

            container.Bind <IMockInterface>().To <MockIClass>();
            container.Bind <IMockInterface>().To <MockIClassWithAttributes>();
            container.Bind <IMockInterface>().To <MockIClassWithoutAttributes>();

            var instance = container.Resolve <MockClassMultiple>();

            Assert.AreEqual(3, instance.list.Length);
            Assert.AreEqual(typeof(MockIClass), instance.list[0].GetType());
            Assert.AreEqual(typeof(MockIClassWithAttributes), instance.list[1].GetType());
            Assert.AreEqual(typeof(MockIClassWithoutAttributes), instance.list[2].GetType());
        }
        public void RegisterSelf_CreatBinding_Correct()
        {
            //Arrange
            var container = new InjectionContainer();
            //Act
            //由于 RegisterSelf 方法于构造函数内部使用,所有不用也无法以 container.RegisterSelf() 形式调用;
            var binding = container.GetAll()[0];

            //Assert
            Assert.AreEqual(
                true,
                container.GetAll().Count == 1 &&
                binding.type == typeof(IInjectionContainer) &&
                binding.value == container);
        }
Exemplo n.º 26
0
        public void TestResolveToNamespaceSingleton()
        {
            var container = new InjectionContainer();

            container.Bind <IMockInterface>().ToNamespaceSingleton("Adic.Tests");
            var bindings = container.GetBindingsFor <IMockInterface>();
            var instance = container.ResolveAll <IMockInterface>();

            Assert.AreEqual(3, instance.Length);
            Assert.IsTrue(instance[0] is MockIClass);
            Assert.IsTrue(instance[1] is MockIClassWithoutAttributes);
            Assert.IsTrue(instance[2] is MockIClassWithAttributes);
            Assert.IsTrue(instance[0] == bindings[0].value);
            Assert.IsTrue(instance[1] == bindings[1].value);
            Assert.IsTrue(instance[2] == bindings[2].value);
        }
Exemplo n.º 27
0
        public override void SetupContainers()
        {
            IInjectionContainer container = new InjectionContainer()
                                            .RegisterExtension <UnityBindingContainerExtension>()
                                            .RegisterExtension <EventCallerContainerExtension>();

            IInjectionService injectionService = new InjectionService(container);

            container
            .Bind <IInjectionService>().To(injectionService)
            .Bind <IEntityGeneratorService>().ToSingleton <EntityGeneratorService>();

            BindControllers(container);

            AddContainer(container);
        }
Exemplo n.º 28
0
        /// <summary>
        /// 预加载网站启动相关步骤
        /// </summary>
        public static void PreRegister()
        {
            var config = GlobalConfiguration.Configuration;
            var dict   = new Dictionary <Type, object>();

            dict.Add(typeof(string), "vgoyun.com");
            InjectionContainer.Register <SqlStorageBase>(typeof(UserStorage).Assembly, dict);
            //注册数据库模型验证类
            InjectionContainer.Register <IValidator>(typeof(IUserStorage).Assembly);
            InjectionContainer.Build((builder) =>
            {
                // Register your Web API controllers.
                builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
                // OPTIONAL: Register the Autofac filter provider.
                builder.RegisterWebApiFilterProvider(config);
            }, c => config.DependencyResolver = new AutofacWebApiDependencyResolver(c));
        }
Exemplo n.º 29
0
        public async Task <ActionResult> Index()
        {
            string key = "homecontroller->banner.index.list";

            if (!CacheProvider.TryGet(key, out IEnumerable <Banner> list))
            {
                list = await InjectionContainer.Resolve <IBannerStorage>().GetListAsync(10, (int)BannerType.首页, "sort_DESC");

                if (list.Any())
                {
                    CacheProvider.Set(key, list, TimeSpan.FromMinutes(10));
                }
            }
            ViewBag.BannerList = list;

            return(View(list));
        }
Exemplo n.º 30
0
        public async Task <ActionResult> InformationDetail(int id)
        {
            var storage = InjectionContainer.Resolve <IArticleStorage>();
            var model   = await storage.GetAsync(id);

            if (model == null)
            {
                throw new Exception("指定资讯详情不存在");
            }
            //更新查看数
            model.seecount++;
            await storage.UpdateAsync(model);

            //获取页面数据
            var data = await storage.GetViewDataAsync(id);

            data.Current = model;

            return(View(data));
        }
Exemplo n.º 31
0
        public void TestBindAsIdentifierWhenIntoByInstance()
        {
            var instance1 = new MockClassVerySimple();
            var instance2 = new MockClassSimple();

            var container = new InjectionContainer();

            container.Bind <IMockInterface>()
            .To <MockIClassWithAttributes>().WhenIntoInstance(instance1);
            container.Bind <IMockInterface>()
            .To <MockIClassWithoutAttributes>().WhenIntoInstance(instance2).As("singleton");
            container.Bind <IMockInterface>()
            .To <MockIClass>().WhenInto <MockClassSimple>().WhenIntoInstance(instance2).As("test");

            container.Inject(instance1);
            container.Inject(instance2);

            Assert.AreEqual(typeof(MockIClassWithAttributes), instance1.field.GetType());
            Assert.IsNull(instance2.field);
            Assert.AreEqual(typeof(MockIClassWithoutAttributes), instance2.property.GetType());
        }
Exemplo n.º 32
0
        public void TestBindAsIdentifierWhenIntoByInstance()
        {
            var instance1 = new MockClassVerySimple();
            var instance2 = new MockClassSimple();

            var container = new InjectionContainer();

            container.Bind<IMockInterface>()
                .To<MockIClassWithAttributes>().WhenIntoInstance(instance1);
            container.Bind<IMockInterface>()
                .To<MockIClassWithoutAttributes>().WhenIntoInstance(instance2).As("singleton");
            container.Bind<IMockInterface>()
                .To<MockIClass>().WhenInto<MockClassSimple>().WhenIntoInstance(instance2).As("test");

            container.Inject(instance1);
            container.Inject(instance2);

            Assert.AreEqual(typeof(MockIClassWithAttributes), instance1.field.GetType());
            Assert.IsNull(instance2.field);
            Assert.AreEqual(typeof(MockIClassWithoutAttributes), instance2.property.GetType());
        }
Exemplo n.º 33
0
        public void TestResolveToNamespaceTransient()
        {
            var container = new InjectionContainer();

            container.Bind<IMockInterface>().ToNamespace("Adic.Tests");
            var instance = container.ResolveAll<IMockInterface>();

            Assert.AreEqual(3, instance.Length);
            Assert.IsTrue(instance[0] is MockIClass);
            Assert.IsTrue(instance[1] is MockIClassWithoutAttributes);
            Assert.IsTrue(instance[2] is MockIClassWithAttributes);
        }
Exemplo n.º 34
0
        public void TestResolveToNamespaceSingleton()
        {
            var container = new InjectionContainer();

            container.Bind<IMockInterface>().ToNamespaceSingleton("Adic.Tests");
            var bindings = container.GetBindingsFor<IMockInterface>();
            var instance = container.ResolveAll<IMockInterface>();

            Assert.AreEqual(3, instance.Length);
            Assert.IsTrue(instance[0] is MockIClass);
            Assert.IsTrue(instance[1] is MockIClassWithoutAttributes);
            Assert.IsTrue(instance[2] is MockIClassWithAttributes);
            Assert.IsTrue(instance[0] == bindings[0].value);
            Assert.IsTrue(instance[1] == bindings[1].value);
            Assert.IsTrue(instance[2] == bindings[2].value);
        }
Exemplo n.º 35
0
        public void TestResolveMultiple()
        {
            var container = new InjectionContainer();

            container.Bind<IMockInterface>().To<MockIClass>();
            container.Bind<IMockInterface>().To<MockIClassWithAttributes>();
            container.Bind<IMockInterface>().To<MockIClassWithoutAttributes>();

            var instance = container.Resolve<MockClassMultiple>();

            Assert.AreEqual(3, instance.list.Length);
            Assert.AreEqual(typeof(MockIClass), instance.list[0].GetType());
            Assert.AreEqual(typeof(MockIClassWithAttributes), instance.list[1].GetType());
            Assert.AreEqual(typeof(MockIClassWithoutAttributes), instance.list[2].GetType());
        }
Exemplo n.º 36
0
        public void TestResolveFromFactoryType()
        {
            var container = new InjectionContainer();

            container.Bind<MockIClassWithAttributes>().ToFactory(typeof(MockFactory));
            var instance = container.Resolve<MockIClassWithAttributes>();

            Assert.NotNull(instance);
            Assert.AreEqual("Created from a Factory", instance.field1);
            Assert.AreEqual("Created from a Factory", instance.field2);
            Assert.AreEqual("Created from a Factory", instance.field3);
        }
Exemplo n.º 37
0
        public void TestBindWhenComplexCondition()
        {
            var instance1 = new MockClassVerySimple();
            var instance2 = new MockClassSimple();
            var instance3 = new MockClassSimple();

            var container = new InjectionContainer();

            container.Bind<IMockInterface>().To<MockIClass>().When(context =>
                    context.member.Equals(InjectionMember.Field) &&
                    context.parentInstance.Equals(instance3)
                );

            container.Inject(instance1);
            container.Inject(instance2);
            container.Inject(instance3);

            Assert.IsNull(instance1.field);
            Assert.IsNull(instance2.field);
            Assert.IsNull(instance2.property);
            Assert.AreEqual(typeof(MockIClass), instance3.field.GetType());
            Assert.IsNull(instance3.property);
        }
Exemplo n.º 38
0
        public void TestBindWhenIntoByType()
        {
            var container = new InjectionContainer();

            container.Bind<IMockInterface>().To<MockIClassWithAttributes>().WhenInto(typeof(MockClassVerySimple));
            container.Bind<IMockInterface>().To<MockIClassWithoutAttributes>().WhenInto(typeof(MockClassSimple));

            var instance1 = container.Resolve<MockClassVerySimple>();
            var instance2 = container.Resolve<MockClassSimple>();

            Assert.AreEqual(typeof(MockIClassWithAttributes), instance1.field.GetType());
            Assert.AreEqual(typeof(MockIClassWithoutAttributes), instance2.field.GetType());
        }
Exemplo n.º 39
0
 public void Install(InjectionContainer.IInjectionContainer container, Common.IQueryStore queryStore)
 {
     container.Bind<IHttpHost, AspNetRoutedHost>();
     container.Bind<IItemManager, ThreadItemManager>();
 }
Exemplo n.º 40
0
		public void Init() {
			this.container = new InjectionContainer();
			this.container.Bind<IMockInterface>().To<MockIClass>();
			this.container.cache.CacheFromBinder(this.container);
		}