コード例 #1
0
        /// <inheritdoc />
        public MutableMethodInfo GetOverride(MethodInfo baseDefinition, IEnumerable <MutableMethodInfo> overrideCandidates)
        {
            ArgumentUtility.CheckNotNull("baseDefinition", baseDefinition);
            ArgumentUtility.CheckNotNull("overrideCandidates", overrideCandidates);
            Assertion.DebugAssert(s_memberInfoEqualityComparer.Equals(baseDefinition, MethodBaseDefinitionCache.GetBaseDefinition(baseDefinition)));

            return(overrideCandidates.SingleOrDefault(
                       m => s_memberInfoEqualityComparer.Equals(baseDefinition, MethodBaseDefinitionCache.GetBaseDefinition(m)) ||
                       m.AddedExplicitBaseDefinitions.Contains(baseDefinition, s_memberInfoEqualityComparer)));
        }
コード例 #2
0
        /// <inheritdoc />
        public bool IsShadowed(MethodInfo baseDefinition, IEnumerable <MethodInfo> shadowingCandidates)
        {
            ArgumentUtility.CheckNotNull("baseDefinition", baseDefinition);
            ArgumentUtility.CheckNotNull("shadowingCandidates", shadowingCandidates);
            Assertion.DebugAssert(s_memberInfoEqualityComparer.Equals(baseDefinition, MethodBaseDefinitionCache.GetBaseDefinition(baseDefinition)));

            return(shadowingCandidates.Any(
                       m => m.Name == baseDefinition.Name &&
                       MethodSignature.AreEqual(m, baseDefinition) &&
                       baseDefinition.DeclaringType.IsTypePipeAssignableFrom(m.DeclaringType.BaseType) &&
                       !s_memberInfoEqualityComparer.Equals(baseDefinition, MethodBaseDefinitionCache.GetBaseDefinition(m))));
        }
コード例 #3
0
        /// <inheritdoc />
        public MethodInfo GetBaseMethod(MethodInfo method)
        {
            ArgumentUtility.CheckNotNull("method", method);
            Assertion.IsNotNull(method.DeclaringType);

            var baseDefinition = MethodBaseDefinitionCache.GetBaseDefinition(method);

            if (baseDefinition.DeclaringType.BaseType == null)
            {
                return(null);
            }

            return(GetMostDerivedOverride(baseDefinition, method.DeclaringType.BaseType));
        }
コード例 #4
0
 private bool HasSameBaseDefinition(MethodInfo a, MethodInfo b)
 {
     return(MethodBaseDefinitionCache.GetBaseDefinition(a) == MethodBaseDefinitionCache.GetBaseDefinition(b));
 }
コード例 #5
0
        /// <inheritdoc />
        public MethodInfo GetMostDerivedOverride(MethodInfo baseDefinition, Type typeToStartSearch)
        {
            ArgumentUtility.CheckNotNull("baseDefinition", baseDefinition);
            ArgumentUtility.CheckNotNull("typeToStartSearch", typeToStartSearch);
            Assertion.DebugAssert(s_memberInfoEqualityComparer.Equals(baseDefinition, MethodBaseDefinitionCache.GetBaseDefinition(baseDefinition)));

            Func <MethodInfo, bool> predicate = m =>
                                                s_memberInfoEqualityComparer.Equals(baseDefinition, MethodBaseDefinitionCache.GetBaseDefinition(m));

            return(FirstOrDefaultFromOrderedBaseMethods(typeToStartSearch, predicate));
        }
コード例 #6
0
 private bool SafeHasSameBaseDefinition(MethodInfo a, MethodInfo b)
 {
     return(a != null && b != null && MethodBaseDefinitionCache.GetBaseDefinition(a) == MethodBaseDefinitionCache.GetBaseDefinition(b));
 }