Exemplo n.º 1
0
        public void InjectTo(object o)
        {
            ITypeBlueprint blueprint = DIBlueprintRepository.Get(o.GetType());

            ITypeElement typeElement = FindElementByType(blueprint, targetValue.GetType());

            RaiseException.WhenTrue(typeElement == null, "Blueprint '{0}' has no AutoInject field/property assignable from '{1}'!", blueprint.Type, targetValue.GetType());

            typeElement.SetValue(o, targetValue);
        }
Exemplo n.º 2
0
        public void InjectTo(object o)
        {
            ITypeBlueprint blueprint = DIBlueprintRepository.Get(o.GetType());

            ITypeElement typeElement = FindElementByName(blueprint);

            RaiseException.WhenTrue(typeElement == null, "Blueprint '{0}' has no AutoInject field/property with name '{1}'!", blueprint.Type, name);
            RaiseException.WhenFalse(targetValue == null || typeElement.ElementType.IsAssignableFrom(targetValue.GetType()), "Element '{0}' in blueprint '{1}' is not assignable from {2}", name, blueprint.Type, targetValue.GetType());

            typeElement.SetValue(o, targetValue);
        }