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


C# Dynamic.InvokeMemberBinder类代码示例

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


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

示例1: CreateDelegate

        public Func<object[], object> CreateDelegate(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
        {
            if (dataStrategy is SimpleTransaction) return null;

            if (binder.Name.Equals("FindBy") || binder.Name.Equals("find_by"))
            {
                ArgumentHelper.CheckFindArgs(args, binder);
                if (args.Length == 1 && args[0].IsAnonymous()) return null;
            }

            var criteriaDictionary = ArgumentHelper.CreateCriteriaDictionary(binder, args, "FindBy", "find_by");
            if (criteriaDictionary == null) return null;

            var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), criteriaDictionary);
            try
            {
                var adapter = dataStrategy.GetAdapter();
                var func = adapter.OptimizingDelegateFactory.CreateFindOneDelegate(adapter, table.GetQualifiedName(), criteriaExpression);
                return a =>
                           {
                               var data = func(a);
                               return (data != null && data.Count > 0)
                                          ? new SimpleRecord(data, table.GetQualifiedName(), dataStrategy)
                                          : null;
                           };
            }
            catch (NotImplementedException)
            {
                return null;
            }
        }
开发者ID:JorgeGamba,项目名称:Simple.Data,代码行数:31,代码来源:FindByCommand.cs

示例2: CreateCriteriaDictionary

        internal static IEnumerable<KeyValuePair<string, object>> CreateCriteriaDictionary(InvokeMemberBinder binder, IList<object> args, params string[] exactNames)
        {
            IDictionary<string, object> criteriaDictionary = null;
            if (exactNames.Contains(binder.Name))
            {
                if (binder.CallInfo.ArgumentNames != null && binder.CallInfo.ArgumentNames.Count > 0)
                {
                    criteriaDictionary = binder.NamedArgumentsToDictionary(args);
                }
                else if (args.Count == 1)
                {
                    if (ReferenceEquals(args[0], null)) throw new ArgumentException("FindBy does not accept unnamed null argument.");
                    criteriaDictionary = args[0].ObjectToDictionary();
                }
            }
            else
            {
                criteriaDictionary = MethodNameParser.ParseFromBinder(binder, args);
            }

            if (criteriaDictionary == null || criteriaDictionary.Count == 0)
            {
                throw new ArgumentException(binder.Name + " requires an equal number of column names and values to filter data by.");
            }
            return criteriaDictionary;
        }
开发者ID:JorgeGamba,项目名称:Simple.Data,代码行数:26,代码来源:ArgumentHelper.cs

示例3: TryInvokeMember

        public bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
        {
            var adapterMethods = _adapter.GetType().GetMethods().Where(m => m.Name == binder.Name).ToList();

            foreach (var method in adapterMethods)
            {
                var parameters = method.GetParameters().ToArray();
                if (parameters.Any(p => p.RawDefaultValue != DBNull.Value) && binder.CallInfo.ArgumentNames.Any(s => !string.IsNullOrWhiteSpace(s)))
                {
                    if (TryInvokeMemberWithNamedParameters(binder, args, out result, method, parameters))
                    {
                        return true;
                    }
                }
                else
                {
                    if (AreCompatible(parameters, args))
                    {
                        result = method.Invoke(_adapter, args);
                        return true;
                    }
                }
            }

            result = null;
            return false;
        }
开发者ID:JorgeGamba,项目名称:Simple.Data,代码行数:27,代码来源:AdapterMethodDynamicInvoker.cs

示例4: TryInvokeMember

 public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
 {
     var msg = new Message(binder, args);
     Apply(msg);
     result = null;
     return true;
 }
开发者ID:ToJans,项目名称:CQRS-101-code,代码行数:7,代码来源:MiniVan.cs

示例5: TryInvokeMember

        /// <summary>
        /// This builds a query with the passed in named arguments - shopify.Products(collection_id:121212)
        /// </summary>
        public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
        {
            var name = binder.Name.ToLower() + ".json";
            var url = _baseUrl + name;

            //params?
            var info = binder.CallInfo;
            var looper = 0;
            if (info.ArgumentNames.Count > 0) {

                for (int i = 0; i < args.Length; i++) {
                    var argName = info.ArgumentNames[i].ToLower();
                    var val = args[i];
                    //the ID is a singular call
                    //with a special format
                    if (argName == "id") {
                        url = url.Replace(".json", "/" + val + ".json");
                    } else {
                        if (looper == 0)
                            url += "?";
                        else
                            url += "&";
                        url += string.Format("{0}={1}", argName, val);
                    }
                    looper++;
                }
            }
            var json = Send(url);
            result = JsonHelper.Decode(json);
            return true;
        }
开发者ID:kingdango,项目名称:ShopifyApi,代码行数:34,代码来源:Api.cs

示例6: TryInvokeMember

        public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
        {
            var name = binder.Name;
            result = GetUrl(name, args);

            return true;
        }
开发者ID:harshb,项目名称:snippets,代码行数:7,代码来源:RouteHelper.cs

示例7: TryInvokeMember

        public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
        {
            var functionName = binder.Name;

            try
            {
                // convert arguments to Parameter
                var parameters = new Parameter[args.Length];

                for (int i = 0; i < args.Length; i++)
                {
                    parameters[i] = new Parameter(args[i]);
                }

                Function.SetEntRef(_entRef);
                result = Function.Call(functionName, typeof(object), parameters);

                return true;
            }
            catch (Exception ex)
            {
                Log.Error(ex);

                result = null;

                return false;
            }
        }
开发者ID:cubedj,项目名称:fourdeltaone,代码行数:28,代码来源:ScriptDynamics.cs

