IronRuby.Runtime.Calls.MetaObjectBuilder.AddTypeRestriction C# (CSharp) Method

AddTypeRestriction() public method

public AddTypeRestriction ( Type type, Expression expression ) : void
type System.Type
expression Expression
return void
        public void AddTypeRestriction(Type/*!*/ type, Expression/*!*/ expression) {
            if (_treatRestrictionsAsConditions) {
                AddCondition(Ast.TypeEqual(expression, type));
            } else if (expression.Type != type || !type.IsSealed) {
                Add(BindingRestrictions.GetTypeRestriction(expression, type));
            }
        }

Usage Example

Example #1
0
            public override DynamicMetaObject /*!*/ FallbackInvoke(DynamicMetaObject /*!*/ target, DynamicMetaObject /*!*/[] /*!*/ args,
                                                                   DynamicMetaObject errorSuggestion)
            {
                // Used in combination with GetMember to compose InvokeMember operation.
                // Gets here only if the target is not a callable meta-object.

                var metaBuilder = new MetaObjectBuilder(this, target, args);
                var callArgs    = new CallArguments(_context, target, args, CallInfo);

                metaBuilder.AddTypeRestriction(target.GetLimitType(), target.Expression);

                RubyOverloadResolver.NormalizeArguments(metaBuilder, callArgs, 0, 0);
                if (!metaBuilder.Error)
                {
                    // no arguments => just return the target:
                    metaBuilder.Result = target.Expression;
                }
                else
                {
                    // any arguments found (expected none):
                    metaBuilder.SetMetaResult(errorSuggestion, false);
                }

                return(metaBuilder.CreateMetaObject(this));
            }
All Usage Examples Of IronRuby.Runtime.Calls.MetaObjectBuilder::AddTypeRestriction