private bool SafisfiesPartialTypeArguments(CandicateServiceType candicateServiceType) { if (!this.isPartialOpenGenericImplementation) { return(true); } return(this.SafisfiesPartialTypeArguments(candicateServiceType.Arguments)); }
private bool SatisfiesGenericTypeConstraints(CandicateServiceType openCandidateServiceType) { // Type arguments that don't match are left out of the list. // When the length of the result does not match the actual length, this means that the generic // type constraints don't match and the given service type does not satisfy the generic type // constraints. return(openCandidateServiceType.Arguments.Count() == this.openGenericImplementation.GetGenericArguments().Length); }
private bool MatchesClosedGenericBaseType(CandicateServiceType openCandidateServiceType) { if (this.openGenericImplementation.IsGenericType()) { return(this.SatisfiesGenericTypeConstraints(openCandidateServiceType)); } // When there are no generic type arguments, there are (obviously) no generic type constraints // so checking for the number of argument would always succeed, while this is not correct. // Instead we should check whether the given service type is the requested closed generic base // type. return(this.closedGenericBaseType == openCandidateServiceType.ServiceType); }
private Type BuildClosedGenericImplementationBasedOnMatchingServiceType( CandicateServiceType candicateServiceType) { if (this.openGenericImplementation.IsGenericType()) { try { return(this.openGenericImplementation.MakeGenericType(candicateServiceType.Arguments)); } catch (ArgumentException) { // This can happen when there is a type constraint that we didn't check. For instance // the constraint where TIn : TOut is one we cannot check and have to do here (bit ugly). return(null); } } else { return(this.openGenericImplementation); } }
private bool SafisfiesPartialTypeArguments(CandicateServiceType candicateServiceType) { if (!this.isPartialOpenGenericImplementation) { return true; } return this.SafisfiesPartialTypeArguments(candicateServiceType.Arguments); }
private bool SatisfiesGenericTypeConstraints(CandicateServiceType openCandidateServiceType) { // Type arguments that don't match are left out of the list. // When the length of the result does not match the actual length, this means that the generic // type constraints don't match and the given service type does not satisfy the generic type // constraints. return openCandidateServiceType.Arguments.Count() == this.openGenericImplementation.GetGenericArguments().Length; }
private bool MatchesClosedGenericBaseType(CandicateServiceType openCandidateServiceType) { if (this.openGenericImplementation.Info().IsGenericType) { return this.SatisfiesGenericTypeConstraints(openCandidateServiceType); } // When there are no generic type arguments, there are (obviously) no generic type constraints // so checking for the number of argument would always succeed, while this is not correct. // Instead we should check whether the given service type is the requested closed generic base // type. return this.closedGenericBaseType == openCandidateServiceType.ServiceType; }
private Type BuildClosedGenericImplementationBasedOnMatchingServiceType( CandicateServiceType candicateServiceType) { if (this.openGenericImplementation.Info().IsGenericType) { try { return this.openGenericImplementation.MakeGenericType(candicateServiceType.Arguments); } catch (ArgumentException) { // This can happen when there is a type constraint that we didn't check. For instance // the constraint where TIn : TOut is one we cannot check and have to do here (bit ugly). return null; } } else { return this.openGenericImplementation; } }