当前位置: 首页>>代码示例>>C#>>正文


C# Calls.OverloadResolverFactory类代码示例

本文整理汇总了C#中Microsoft.Scripting.Actions.Calls.OverloadResolverFactory的典型用法代码示例。如果您正苦于以下问题:C# OverloadResolverFactory类的具体用法?C# OverloadResolverFactory怎么用?C# OverloadResolverFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


OverloadResolverFactory类属于Microsoft.Scripting.Actions.Calls命名空间,在下文中一共展示了OverloadResolverFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoOperation

        public DynamicMetaObject DoOperation(string operation, OverloadResolverFactory resolverFactory, params DynamicMetaObject[] args) {
            ContractUtils.RequiresNotNull(operation, "operation");
            ContractUtils.RequiresNotNull(resolverFactory, "resolverFactory");
            ContractUtils.RequiresNotNullItems(args, "args");

            return MakeGeneralOperatorRule(operation, resolverFactory, args);   // Then try comparison / other ExpressionType
        }
开发者ID:apboyle,项目名称:ironruby,代码行数:7,代码来源:DefaultBinder.Operations.cs

示例2: ConvertExpression

        public override Ast ConvertExpression(Ast expr, Type toType, ConversionResultKind kind, OverloadResolverFactory resolverFactory)
        {
            Type exprType = expr.Type;
            Type visType = CompilerHelpers.GetVisibleType(toType);

            if (typeof(IFn).IsAssignableFrom(exprType) && typeof(Delegate).IsAssignableFrom(visType))
                return Ast.Call(typeof(Converter).GetMethod("ConvertToDelegate"), Ast.Convert(expr, typeof(IFn)), Expression.Constant(visType));

            // Follow through on our promise to convert IEnumerable<Object> or IEnumerable to IEnumerable<T> for any T
            if (toType.IsGenericType && ! toType.IsAssignableFrom(expr.Type))
            {
                // The following is inspired by IronPython.Runtime.Binding.Python.ConversionBinder.FallbackConvert
                Type genTo = toType.GetGenericTypeDefinition();
                if ( genTo == typeof(IList<>))
                {
                    return MakeToGenericConversion(expr,toType,typeof(IList<object>),typeof(ListGenericWrapper<>));
                }
                else if (genTo == typeof(IDictionary<,>))
                {
                    return MakeToGenericConversion(expr,toType,typeof(IDictionary<object,object>),typeof(DictionaryGenericWrapper<,>));
                }
                else if (genTo == typeof(IEnumerable<>))
                {   
                    return MakeToGenericConversion(expr, toType, typeof(IEnumerable),typeof(IEnumerableOfTWrapper<>));
                }
            }

            return base.ConvertExpression(expr, toType, kind, resolverFactory);
        }
开发者ID:TerabyteX,项目名称:clojure-clr,代码行数:29,代码来源:ClojureBinder.cs

示例3: SetBoundValue

 protected override DynamicMetaObject SetBoundValue(OverloadResolverFactory factory, ActionBinder binder, Type type, DynamicMetaObject value, DynamicMetaObject instance, DynamicMetaObject errorSuggestion) {
     return new DynamicMetaObject(
         Expression.Condition(
             Ast.Call(
                 typeof(PythonOps).GetMethod("SlotTrySetValue"),
                 ((PythonOverloadResolverFactory)factory)._codeContext,
                 AstUtils.Constant(GetSlot(), typeof(PythonTypeSlot)),
                 AstUtils.Convert(
                     instance.Expression,
                     typeof(object)
                 ),
                 AstUtils.Constant(DynamicHelpers.GetPythonTypeFromType(type)),
                 value.Expression
             ),
             AstUtils.Convert(value.Expression, typeof(object)),
             errorSuggestion != null ?
                 errorSuggestion.Expression :
                 Expression.Throw(
                     Expression.Call(
                         typeof(PythonOps).GetMethod("AttributeErrorForMissingAttribute", new Type[] { typeof(object), typeof(string) }),
                         instance.Expression,
                         Expression.Constant(Name)
                     ),
                     typeof(object)
                 )
         ),
         BindingRestrictions.Empty
     );
 }
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:29,代码来源:CustomAttributeTracker.cs

示例4: SetIndex

        /// <summary>
        /// Creates the MetaObject for indexing directly into arrays or indexing into objects which have
        /// default members.  Returns null if we're not an indexing operation.
        /// </summary>
        public DynamicMetaObject SetIndex(OverloadResolverFactory resolverFactory, DynamicMetaObject[] args) {
            if (args[0].LimitType.IsArray) {
                return MakeArrayIndexRule(resolverFactory, IndexType.Set, args);
            }

            return MakeMethodIndexRule(IndexType.Set, resolverFactory, args);
        }
