コード例 #1
0
ファイル: InlineVisitor.cs プロジェクト: fafnir901/fwd
        protected override Expression VisitMethodCall(MethodCallExpression target)
        {
            InlineableAttribute customAttribute = target.Method.GetCustomAttribute <InlineableAttribute>();
            Expression          result;

            if (customAttribute.ToMaybe <InlineableAttribute>().HasValue)
            {
                result = this.Visit(this.InlineExpression(target.Object, target.Method, customAttribute, target.Arguments));
            }
            else
            {
                result = base.VisitMethodCall(target);
            }
            return(result);
        }
コード例 #2
0
ファイル: InlineVisitor.cs プロジェクト: fafnir901/fwd
        protected override Expression VisitMember(MemberExpression node)
        {
            Expression result;

            if (node.Member.MemberType == MemberTypes.Property)
            {
                PropertyInfo        propertyInfo    = (PropertyInfo)node.Member;
                InlineableAttribute customAttribute = propertyInfo.GetCustomAttribute <InlineableAttribute>();
                if (customAttribute.ToMaybe <InlineableAttribute>().HasValue)
                {
                    MethodInfo getMethod = propertyInfo.GetGetMethod();
                    if (getMethod.IsAbstract)
                    {
                        PropertyInfo property = node.Expression.Type.GetProperty(node.Member.Name);
                        getMethod = property.GetGetMethod();
                    }
                    ReadOnlyCollection <Expression> targetArguments = new List <Expression>().AsReadOnly();
                    result = this.Visit(this.InlineExpression(node.Expression, getMethod, customAttribute, targetArguments));
                    return(result);
                }
            }
            result = base.VisitMember(node);
            return(result);
        }