コード例 #1
0
ファイル: Get.cs プロジェクト: FlorianGrimm/DurableWeb
 /// <summary>
 /// Tries the index of the get.
 /// </summary>
 /// <param name="binder">The binder.</param>
 /// <param name="indexes">The indexes.</param>
 /// <param name="result">The result.</param>
 /// <returns></returns>
 public override bool TryGetIndex(System.Dynamic.GetIndexBinder binder, object[] indexes, out object result)
 {
     if (base.TryGetIndex(binder, indexes, out result))
     {
         return(this.MassageResultBasedOnInterface(Invocation.IndexBinderName, true, ref result));
     }
     return(false);
 }
コード例 #2
0
 public override bool TryGetIndex(System.Dynamic.GetIndexBinder binder, object[] indexes, out object result)
 {
     if (indexes != null && indexes.Length == 1 && int.Parse(indexes[0].ToString()) < this.PrivateList.Count)
     {
         result = this.PrivateList[int.Parse(indexes[0].ToString())];
         return(true);
     }
     return(base.TryGetIndex(binder, indexes, out result));
 }
コード例 #3
0
 public override bool TryGetIndex(System.Dynamic.GetIndexBinder binder, object [] indexes, out object result)
 {
     if (indexes.Length == 1)
     {
         result = _row [int.Parse(indexes [0].ToString())];
         return(true);
     }
     return(base.TryGetIndex(binder, indexes, out result));
 }
コード例 #4
0
        public override bool TryGetIndex(System.Dynamic.GetIndexBinder binder, object[] indexes, out object result)
        {
            if (indexes.Count() == 1)
            {
                var key = Convert.ToString(indexes.Single());

                return(TryGetMemberImpl(key, out result));
            }

            return(base.TryGetIndex(binder, indexes, out result));
        }
コード例 #5
0
 /// <summary>
 /// Provides the implementation for operations that get a value by index.
 /// </summary>
 /// <param name="binder"> Provides information about the object that called the dynamic
 /// operation. </param>
 /// <param name="indexes"> The indexes that are used in the operation. </param>
 /// <param name="result"> The result of the index operation. </param>
 /// <returns> <c>true</c> if the operation is successful; otherwise, <c>false</c>. </returns>
 public override bool TryGetIndex(System.Dynamic.GetIndexBinder binder, object[] indexes, out object result)
 {
     if (indexes.Length != 1)
     {
         throw new NotImplementedException();
     }
     result = this.obj[indexes[0].ToString()];
     if (TypeUtilities.IsUndefined(result))
     {
         result = Undefined.Value;
     }
     return(true);
 }
コード例 #6
0
        /// <summary>
        /// Attempts to get an index of the instance.
        /// </summary>
        /// <param name="binder"></param>
        /// <param name="indexes"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public override bool TryGetIndex(System.Dynamic.GetIndexBinder binder, object[] indexes, out object result)
        {
            string name = indexes[0].ToString().ToLower();

            if (!_dictionary.ContainsKey(name))
            {
                Logger.Warning(String.Format("Key '{0}' Not Found In ItemFields", name));
                result = null;
                return(true);
            }

            return(_dictionary.TryGetValue(name, out result));
        }
コード例 #7
0
ファイル: DynamicJson.cs プロジェクト: tmnykf/Symbol
        public override bool TryGetIndex(System.Dynamic.GetIndexBinder binder, Object[] indexes, out Object result)
        {
            var index = indexes[0];

            if (index is int)
            {
                result = _list[(int)index];
            }
            else
            {
                result = _dictionary[(string)index];
            }
            if (result is IDictionary <string, object> )
            {
                result = new DynamicJson(result as IDictionary <string, object>);
            }
            return(true);
        }
コード例 #8
0
 public override bool TryGetIndex(System.Dynamic.GetIndexBinder binder, object[] indexes, out object result)
 {
     if (list != null && indexes[0] is int i)
     {
         object v = list[i];
         result = v;
         if (result is Dictionary <string, object> )
         {
             result = new JsonData(result as Dictionary <string, object>);
         }
         else if (result is System.Collections.ArrayList)
         {
             result = new JsonData(result as System.Collections.ArrayList);
         }
         return(true);
     }
     else if (data != null)
     {
         if (indexes[0] is int i1)
         {
             string[] keys = new string[data.Keys.Count];
             data.Keys.CopyTo(keys, 0);
             result = keys[i1];
             return(true);
         }
         else if (indexes[0] is string)
         {
             if (data.ContainsKey(indexes[0].ToString()))
             {
                 result = data[indexes[0].ToString()];
                 if (result is Dictionary <string, object> )
                 {
                     result = new JsonData(result as Dictionary <string, object>);
                 }
                 else if (result is System.Collections.ArrayList)
                 {
                     result = new JsonData(result as System.Collections.ArrayList);
                 }
                 return(true);
             }
         }
     }
     return(base.TryGetIndex(binder, indexes, out result));
 }
コード例 #9
0
 /// <summary>
 /// Provides the implementation for operations that get a value by index. Classes derived from the <see cref="T:System.Dynamic.DynamicObject" /> class can override this method to specify dynamic behavior for indexing operations.
 /// </summary>
 /// <param name="binder">Provides information about the operation.</param>
 /// <param name="indexes">The indexes that are used in the operation. For example, for the sampleObject[3] operation in C# (sampleObject(3) in Visual Basic), where sampleObject is derived from the DynamicObject class, <paramref name="indexes[0]" /> is equal to 3.</param>
 /// <param name="result">The result of the index operation.</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 run-time exception is thrown.)
 /// </returns>
 public override bool TryGetIndex(System.Dynamic.GetIndexBinder binder, object[] indexes, out object result)
 {
     try
     {
         PropertyInfo prop = TargetType.GetProperty("Item", AccessFlags);
         result = prop.GetValue(Target, indexes);
         if (WrapReturn)
         {
             result = new DynamicReflector(result)
             {
                 WrapReturn = this.WrapReturn
             };
         }
         return(true);
     }
     catch (Exception)
     {
         return(base.TryGetIndex(binder, indexes, out result));
     }
 }
コード例 #10
0
 public override bool TryGetIndex(System.Dynamic.GetIndexBinder binder, object[] indexes, out object result)
 {
     // NilBehavior
     result = Nil.Instance;
     return(true);
 }
コード例 #11
0
 public virtual bool TryGetIndex(System.Dynamic.GetIndexBinder binder, object[] indexes, out object result)
 {
     throw null;
 }
コード例 #12
0
 public virtual System.Dynamic.DynamicMetaObject BindGetIndex(System.Dynamic.GetIndexBinder binder, System.Dynamic.DynamicMetaObject[] indexes)
 {
     throw null;
 }
コード例 #13
0
 public virtual bool TryGetIndex(System.Dynamic.GetIndexBinder binder, object[] indexes, out object result)
 {
     result = default(object); return(default(bool));
 }
コード例 #14
0
 public virtual System.Dynamic.DynamicMetaObject BindGetIndex(System.Dynamic.GetIndexBinder binder, System.Dynamic.DynamicMetaObject[] indexes)
 {
     return(default(System.Dynamic.DynamicMetaObject));
 }
        public override bool TryGetIndex(System.Dynamic.GetIndexBinder binder, Object[] indexes, out Object result)
        {
            result = default(Object);

            return(default(bool));
        }