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


C# SimpleQuery.TryInvokeMember方法代码示例

本文整理汇总了C#中SimpleQuery.TryInvokeMember方法的典型用法代码示例。如果您正苦于以下问题:C# SimpleQuery.TryInvokeMember方法的具体用法?C# SimpleQuery.TryInvokeMember怎么用?C# SimpleQuery.TryInvokeMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleQuery的用法示例。


在下文中一共展示了SimpleQuery.TryInvokeMember方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TryInvokeMember

        /// <summary>
        /// Provides the implementation for operations that invoke a member. Classes derived from the <see cref="T:System.Dynamic.DynamicObject"/> class can override this method to specify dynamic behavior for operations such as calling a method.
        /// </summary>
        /// <param name="binder">Provides information about the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the statement sampleObject.SampleMethod(100), where sampleObject is an instance of the class derived from the <see cref="T:System.Dynamic.DynamicObject"/> class, binder.Name returns "SampleMethod". The binder.IgnoreCase property specifies whether the member name is case-sensitive.</param>
        /// <param name="args">The arguments that are passed to the object member during the invoke operation. For example, for the statement sampleObject.SampleMethod(100), where sampleObject is derived from the <see cref="T:System.Dynamic.DynamicObject"/> class, <paramref name="args[0]"/> is equal to 100.</param>
        /// <param name="result">The result of the member invocation.</param>
        /// <returns>
        /// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.)
        /// </returns>
        public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
        {
            var signature = FunctionSignature.FromBinder(binder, args);
            Func<object[], object> func;
            if (_delegatesAsCollection.IsSynchronized && _delegates.ContainsKey(signature))
            {
                func = _delegates[signature];
            }
            else
            {
                lock (_delegatesAsCollection.SyncRoot)
                {
                    if (!_delegates.ContainsKey(signature))
                    {
                        func = CreateMemberDelegate(signature, binder, args);
                        _delegates.Add(signature, func);
                    }
                    else
                    {
                        func = _delegates[signature];
                    }
                }
            }
            if (func != null)
            {
                result = func(args);
                return true;
            }

            var command = CommandFactory.GetCommandFor(binder.Name);
            if (command != null)
            {
                result = command.Execute(_dataStrategy, this, binder, args);
                return true;
            }

            var query = new SimpleQuery(_dataStrategy, _tableName);
            if (query.TryInvokeMember(binder, args, out result))
            {
                return true;
            }

            return base.TryInvokeMember(binder, args, out result);
        }
开发者ID:remcok,项目名称:Simple.Data,代码行数:53,代码来源:DynamicTable.cs


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