Esempio n. 1
0
 public void TypeRequired()
 {
     Should.Throw <ArgumentNullException>(() => PropertyInjectionUtils.TypeRequired(null));
     Should.NotThrow(() => PropertyInjectionUtils.TypeRequired(typeof(PropertyInjectionService))).ShouldBeTrue();
     Should.NotThrow(() => PropertyInjectionUtils.TypeRequired(typeof(NonPropertyInjectionService))).ShouldBeFalse();
     Should.NotThrow(() => PropertyInjectionUtils.TypeRequired(typeof(ReadOnlyPropertyInjectionService))).ShouldBeFalse();
 }
Esempio n. 2
0
        internal static bool RequiredPropertyInjection(this ServiceDefinition serviceDefinition)
        {
            Check.NotNull(serviceDefinition, nameof(serviceDefinition));
            if (serviceDefinition.GetType().Name == "ProxyServiceDefinition" && serviceDefinition.ServiceType.GetTypeInfo().IsInterface)
            {
                return(false);
            }
            var implType = serviceDefinition.GetImplementationType();

            if (implType == null)
            {
                return(false);
            }
            if (implType == typeof(object))
            {
                return(true);
            }
            return(PropertyInjectionUtils.TypeRequired(implType));
        }