示例8: TryInvokeMember

 public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
 {
     if(Members.Contains(binder.Name))
         return base.TryInvokeMember(binder, args, out result);
     result = Evaluate(ConstructInvokeStatement(binder, args));
     return true;
 }
开发者ID:danderson00,项目名称:Noesis.Javascript.Extensions,代码行数:7,代码来源:JContext.cs

示例9: Execute

 public object Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
 {
     var criteria = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), MethodNameParser.ParseFromBinder(binder, args));
     return new SimpleQuery(dataStrategy.Adapter, table.GetQualifiedName()).Where(criteria);
     //var data = dataStrategy.Find(table.GetQualifiedName(), criteria);
     //return CreateSimpleResultSet(table, dataStrategy, data);
 }
开发者ID:osaylan1,项目名称:Simple.Data,代码行数:7,代码来源:FindAllByCommand.cs

示例10: CreateDelegate

        public Func<object[], object> CreateDelegate(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
        {
            if (dataStrategy is SimpleTransaction) return null;

            var criteriaDictionary = CreateCriteriaDictionary(binder, args);
            if (criteriaDictionary == null) return null;

            var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), criteriaDictionary);
            try
            {
                var adapter = dataStrategy.GetAdapter();
                var func = adapter.OptimizingDelegateFactory.CreateFindOneDelegate(adapter, table.GetQualifiedName(), criteriaExpression);
                return a =>
                           {
                               var data = func(a);
                               return (data != null && data.Count > 0)
                                          ? new SimpleRecord(data, table.GetQualifiedName(), dataStrategy)
                                          : null;
                           };
            }
            catch (NotImplementedException)
            {
                return null;
            }
        }
开发者ID:hlach,项目名称:Simple.Data,代码行数:25,代码来源:FindByCommand.cs

示例11: TryInvokeMember

 // i.e. Error("I had an error.")
 // i.e. Error(exception)
 // i.e. Error("You can't do that.", exception)
 public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
 {
     result = null;
     Log log;
     if (_logs.TryGetValue(binder.Name, out log)) {
         try {
             if (args.Length == 1) {
                 if (args[0] is string) {
                     log.Write(args[0] as string);
                     return true;
                 }
                 else if (args[0] is Exception) {
                     log.Write(args[0] as Exception);
                     return true;
                 }
             }
             else if (args.Length == 2) {
                 if (args[0] is string && args[1] is Exception) {
                     log.Write(args[0] as string, args[1] as Exception);
                     return true;
                 }
             }
             return false;
         }
         catch {
             return false;
         }
     }
     return base.TryInvokeMember(binder, args, out result);
 }
开发者ID:stewmc,项目名称:vixen,代码行数:33,代码来源:Logging.cs

示例12: CreateDelegate

        public Func<object[], object> CreateDelegate(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, object[] args)
        {
            if (dataStrategy is SimpleTransaction) return null;

            if (binder.Name.Equals("FindBy") || binder.Name.Equals("find_by"))
            {
                if (args.Length == 0) throw new ArgumentException("FindBy requires arguments.");
                if (args.Length == 1)
                {
                    if (ReferenceEquals(args[0], null)) throw new ArgumentException("FindBy does not accept unnamed null argument.");
                    if (args[0].GetType().Namespace == null) return null;
                }
            }

            var criteriaDictionary = CreateCriteriaDictionary(binder, args);
            if (criteriaDictionary == null) return null;

            var criteriaExpression = ExpressionHelper.CriteriaDictionaryToExpression(table.GetQualifiedName(), criteriaDictionary);
            try
            {
                var adapter = dataStrategy.GetAdapter();
                var func = adapter.OptimizingDelegateFactory.CreateFindOneDelegate(adapter, table.GetQualifiedName(), criteriaExpression);
                return a =>
                           {
                               var data = func(a);
                               return (data != null && data.Count > 0)
                                          ? new SimpleRecord(data, table.GetQualifiedName(), dataStrategy)
                                          : null;
                           };
            }
            catch (NotImplementedException)
            {
                return null;
            }
        }
开发者ID:kotsaris,项目名称:Simple.Data,代码行数:35,代码来源:FindByCommand.cs

示例13: TryInvokeMember

 public override bool TryInvokeMember(
     InvokeMemberBinder binder, object[] args, out object result)
 {
     if (cities.FindCity(binder.Name) != null) result = cities.FindCity(binder.Name);
     else result = "The city <" + binder.Name + "> does not exist!";
     return true;
 }
开发者ID:platzhersh,项目名称:FHNW-Java-Projekte,代码行数:7,代码来源:World.cs

示例14: TryInvokeMember

        public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
        {
            string routename = binder.Name;

            var stems = routename.Split('_');

            if (stems.Last() == "h")
            {
                routename = routename.Remove(binder.Name.Length - 2);

                result = GetAnchorTag("http", routename, args);
            }
            else if (stems.Last() == "s")
            {
                routename = routename.Remove(binder.Name.Length - 2);

                result = GetAnchorTag("https", routename, args);
            }
            else
            {
                result = GetAnchorTag(routename, args);
            }

            return true;
        }
开发者ID:aregsar,项目名称:rapido,代码行数:25,代码来源:DynamicImageLinkTo.cs

示例15: TryInvokeMember

 public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
 {
     SpeechSynthesizer ss = new SpeechSynthesizer();
     ss.Speak(binder.Name);
     result = true;
     return true;
 }
开发者ID:Laubeee,项目名称:ecnf,代码行数:7,代码来源:Speech.cs


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