开发者ID:apboyle,项目名称:ironruby,代码行数:11,代码来源:DefaultBinder.Operations.cs

示例5: ConvertExpression

        public override Expression ConvertExpression(Expression expr, Type toType, ConversionResultKind kind, OverloadResolverFactory resolverFactory)
        {
            ContractUtils.RequiresNotNull(expr, "expr");
            ContractUtils.RequiresNotNull(toType, "toType");

            Type exprType = expr.Type;

            if (toType == typeof(object))
            {
                if (exprType.IsValueType())
                    return Utils.Convert(expr, toType);
                else
                    return expr;
            }

            if (toType.IsAssignableFrom(exprType))
                return expr;

            Type visType = Context.Binder.PrivateBinding ? toType : CompilerHelpers.GetVisibleType(toType);

            return Binders.Convert(
                _context,
                visType,
                kind,
                expr
            );
        }
开发者ID:Alxandr,项目名称:IronTotem-3.0,代码行数:27,代码来源:TotemBinder.cs

示例6: Call

        /// <summary>
        /// Provides default binding for performing a call on the specified meta objects.
        /// </summary>
        /// <param name="signature">The signature describing the call</param>
        /// <param name="target">The meta object to be called.</param>
        /// <param name="args">
        /// Additional meta objects are the parameters for the call as specified by the CallSignature in the CallAction.
        /// </param>
        /// <param name="resolverFactory">Overload resolver factory.</param>
        /// <param name="errorSuggestion">The result should the object be uncallable.</param>
        /// <returns>A MetaObject representing the call or the error.</returns>
        public DynamicMetaObject Call(CallSignature signature, DynamicMetaObject errorSuggestion, OverloadResolverFactory resolverFactory,ClrMethod method, DynamicMetaObject target, params DynamicMetaObject[] args)
        {
            ContractUtils.RequiresNotNullItems(args, "args");
            ContractUtils.RequiresNotNull(resolverFactory, "resolverFactory");

            TargetInfo targetInfo = GetTargetInfo(method, target, args);

            if (targetInfo != null)
            {
                // we're calling a well-known MethodBase
                DynamicMetaObject res = MakeMetaMethodCall(signature, resolverFactory, targetInfo);
                if (res.Expression.Type.IsValueType)
                {
                    if (res.Expression.Type == Types.Void)
                        res = new DynamicMetaObject(
                            Expression.Block(Types.Object[0],
                                res.Expression,
                                Expression.Constant(null)),
                            res.Restrictions
                        );
                    else
                        res = new DynamicMetaObject(
                            Expression.Convert(res.Expression, typeof(object)),
                            res.Restrictions
                    );
                }

                return res;
            }
            else
            {
                // we can't call this object
                return errorSuggestion ?? MakeCannotCallRule(target, target.GetLimitType());
            }
        }
开发者ID:dw4dev,项目名称:Phalanger,代码行数:46,代码来源:PhpBinder.cs

示例7: ConvertTo

        public DynamicMetaObject ConvertTo(Type toType, ConversionResultKind kind, DynamicMetaObject arg, OverloadResolverFactory resolverFactory, DynamicMetaObject errorSuggestion) {
            ContractUtils.RequiresNotNull(toType, "toType");
            ContractUtils.RequiresNotNull(arg, "arg");

            Type knownType = arg.GetLimitType();

            // try all the conversions - first look for conversions against the expression type,
            // these can be done w/o any additional tests.  Then look for conversions against the 
            // restricted type.
            BindingRestrictions typeRestrictions = arg.Restrictions.Merge(BindingRestrictionsHelpers.GetRuntimeTypeRestriction(arg.Expression, arg.GetLimitType()));

            DynamicMetaObject res = 
                TryConvertToObject(toType, arg.Expression.Type, arg, typeRestrictions) ??
                TryAllConversions(resolverFactory, toType, kind, arg.Expression.Type, typeRestrictions, arg) ??
                TryAllConversions(resolverFactory, toType, kind, arg.GetLimitType(), typeRestrictions, arg) ??
                errorSuggestion ??
                MakeErrorTarget(toType, kind, typeRestrictions, arg);

            if ((kind == ConversionResultKind.ExplicitTry || kind == ConversionResultKind.ImplicitTry) && toType.IsValueType) {
                res = new DynamicMetaObject(
                    AstUtils.Convert(
                        res.Expression,
                        typeof(object)
                    ),
                    res.Restrictions
                );
            }
            return res;
        }
