FromValueNoError() public static méthode

Crates a new ErrorInfo which represents a value which should be returned to the user but does not represent an error.
public static FromValueNoError ( Expression resultValue ) : ErrorInfo
resultValue System.Linq.Expressions.Expression
Résultat ErrorInfo
Exemple #1
0
        /// <summary>
        /// Called when a set is attempting to assign to a field or property from a derived class through the base class.
        ///
        /// The default behavior is to allow the assignment.
        /// </summary>
        public virtual ErrorInfo MakeStaticAssignFromDerivedTypeError(Type accessingType, DynamicMetaObject self, MemberTracker assigning, DynamicMetaObject assignedValue, OverloadResolverFactory context)
        {
            switch (assigning.MemberType)
            {
            case TrackerTypes.Property:
                PropertyTracker pt     = (PropertyTracker)assigning;
                MethodInfo      setter = pt.GetSetMethod() ?? pt.GetSetMethod(true);
                return(ErrorInfo.FromValueNoError(
                           AstUtils.SimpleCallHelper(
                               setter,
                               ConvertExpression(
                                   assignedValue.Expression,
                                   setter.GetParameters()[0].ParameterType,
                                   ConversionResultKind.ExplicitCast,
                                   context
                                   )
                               )
                           ));

            case TrackerTypes.Field:
                FieldTracker ft = (FieldTracker)assigning;
                return(ErrorInfo.FromValueNoError(
                           Expression.Assign(
                               Expression.Field(null, ft.Field),
                               ConvertExpression(assignedValue.Expression, ft.FieldType, ConversionResultKind.ExplicitCast, context)
                               )
                           ));

            default:
                throw new InvalidOperationException();
            }
        }
Exemple #2
0
        /// <summary>
        /// Called when the user is accessing a protected or private member on a get.
        ///
        /// The default implementation allows access to the fields or properties using reflection.
        /// </summary>
        public virtual ErrorInfo MakeNonPublicMemberGetError(OverloadResolverFactory resolverFactory, MemberTracker member, Type type, DynamicMetaObject instance)
        {
            switch (member.MemberType)
            {
            case TrackerTypes.Field:
                FieldTracker ft = (FieldTracker)member;

                return(ErrorInfo.FromValueNoError(
                           Ast.Call(
                               AstUtils.Convert(AstUtils.Constant(ft.Field), typeof(FieldInfo)),
                               typeof(FieldInfo).GetMethod("GetValue"),
                               AstUtils.Convert(instance.Expression, typeof(object))
                               )
                           ));

            case TrackerTypes.Property:
                PropertyTracker pt = (PropertyTracker)member;

                return(ErrorInfo.FromValueNoError(
                           MemberTracker.FromMemberInfo(pt.GetGetMethod(true)).Call(resolverFactory, this, instance).Expression
                           ));

            default:
                throw new InvalidOperationException();
            }
        }
Exemple #3
0
        public virtual ErrorInfo MakeEventValidation(MemberGroup members, DynamicMetaObject eventObject, DynamicMetaObject value, OverloadResolverFactory resolverFactory)
        {
            EventTracker ev = (EventTracker)members[0];

            // handles in place addition of events - this validates the user did the right thing.
            return(ErrorInfo.FromValueNoError(
                       Expression.Call(
                           typeof(BinderOps).GetMethod("SetEvent"),
                           AstUtils.Constant(ev),
                           value.Expression
                           )
                       ));
        }
Exemple #4
0
        public virtual ErrorInfo MakeEventValidation(MemberGroup members, Expression eventObject, Expression value, Expression codeContext)
        {
            EventTracker ev = (EventTracker)members[0];

            // handles in place addition of events - this validates the user did the right thing.
            return(ErrorInfo.FromValueNoError(
                       Expression.Call(
                           typeof(BinderOps).GetMethod("SetEvent"),
                           Expression.Constant(ev),
                           value
                           )
                       ));
        }
Exemple #5
0
        public virtual ErrorInfo MakeEventValidation(RuleBuilder rule, MemberGroup members)
        {
            EventTracker ev = (EventTracker)members[0];

            // handles in place addition of events - this validates the user did the right thing.
            return(ErrorInfo.FromValueNoError(
                       Expression.Call(
                           typeof(ScriptingRuntimeHelpers).GetMethod("SetEvent"),
                           Expression.Constant(ev),
                           rule.Parameters[1]
                           )
                       ));
        }