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(); }
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)); }