开发者ID:BenHall,项目名称:ironruby,代码行数:29,代码来源:DefaultBinder.Conversions.cs

示例8: TryAllConversions

 /// <summary>
 /// Checks if any conversions are available and if so builds the target for that conversion.
 /// </summary>
 private DynamicMetaObject TryAllConversions(OverloadResolverFactory factory, Type toType, ConversionResultKind kind, Type knownType, BindingRestrictions restrictions, DynamicMetaObject arg) {
     return
         TryAssignableConversion(toType, knownType, restrictions, arg) ??                // known type -> known type
         TryExtensibleConversion(toType, knownType, restrictions, arg) ??                // Extensible<T> -> Extensible<T>.Value
         TryUserDefinedConversion(kind, toType, knownType, restrictions, arg) ??         // op_Implicit
         TryImplicitNumericConversion(toType, knownType, restrictions, arg) ??           // op_Implicit
         TryNullableConversion(factory, toType, kind, knownType, restrictions, arg) ??   // null -> Nullable<T> or T -> Nullable<T>
         TryNullConversion(toType, knownType, restrictions);                             // null -> reference type
 }
开发者ID:aceptra,项目名称:ironruby,代码行数:12,代码来源:DefaultBinder.Conversions.cs

示例9: GetMember

 /// <summary>
 /// Builds a MetaObject for performing a member get.  Supports all built-in .NET members, the OperatorMethod 
 /// GetBoundMember, and StrongBox instances.
 /// </summary>
 /// <param name="name">
 /// The name of the member to retrieve.  This name is not processed by the DefaultBinder and
 /// is instead handed off to the GetMember API which can do name mangling, case insensitive lookups, etc...
 /// </param>
 /// <param name="target">
 /// The MetaObject from which the member is retrieved.
 /// </param>
 /// <param name="resolverFactory">
 /// Provides overload resolution and method binding for any calls which need to be performed for the GetMember.
 /// </param>
 /// <returns>
 /// Returns a DynamicMetaObject which represents the value that will be returned when the member is accessed.
 /// 
 /// The returned DynamicMetaObject may be strongly typed to a value type which needs boxing before being
 /// returned from a standard DLR GetMemberBinder.  The language is responsible for performing any boxing
 /// so that it has an opportunity to perform custom boxing.
 /// </returns>
 public DynamicMetaObject GetMember(string name, DynamicMetaObject target, OverloadResolverFactory resolverFactory) {
     return GetMember(
         name,
         target,
         resolverFactory,
         false,
         null
     );
 }
开发者ID:jschementi,项目名称:iron,代码行数:30,代码来源:DefaultBinder.GetMember.cs

示例10: ConvertExpression

        public override Ast ConvertExpression(Ast expr, Type toType, ConversionResultKind kind, OverloadResolverFactory resolverFactory)
        {
            Type exprType = expr.Type;
            Type visType = CompilerHelpers.GetVisibleType(toType);

            if (typeof(IFn).IsAssignableFrom(exprType) && typeof(Delegate).IsAssignableFrom(visType))
                return Ast.Call(typeof(Converter).GetMethod("ConvertToDelegate"), Ast.Convert(expr, typeof(IFn)), Expression.Constant(visType));

            return base.ConvertExpression(expr, toType, kind, resolverFactory);
        }
开发者ID:richhickey,项目名称:clojure-clr,代码行数:10,代码来源:ClojureBinder.cs

示例11: SetMember

        /// <summary>
        /// Builds a MetaObject for performing a member get.  Supports all built-in .NET members, the OperatorMethod 
        /// GetBoundMember, and StrongBox instances.
        /// </summary>
        /// <param name="name">
        /// The name of the member to retrieve.  This name is not processed by the DefaultBinder and
        /// is instead handed off to the GetMember API which can do name mangling, case insensitive lookups, etc...
        /// </param>
        /// <param name="target">
        /// The MetaObject from which the member is retrieved.
        /// </param>
        /// <param name="value">
        /// The value being assigned to the target member.
        /// </param>
        /// <param name="resolverFactory">
        /// rovides overload resolution and method binding for any calls which need to be performed for the SetMember.
        /// </param>
        public DynamicMetaObject SetMember(string name, DynamicMetaObject target, DynamicMetaObject value, OverloadResolverFactory resolverFactory) {
            ContractUtils.RequiresNotNull(name, "name");
            ContractUtils.RequiresNotNull(target, "target");
            ContractUtils.RequiresNotNull(value, "value");
            ContractUtils.RequiresNotNull(resolverFactory, "resolverFactory");

            return MakeSetMemberTarget(
                new SetOrDeleteMemberInfo(name, resolverFactory),
                target,
                value
            );
        }
