示例#1
0
        public void ShouldOnlyHaveDependenciesInjectionAspectByDefault()
        {
            Type t = typeof(AspectTestWithNoAttributes);
            List<Aspects> r = new AspectUtils(t).WishedAspects();

            Assert.IsTrue(r.Count == 1);
            Assert.That(r[0], Is.EqualTo(Aspects.RESOLVE_DEPENDENCIES));
        }
示例#2
0
        public void ShouldIdenftifyWishedAspects()
        {
            Type t = typeof(AspectTest);
            List<Aspects> r = new AspectUtils(t).WishedAspects();

            Assert.IsTrue(r.Contains(Aspects.REQUIRE_TRANSACTION));
            Assert.IsTrue(r.Contains(Aspects.RESOLVE_DEPENDENCIES));
            Assert.IsFalse(r.Contains(Aspects.LOG));
            Assert.IsTrue(r.Count == 2);
        }
        private void InjectDependency(IMethodInvocation input, PropertyInfo property, AutowiredAttribute inject, Type abstractType)
        {
            Type concreteType;
            if (inject.concreteType != null)
            {
                concreteType = inject.concreteType;
            }
            else {
                concreteType = ResolveTypes(inject.Url, abstractType);
            }
            List<Aspects> aspects = new AspectUtils(concreteType).WishedAspects();
            var objInstance = this.context.GetStickedWith(concreteType, this.BehaviorsFromAspects(aspects));

            property.SetValue(input.Target, objInstance, null);
        }