private IndexerDescriptor CreateIndexerDescriptor(object[] indexValues) { if ((indexValues == null) || (indexValues.Length <= 0) || (m_targetType == null)) { return(null); } var best = default(IndexerChoice); foreach (var propertyInfo in m_targetType.GetProperties()) { var candidate = IndexerChoice.GetMatch(propertyInfo, indexValues); if (candidate == null) { continue; } if ((best == null) || (candidate.CompareTo(best) > 0)) { best = candidate; } } // No matching indexer was found. if (best == null) { return(null); } return(IndexerDescriptor.Create(best.Property, indexValues, best.Values)); }
internal int CompareTo(IndexerChoice comparand) { if (comparand == null) { throw new ArgumentNullException("comparand"); } if (comparand.m_fitTypes.Length != m_fitTypes.Length) { throw new ArgumentException("The indexer does not have the same number of parameters.", "comparand"); } for (int i = 0; i < m_fitTypes.Length; i++) { var compare = m_fitTypes[i].CompareTo(comparand.m_fitTypes[i]); if (compare != 0) { return(compare); } } return(0); }