コード例 #1
0
            protected override Expression VisitMember(MemberExpression node)
            {
                EnsureTypeInitialized(node.Member.DeclaringType);

                CompiledExpression cp;

                if (map.TryGetValue(node.Member, out cp))
                {
                    return(VisitCompiledExpression(cp, node.Expression));
                }

                if (typeof(CompiledExpression).IsAssignableFrom(node.Member.DeclaringType))
                {
                    return(VisitCompiledExpression(cp, node.Expression));
                }

                return(base.VisitMember(node));
            }
コード例 #2
0
            /// <summary>
            ///  Walk up the inheritance heirarchy searching for a compiled expression attached to a
            ///  property of the given name
            /// </summary>
            /// <param name="memberName">Name of the property to search for</param>
            /// <param name="type">Type of the property to search against</param>
            /// <returns>Compiled expression if found or null if not</returns>
            private CompiledExpression FindCompiledExpressionMember(String memberName, Type type)
            {
                Boolean useOverride = true;

                while (type != typeof(Object) && type != null)
                {
                    MemberInfo[] mis = type.GetMember(memberName, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                    if (mis != null && mis.Length > 0)
                    {
                        EnsureTypeInitialized(type);
                        if (mis[0] != null && map.TryGetValue(mis[0], out CompiledExpression cp))
                        {
                            cp.UseOverride = useOverride;
                            return(cp);
                        }
                    }
                    type        = type.BaseType;
                    useOverride = false;
                }
                return(null);
            }
コード例 #3
0
            protected override Expression VisitMember(MemberExpression node)
            {
                if (node == null)
                {
                    throw new ArgumentNullException(nameof(node));
                }

                EnsureTypeInitialized(node.Member.DeclaringType);

                if (map.TryGetValue(node.Member, out CompiledExpression cp))
                {
                    return(VisitCompiledExpression(cp, node.Expression));
                }

                if (typeof(CompiledExpression).GetTypeInfo().IsAssignableFrom(node.Member.DeclaringType.GetTypeInfo()))
                {
                    return(VisitCompiledExpression(cp, node.Expression));
                }

                return(base.VisitMember(node));
            }