public override bool TrySetIndex(System.Dynamic.SetIndexBinder binder, object[] indexes, object value)
 {
     if (indexes.Count() == 1 && indexes.All(k => k is string))
     {
         Patch(this, System.Convert.ToString(indexes.Single()), value);
     }
     return(base.TrySetIndex(binder, indexes, value));
 }
 /// <summary>
 /// Provides the implementation for operations that set 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="value"> The value to set to the object that has the specified index. </param>
 /// <returns> <c>true</c> if the operation is successful; otherwise, <c>false</c>. </returns>
 public override bool TrySetIndex(System.Dynamic.SetIndexBinder binder, object[] indexes, object value)
 {
     if (indexes.Length != 1)
     {
         throw new NotImplementedException();
     }
     this.obj[indexes[0].ToString()] = value;
     return(true);
 }
示例#3
0
 public override bool TrySetIndex(System.Dynamic.SetIndexBinder binder, object[] indexes, object value)
 {
     if (indexes != null && indexes.Length == 1 && int.Parse(indexes[0].ToString()) < this.PrivateList.Count)
     {
         this.PrivateList[int.Parse(indexes[0].ToString())] = value;
         return(true);
     }
     return(base.TrySetIndex(binder, indexes, value));
 }
        public override bool TrySetIndex(System.Dynamic.SetIndexBinder binder, object[] indexes, object value)
        {
            if (indexes.Count() == 1)
            {
                var key = Convert.ToString(indexes.First());

                return(TrySetMemberImpl(key, value));
            }

            return(base.TrySetIndex(binder, indexes, value));
        }
示例#5
0
 /// <summary>
 /// Provides the implementation for operations that set a value by index. Classes derived from the <see cref="T:System.Dynamic.DynamicObject" /> class can override this method to specify dynamic behavior for operations that access objects by a specified index.
 /// </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] = 10 operation in C# (sampleObject(3) = 10 in Visual Basic), where sampleObject is derived from the <see cref="T:System.Dynamic.DynamicObject" /> class, <paramref name="indexes[0]" /> is equal to 3.</param>
 /// <param name="value">The value to set to the object that has the specified index. For example, for the sampleObject[3] = 10 operation in C# (sampleObject(3) = 10 in Visual Basic), where sampleObject is derived from the <see cref="T:System.Dynamic.DynamicObject" /> class, <paramref name="value" /> is equal to 10.</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 TrySetIndex(System.Dynamic.SetIndexBinder binder, object[] indexes, object value)
 {
     try
     {
         PropertyInfo prop = TargetType.GetProperty("Item", AccessFlags);
         prop.SetValue(Target, value, indexes);
         return(true);
     }
     catch (Exception)
     {
         return(base.TrySetIndex(binder, indexes, value));
     }
 }
 public virtual bool TrySetIndex(System.Dynamic.SetIndexBinder binder, object[] indexes, object value)
 {
     throw null;
 }
 public virtual System.Dynamic.DynamicMetaObject BindSetIndex(System.Dynamic.SetIndexBinder binder, System.Dynamic.DynamicMetaObject[] indexes, System.Dynamic.DynamicMetaObject value)
 {
     throw null;
 }
示例#8
0
 public override bool TrySetIndex(System.Dynamic.SetIndexBinder binder, object[] indexes, object value)
 {
     return(true);
 }
 public virtual bool TrySetIndex(System.Dynamic.SetIndexBinder binder, object[] indexes, object value)
 {
     return(default(bool));
 }
 public virtual System.Dynamic.DynamicMetaObject BindSetIndex(System.Dynamic.SetIndexBinder binder, System.Dynamic.DynamicMetaObject[] indexes, System.Dynamic.DynamicMetaObject value)
 {
     return(default(System.Dynamic.DynamicMetaObject));
 }
 public override bool TrySetIndex(System.Dynamic.SetIndexBinder binder, Object[] indexes, Object value)
 {
     return(default(bool));
 }