コード例 #1
0
 public override DynamicMetaObject FallbackSetIndex(DynamicMetaObject target, DynamicMetaObject[] indexes, DynamicMetaObject value, DynamicMetaObject errorSuggestion)
 {
     try
     {
         return(new DynamicMetaObject(
                    YacqExpression.Function(this._symbols, "=",
                                            YacqExpression.Function(this._symbols, ".",
                                                                    target.Expression.Reduce(this._symbols).TryConvert(target.RuntimeType),
                                                                    YacqExpression.Vector(this._symbols,
                                                                                          indexes.SelectAll(o => o.Expression.Reduce(this._symbols).TryConvert(target.RuntimeType))
                                                                                          )
                                                                    ),
                                            value.Expression.Reduce(this._symbols).TryConvert(target.RuntimeType)
                                            ).Reduce(this._symbols).TryConvert(typeof(Object)),
                    target.Restrictions
                    ));
     }
     catch (Exception ex)
     {
         return(errorSuggestion
                ?? new DynamicMetaObject(
                    Expression.Throw(Expression.Constant(ex), typeof(Object)),
                    BindingRestrictions.Empty
                    ));
     }
 }
コード例 #2
0
 public override DynamicMetaObject FallbackUnaryOperation(DynamicMetaObject target, DynamicMetaObject errorSuggestion)
 {
     try
     {
         return(new DynamicMetaObject(
                    YacqExpression.Function(this._symbols, GetSymbolName(this.Operation),
                                            target.Expression.Reduce(_symbols).TryConvert(target.RuntimeType)
                                            ).Reduce(this._symbols).TryConvert(typeof(Object)),
                    target.Restrictions
                    ));
     }
     catch (Exception ex)
     {
         return(errorSuggestion
                ?? new DynamicMetaObject(
                    Expression.Throw(Expression.Constant(ex), typeof(Object)),
                    BindingRestrictions.Empty
                    ));
     }
 }
コード例 #3
0
 public static Expression Tab(DispatchExpression e, SymbolTable s, Type t)
 {
     return(YacqExpression.TypeCandidate(typeof(Setting))
            .Member(s, "Instance")
            .Member(s, "StateProperty")
            .Member(s, "TabInformations")
            .Method(s, "SelectMany",
                    YacqExpression.Function(s, "\\",
                                            YacqExpression.Vector(s, YacqExpression.Identifier(s, "e")),
                                            YacqExpression.Identifier(s, "e")
                                            )
                    )
            .Method(s, "First",
                    YacqExpression.LambdaList(s,
                                              YacqExpression.Identifier(s, "=="),
                                              YacqExpression.Identifier(s, "$0").Member(s, "Name"),
                                              e.Arguments[0]
                                              )
                    )
            .Member(s, "TweetSources")
            .Method(s, "Single"));
 }
コード例 #4
0
 public override DynamicMetaObject FallbackSetMember(DynamicMetaObject target, DynamicMetaObject value, DynamicMetaObject errorSuggestion)
 {
     try
     {
         return(new DynamicMetaObject(
                    YacqExpression.Function(this._symbols, "=",
                                            (Static.GetTargetType(target.Value)
                                             .Null(t => YacqExpression.TypeCandidate(this._symbols, t))
                                             ?? target.Expression.Reduce(this._symbols).TryConvert(target.RuntimeType)
                                            ).Member(this._symbols, this.Name),
                                            value.Expression.Reduce(this._symbols).TryConvert(target.RuntimeType)
                                            ).Reduce(this._symbols).TryConvert(typeof(Object)),
                    target.Restrictions
                    ));
     }
     catch (Exception ex)
     {
         return(errorSuggestion
                ?? new DynamicMetaObject(
                    Expression.Throw(Expression.Constant(ex), typeof(Object)),
                    BindingRestrictions.Empty
                    ));
     }
 }