public int CompareTo(IConstructionInfo other) { // ReSharper disable once ImpureMethodCallOnReadonlyValueField var isConfiguredComparison = other.IsConfigured.CompareTo(IsConfigured); if (isConfiguredComparison != 0) { return(isConfiguredComparison); } var conditionalComparison = IsUnconditional.CompareTo(other.IsUnconditional); if (conditionalComparison != 0) { return(conditionalComparison); } var paramCountComparison = ParameterCount.CompareTo(other.ParameterCount); if (paramCountComparison != 0) { return(paramCountComparison); } var priorityComparison = other.Priority.CompareTo(Priority); return(priorityComparison); }
internal DiStrategy(IDiConstructorMap diConstructorMap, IDiArgumentBuilderFactory diArgumentBuilderFactory, IObjectBuilderFactory objectBuilderFactory) { IConstructionInfo constructionInfo = diConstructorMap.FindBestConstructorForDi(); IArgumentBuilder argumentBuilder = diArgumentBuilderFactory.CreateBuilderFor(constructionInfo); _objectBuilder = objectBuilderFactory.CreateBuilder(constructionInfo, argumentBuilder); }
public object RetrieveService(object[] arguments) { IConstructionInfo constructionInfo = _argumentConstructorMap.FindBestConstructorForArguments(arguments); IArgumentBuilder argumentBuilder = _userArgumentBuilderFactory.CreateBuilderFor(constructionInfo, arguments); IObjectBuilder objectBuilder = _objectBuilderFactory.CreateBuilder(constructionInfo, argumentBuilder); return(objectBuilder.BuildObject()); }
public void TestFindBestConstructorCallsAcceptsArguments() { var constructors = SetupConstructors(SetupConstructorEligible()); IConstructionInfo constructionInfo = FindBestConstructorForArguments(); Assert.NotNull(constructionInfo); VerifyAcceptsArgumentsCalled(constructors[0]); }
public void TestFindsElibigbleConstructor() { var constructors = SetupConstructors(SetupConstructorNotEligible(), SetupConstructorNotEligible(), SetupConstructorEligible()); IConstructionInfo constructionInfo = FindBestConstructorForArguments(); Assert.Equal(constructors[2].Object, constructionInfo); }
public void TestReturnsSmallestArgumentCountConstructor() { const int expectedParameterCount = 12; SetupConstructors(SetupConstructorWithParameterCount(50), SetupConstructorWithParameterCount(expectedParameterCount), SetupConstructorWithParameterCount(18)); IConstructionInfo constructionInfo = FindBestConstructorForDi(); Assert.Equal(expectedParameterCount, constructionInfo.ParameterCount); }
public Construction(IConstructionInfo info, Expression construction, Expression condition = null) : this(construction, condition) { _info = info; }