public IEnumerable <IFactory> Filter(Type targetType, IEnumerable <IFactory> factories) { return(factories .Where(x => !AssignableChecker.Check(x.ResultType, typeof(ValueType))) .Where(x => x.ResultType != typeof(void)) .Where(x => AssignableChecker.Check(x.ResultType, targetType))); }
public Type ProvideType(Type declarationType, Attribute attribute) { if (attribute is FactoryResult factoryResult) { if (AssignableChecker.Check(factoryResult.ResultType, declarationType)) { return(factoryResult.ResultType); } } else if (attribute is FactoryAttribute factoryAttr) { if (AssignableChecker.Check(factoryAttr.ResultType, declarationType)) { return(factoryAttr.ResultType); } } return(declarationType); }