public Int32 GetConstructorIndex(Type fragmentType) { ListQuery <FragmentConstructorInfo> infos = null; Int32 result = -1; if (this._constructorsForFragments.TryGetValue(fragmentType, out infos) && infos.Count > 0) { FragmentConstructorInfo ctorWithoutParams = infos.FirstOrDefault(ctor => !ctor.Model.Parameters.Any() && ctor.RuntimeInfo.DeclaringType.Equals(fragmentType.GetBaseType())); Type[] types = this._usesContainer.ContainedTypes.ToArray(); if (types.Any()) { // Need to find constructor with all [Uses] parameter types assignable foreach (FragmentConstructorInfo info in infos) { ParameterInfo[] pInfos = info.Parameters; Boolean match = info.Model.Parameters.All(paramModel => !(paramModel.InjectionScope is UsesAttribute) || this._usesContainer.HasValue(pInfos[paramModel.NativeInfo.Position].ParameterType, ((UsesAttribute)paramModel.InjectionScope).Name)); if (match) { result = info.Model.ConstructorIndex; break; } } } if (result == -1) { if (ctorWithoutParams == null) { result = infos.First(ctor => ctor.RuntimeInfo.DeclaringType.Equals(fragmentType)).Model.ConstructorIndex; } else { result = ctorWithoutParams.Model.ConstructorIndex; } } } return(result); }