IronRuby.Runtime.Calls.MetaObjectBuilder.AddObjectTypeRestriction C# (CSharp) Méthode

AddObjectTypeRestriction() public méthode

public AddObjectTypeRestriction ( object value, Expression expression ) : void
value object
expression Expression
Résultat void
        public void AddObjectTypeRestriction(object value, Expression/*!*/ expression) {
            if (value == null) {
                AddRestriction(Ast.Equal(expression, AstUtils.Constant(null)));
            } else {
                AddTypeRestriction(value.GetType(), expression);
            }
        }

Usage Example

        protected override bool Build(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, bool defaultFallback) {
            if (TryImplicitConversion(metaBuilder, args)) {
                metaBuilder.AddObjectTypeRestriction(args.Target, args.TargetExpression);
                return true;
            }

            // TODO: this is our meta object, should we add IRubyMetaConvertible interface instead of using interop-binder?
            if (args.Target is IDynamicMetaObjectProvider) {
                metaBuilder.SetMetaResult(args.MetaTarget.BindConvert(new InteropBinder.Convert(args.RubyContext, _type, true)), false);
                return true;
            }

            if (defaultFallback) {
                metaBuilder.AddObjectTypeRestriction(args.Target, args.TargetExpression);

                metaBuilder.SetError(Methods.MakeTypeConversionError.OpCall(
                    args.MetaContext.Expression,
                    AstUtils.Convert(args.TargetExpression, typeof(object)),
                    Ast.Constant(_type)
                ));
                return true;
            }

            return false;
        }
All Usage Examples Of IronRuby.Runtime.Calls.MetaObjectBuilder::AddObjectTypeRestriction