コード例 #1
0
        /// <summary>
        /// Gets the events that this one overrides or hides.
        /// Only includes overrides that appear on class types, not interfaces.
        /// </summary>
        /// <param name="overridesOnly">If true, only returns overrides.</param>
        public IEnumerable <StaticEventWrapper> GetOverridenOrHiddenEvents(bool overridesOnly)
        {
            StaticMethodWrapper discriminator = GetDiscriminatorMethod(this);

            if (overridesOnly && !discriminator.IsOverride)
            {
                yield break;
            }

            string eventName = Name;

            foreach (StaticDeclaredTypeWrapper baseType in DeclaringType.GetAllBaseTypes())
            {
                foreach (StaticEventWrapper other in ReflectionPolicy.GetTypeEvents(baseType, ReflectedType))
                {
                    if (eventName == other.Name)
                    {
                        if (overridesOnly)
                        {
                            StaticMethodWrapper otherDiscriminator = GetDiscriminatorMethod(other);
                            if (otherDiscriminator == null)
                            {
                                yield break;
                            }

                            if (discriminator.HidesMethod(otherDiscriminator))
                            {
                                yield return(other);

                                if (!otherDiscriminator.IsOverride)
                                {
                                    yield break;
                                }
                                break;
                            }
                        }
                        else
                        {
                            yield return(other);
                        }
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets the methods that this one overrides or hides.
        /// Only includes overrides that appear on class types, not interfaces.
        /// </summary>
        /// <param name="overridesOnly">If true, only returns overrides.</param>
        public IEnumerable <StaticMethodWrapper> GetOverridenOrHiddenMethods(bool overridesOnly)
        {
            if (overridesOnly && !IsOverride)
            {
                yield break;
            }

            foreach (StaticDeclaredTypeWrapper baseType in DeclaringType.GetAllBaseTypes())
            {
                foreach (StaticMethodWrapper other in ReflectionPolicy.GetTypeMethods(baseType, ReflectedType))
                {
                    if (HidesMethod(other))
                    {
                        yield return(other);

                        if (overridesOnly && !other.IsOverride)
                        {
                            yield break;
                        }
                        break;
                    }
                }
            }
        }