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


C# Dynamic.GetIndexBinder类代码示例

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


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

示例1: TryGetIndex

        public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
        {
            if (indexes.Count() != 1)
            {
                return base.TryGetIndex(binder, indexes, out result);
            }

            var index = indexes.Single();

            if (_props.Contains(index))
            {
                result = _props[index];
                return true;
            }

            // try to access an existing member
            var strinIndex = index as string;

            if (strinIndex != null && TryGetMemberImpl(strinIndex, out result))
            {
                return true;
            }

            return base.TryGetIndex(binder, indexes, out result);
        }
开发者ID:alimohammad,项目名称:Orchard2,代码行数:25,代码来源:Composite.cs

示例2: TryGetIndex

        public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
        {
            if (indexes.Length == 0)
                throw new Exception("Missing index");

            return dictionary.TryGetValue(indexes[0].ToString(), out result);
        }
开发者ID:Necat0r,项目名称:Automation,代码行数:7,代码来源:SettingsObject.cs

示例3: TryGetIndex

        public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
        {
            result = null;
            var index = indexes.FirstOrDefault();

            if (index == null)
                return false;

            Attempt<object> attempt;
            var s = index as string;
            if (s != null)
            {
                attempt = _row.AttemptGet(r => r[s]);
            }
            else
            {
                var isInt = index.AttemptGet(Convert.ToInt32);
                if (isInt.Succeeded)
                    attempt = isInt.Value.AttemptGet(i => _row[i]);
                else return false;
            }

            result = attempt.Value;
            return attempt.Succeeded;
        }
开发者ID:thomas-parrish,项目名称:Common,代码行数:25,代码来源:DynamicDataRow.cs

示例4: TryGetIndex

 public override bool TryGetIndex(GetIndexBinder binder,
     object[] indexes, out object result)
 {
     var ndx = (int)indexes[0];
     result = new DynamicXml(_elements[ndx]);
     return true;
 }
开发者ID:endjin,项目名称:DeployToAzure,代码行数:7,代码来源:DynamicXml.cs

示例5: TryGetIndex

        public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
        {
            if (indexes.Length > 1)
            {
                result = null;
                return false;
            }

            try
            {
                if (indexes[0] is int)
                {
                    result = GetMember(_record.GetName((int)indexes[0]));
                    return true;
                }
                else if (indexes[0] is string)
                {
                    result = GetMember((string)indexes[0]);
                    return true;
                }
                else
                {
                    result = null;
                    return false;
                }
            }
            catch
            {
                result = null;
                return false;
            }
        }
开发者ID:julid29,项目名称:confsamples,代码行数:32,代码来源:DynamicRecord.cs

示例6: TryGetIndex

        public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
        {
            var index = indexes[0];
            try
            {
                int i = Int32.Parse(((string)index));
                var str_index = i.ToString();
                if (i > length)
                {
                    result = undefined;
                    return true;
                }
                result = Fields[str_index];
                return true;
            }
            catch { }

            try
            {
                int i = (int)index;
                if (i > length)
                {
                    result = undefined;
                    return true;
                }
                result = Fields[i.ToString()];
                return true;

            }
            catch
            {
                result = undefined;
                return true;
            }
        }
开发者ID:jonlt,项目名称:JONSParser,代码行数:35,代码来源:jsArray.cs

示例7: TryGetIndex

        public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
        {
            result = PySharp.PyZero;
            if (indexes.Length != 1 && indexes.Length != 2)
                return false;

            var pyType = GetPyType();
            if (indexes.Length == 2 && indexes[1] is PyType)
                pyType = (PyType) indexes[1];

            if (pyType == PyType.DictType)
            {
                if (indexes[0] is int)
                    result = DictionaryItem((int) indexes[0]);
                if (indexes[0] is long)
                    result = DictionaryItem((long) indexes[0]);
                if (indexes[0] is string)
                    result = DictionaryItem((string) indexes[0]);
                if (indexes[0] is PyObject)
                    result = DictionaryItem((PyObject) indexes[0]);
            }
            else
            {
                // First index has be an int
                if (!(indexes[0] is int))
                    return false;

                var index = (int) indexes[0];
                if (pyType == PyType.TupleType || pyType == PyType.DerivedTupleType)
                    result = Item(index, pyType);
                else
                    result = Item(index);
            }
            return true;
        }
