Exemple #1
0
        /// <inheritdoc/>
        public override void AcceptVisitor(IProxyDefinitionVisitor proxyDefinitionVisitor)
        {
            base.AcceptVisitor(proxyDefinitionVisitor);

            // Visit declaring type members.
            proxyDefinitionVisitor.VisitMembers(DeclaringType);
        }
        /// <inheritdoc/>
        public override void AcceptVisitor(IProxyDefinitionVisitor proxyDefinitionVisitor)
        {
            base.AcceptVisitor(proxyDefinitionVisitor);

            // Visit declaring type members.
            proxyDefinitionVisitor.VisitMembers(DeclaringType);
        }
        public override void AcceptVisitor(IProxyDefinitionVisitor proxyDefinitionVisitor)
        {
            base.AcceptVisitor(proxyDefinitionVisitor);

            proxyDefinitionVisitor.VisitInterfaces(DeclaringInterfaces);

            proxyDefinitionVisitor.VisitMembers(ParentType);
        }
        public static void VisitInterfaces(this IProxyDefinitionVisitor proxyDefinitionVisitor, IEnumerable <Type> interfaceTypes)
        {
            foreach (var interfaceType in interfaceTypes)
            {
                proxyDefinitionVisitor.VisitInterface(interfaceType);

                proxyDefinitionVisitor.VisitMembers(interfaceType);
            }
        }
        public override void AcceptVisitor(IProxyDefinitionVisitor proxyDefinitionVisitor)
        {
            base.AcceptVisitor(proxyDefinitionVisitor);

            var methodInfo = DeclaringType.GetMethod(DelegateMethodName, BindingFlags.Public | BindingFlags.Instance);

            proxyDefinitionVisitor.VisitMethod(methodInfo);
            proxyDefinitionVisitor.VisitMembers(ParentType);
        }
        /// <inheritdoc/>
        public override void AcceptVisitor(IProxyDefinitionVisitor proxyDefinitionVisitor)
        {
            base.AcceptVisitor(proxyDefinitionVisitor);

            // Visit declaring interface types.
            proxyDefinitionVisitor.VisitInterfaces(DeclaringInterfaces);

            // Visit parent type members.
            proxyDefinitionVisitor.VisitMembers(ParentType);
        }
        /// <inheritdoc/>
        public override void AcceptVisitor(IProxyDefinitionVisitor proxyDefinitionVisitor)
        {
            base.AcceptVisitor(proxyDefinitionVisitor);

            // Visit declaring interface types.
            proxyDefinitionVisitor.VisitInterfaces(DeclaringInterfaces);

            // Visit parent type members.
            proxyDefinitionVisitor.VisitMembers(ParentType);
        }
        public virtual void AcceptVisitor(IProxyDefinitionVisitor proxyDefinitionVisitor)
        {
            if (proxyDefinitionVisitor == null)
            {
                throw new ArgumentNullException("proxyDefinitionVisitor");
            }

            proxyDefinitionVisitor.VisitConstructors(_parentType);
            proxyDefinitionVisitor.VisitInterfaces(_additionalInterfaceTypes);
        }
        /// <summary>
        /// Visits all members of the specified type.
        /// </summary>
        /// <param name="proxyDefinitionVisitor">The proxy definition visitor.</param>
        /// <param name="type">The type.</param>
        public static void VisitMembers(this IProxyDefinitionVisitor proxyDefinitionVisitor, Type type)
        {
            // Visit events.
            proxyDefinitionVisitor.VisitEvents(type);

            // Visit properties.
            proxyDefinitionVisitor.VisitProperties(type);

            // Visit methods.
            proxyDefinitionVisitor.VisitMethods(type);
        }
        /// <inheritdoc/>
        public override void AcceptVisitor(IProxyDefinitionVisitor proxyDefinitionVisitor)
        {
            base.AcceptVisitor(proxyDefinitionVisitor);

            // Visit declaring type method.
            var methodInfo = DeclaringType.GetMethod(
                DelegateMethodName,
                BindingFlags.Public | BindingFlags.Instance);

            proxyDefinitionVisitor.VisitMethod(methodInfo);

            // Visit parent type members.
            proxyDefinitionVisitor.VisitMembers(ParentType);
        }
        private static void VisitMethods(this IProxyDefinitionVisitor proxyDefinitionVisitor, Type type)
        {
            if (proxyDefinitionVisitor == null)
            {
                throw new ArgumentNullException("proxyDefinitionVisitor");
            }

            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            var methodInfos = type.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance).Where(m => !m.IsSpecialName && !m.IsFromObject());

            foreach (var methodInfo in methodInfos)
            {
                proxyDefinitionVisitor.VisitMethod(methodInfo);
            }
        }
        public static void VisitConstructors(this IProxyDefinitionVisitor proxyDefinitionVisitor, Type type)
        {
            if (proxyDefinitionVisitor == null)
            {
                throw new ArgumentNullException("proxyDefinitionVisitor");
            }

            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            var constructorInfos = type.GetConstructors(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);

            foreach (var constructorInfo in constructorInfos)
            {
                proxyDefinitionVisitor.VisitConstructor(constructorInfo);
            }
        }
        private static void VisitEvents(this IProxyDefinitionVisitor proxyDefinitionVisitor, Type type)
        {
            if (proxyDefinitionVisitor == null)
            {
                throw new ArgumentNullException("proxyDefinitionVisitor");
            }

            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            var eventInfos = type.GetEvents(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance)
                             .Where(e => e.CanOverride());

            foreach (var eventInfo in eventInfos)
            {
                proxyDefinitionVisitor.VisitEvent(eventInfo);
            }
        }
        /// <summary>
        /// Visits all methods of the specified type.
        /// </summary>
        /// <param name="proxyDefinitionVisitor">The proxy definition visitor.</param>
        /// <param name="type">The type.</param>
        private static void VisitMethods(this IProxyDefinitionVisitor proxyDefinitionVisitor, Type type)
        {
            if (proxyDefinitionVisitor == null)
            {
                throw new ArgumentNullException("proxyDefinitionVisitor");
            }

            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            // Visit only non-accessor overridable instance methods.
            var methodInfos = type.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance)
                              .Where(m => !m.IsSpecialName && m.CanOverride());

            foreach (var methodInfo in methodInfos)
            {
                proxyDefinitionVisitor.VisitMethod(methodInfo);
            }
        }
        /// <summary>
        /// Visits all properties of the specified type.
        /// </summary>
        /// <param name="proxyDefinitionVisitor">The proxy definition visitor.</param>
        /// <param name="type">The type.</param>
        private static void VisitProperties(this IProxyDefinitionVisitor proxyDefinitionVisitor, Type type)
        {
            if (proxyDefinitionVisitor == null)
            {
                throw new ArgumentNullException("proxyDefinitionVisitor");
            }

            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            // Visit only overridable instance properties.
            var propertyInfos = type.GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance)
                                .Where(p => p.CanOverride());

            foreach (var propertyInfo in propertyInfos)
            {
                proxyDefinitionVisitor.VisitProperty(propertyInfo);
            }
        }
 public static void VisitMembers(this IProxyDefinitionVisitor proxyDefinitionVisitor, Type type)
 {
     proxyDefinitionVisitor.VisitMethods(type);
 }