开发者ID:aceptra,项目名称:ironruby,代码行数:29,代码来源:DefaultBinder.SetMember.cs

示例12: DeleteMember

        public DynamicMetaObject DeleteMember(string name, DynamicMetaObject target, OverloadResolverFactory resolutionFactory) {
            ContractUtils.RequiresNotNull(name, "name");
            ContractUtils.RequiresNotNull(target, "target");

            return MakeDeleteMemberTarget(
                new SetOrDeleteMemberInfo(
                    name,
                    resolutionFactory
                ),
                target.Restrict(target.GetLimitType())
            );
        }
开发者ID:apboyle,项目名称:ironruby,代码行数:12,代码来源:DefaultBinder.DeleteMember.cs

示例13: Call

        /// <summary>
        /// Provides default binding for performing a call on the specified meta objects.
        /// </summary>
        /// <param name="signature">The signature describing the call</param>
        /// <param name="target">The meta object to be called.</param>
        /// <param name="args">
        /// Additional meta objects are the parameters for the call as specified by the CallSignature in the CallAction.
        /// </param>
        /// <param name="resolverFactory">Overload resolver factory.</param>
        /// <returns>A MetaObject representing the call or the error.</returns>
        public DynamicMetaObject Call(CallSignature signature, OverloadResolverFactory resolverFactory, DynamicMetaObject target, params DynamicMetaObject[] args) {
            ContractUtils.RequiresNotNullItems(args, "args");
            ContractUtils.RequiresNotNull(resolverFactory, "resolverFactory");

            TargetInfo targetInfo = GetTargetInfo(signature, target, args);

            if (targetInfo != null) {
                // we're calling a well-known MethodBase
                return MakeMetaMethodCall(signature, resolverFactory, targetInfo);
            } else {
                // we can't call this object
                return MakeCannotCallRule(target, target.GetLimitType());
            }
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:24,代码来源:DefaultBinder.Invoke.cs

示例14: GetBoundValue

 protected override DynamicMetaObject GetBoundValue(OverloadResolverFactory factory, ActionBinder binder, Type type, DynamicMetaObject instance) {
     return new DynamicMetaObject(
         Ast.Call(
             typeof(PythonOps).GetMethod("SlotGetValue"),
             ((PythonOverloadResolverFactory)factory)._codeContext,
             AstUtils.Constant(GetSlot(), typeof(PythonTypeSlot)),
             AstUtils.Convert(
                 instance.Expression,
                 typeof(object)
             ),
             AstUtils.Constant(DynamicHelpers.GetPythonTypeFromType(type))
         ),
         BindingRestrictions.Empty
     );
 }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:15,代码来源:CustomAttributeTracker.cs

示例15: GetMember

        /// <summary>
        /// Builds a MetaObject for performing a member get.  Supports all built-in .NET members, the OperatorMethod 
        /// GetBoundMember, and StrongBox instances.
        /// </summary>
        /// <param name="name">
        /// The name of the member to retrieve.  This name is not processed by the DefaultBinder and
        /// is instead handed off to the GetMember API which can do name mangling, case insensitive lookups, etc...
        /// </param>
        /// <param name="target">
        /// The MetaObject from which the member is retrieved.
        /// </param>
        /// <param name="resolverFactory">
        /// An OverloadResolverFactory which can be used for performing overload resolution and method binding.
        /// </param>
        /// <param name="isNoThrow">
        /// True if the operation should return Operation.Failed on failure, false if it
        /// should return the exception produced by MakeMissingMemberError.
        /// </param>
        /// <param name="errorSuggestion">
        /// The meta object to be used if the get results in an error.
        /// </param>
        public DynamicMetaObject GetMember(string name, DynamicMetaObject target, OverloadResolverFactory resolverFactory, bool isNoThrow, DynamicMetaObject errorSuggestion) {
            ContractUtils.RequiresNotNull(name, "name");
            ContractUtils.RequiresNotNull(target, "target");
            ContractUtils.RequiresNotNull(resolverFactory, "resolverFactory");

            return MakeGetMemberTarget(
                new GetMemberInfo(
                    name,
                    resolverFactory,
                    isNoThrow,
                    errorSuggestion
                ),
                target
            );
        }
开发者ID:aceptra,项目名称:ironruby,代码行数:36,代码来源:DefaultBinder.GetMember.cs


注:本文中的Microsoft.Scripting.Actions.Calls.OverloadResolverFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。