开发者ID:Blinker,项目名称:DirectEve,代码行数:35,代码来源:PyDynamic.cs

示例8: TryGetIndex

        public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
        {
            if (indexes == null || indexes.Length != 1)
            {
                throw new ArgumentException(WebPageResources.DynamicDictionary_InvalidNumberOfIndexes);
            }

            result = null;
            string key = indexes[0] as string;
            if (key != null)
            {
                result = _state[key];
            }
            else if (indexes[0] is int)
            {
                result = _state[(int)indexes[0]];
            }
            else
            {
                // HttpApplicationState only supports keys of type string and int when getting values, so any attempt 
                // to use other types will result in an error. We throw an exception here to explain to the user what is wrong.
                // Returning false will instead cause a runtime binder exception which might be confusing to the user.
                throw new ArgumentException(WebPageResources.DynamicHttpApplicationState_UseOnlyStringOrIntToGet);
            }
            return true;
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:26,代码来源:DynamicHttpApplicationState.cs

示例9: TryGetIndex

 // Get the property value by index.
 public override bool TryGetIndex(
     GetIndexBinder binder, object[] indexes, out object result)
 {
     var key = (string)indexes[0];
     result = this[key];
     return true;
 }
开发者ID:blinemedical,项目名称:SignalRToAs3,代码行数:8,代码来源:ClientsProxy.cs

示例10: TryGetIndex

        public virtual bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
        {
            // X:\jsc.svn\examples\javascript\test\TestDynamicGetIndex\TestDynamicGetIndex\Application.cs

            result = default(object);

            return default(bool);
        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:8,代码来源:DynamicObject.cs

示例11: TryGetIndex

        /// <summary>
        /// 子オブジェクトから取得プロパティを検索しそれを呼びます。
        /// </summary>
        public override bool TryGetIndex(GetIndexBinder binder,
                                         object[] indexes,
                                         out object result)
        {
            var name = indexes[0] as string;

            return TryGetValue(name, out result);
        }
开发者ID:JuroGandalf,项目名称:Ragnarok,代码行数:11,代码来源:DynamicViewModel.cs

示例12: TryGetIndex

 public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result) {
     string key = GetKey(indexes);
     result = null;
     if (!String.IsNullOrEmpty(key)) {
         result = GetValue(key);
     }
     return true;
 }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:8,代码来源:DynamicJsonObject.cs

示例13: TryGetIndex

 public override bool TryGetIndex(GetIndexBinder binder, Object[] indexes, out Object result)
 {
     int index = (int)indexes[0];
     result = _list[index];
     if (result is IDictionary<string, object>)
         result = new DynamicJson(result as IDictionary<string, object>);
     return true;
 }
开发者ID:gitter-badger,项目名称:blimey,代码行数:8,代码来源:dynamic.cs

示例14: TryGetIndex

 public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
 {
     if(indexes.Length == 1 && indexes[0].GetType() == typeof(HttpResponseHeader)) {
         result = _responseHeaders[(HttpResponseHeader)indexes[0]];
         return true;
     }
     return base.TryGetIndex(binder, indexes, out result);
 }
开发者ID:Huddle,项目名称:dynamicrest,代码行数:8,代码来源:RestClient.cs

示例15: TryGetIndex

        public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
        {
			var innerResult = _inner.TryGetIndex(binder, indexes, out result);
			//special case, we need to check if the result is of a non-legacy dynamic type because if it is, we need 
			//to return the legacy type
			result = LegacyConverter.ConvertToLegacy(result);
			return innerResult;
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:8,代码来源:DynamicNull.cs


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