Beispiel #1
0
        public BindingMemberInfo(IBindingMemberInfo attachedIndexerMember, string path)
        {
            var accessor = new AttachedIndexerAccessor(attachedIndexerMember, BindingReflectionExtensions.GetIndexerValues(path, castType: typeof(string)));

            _getValueAccessor             = accessor.GetValue;
            _setValueAccessor             = accessor.SetValue;
            _indexerAttachedBindingMember = attachedIndexerMember;
            _memberType = attachedIndexerMember.MemberType;
            _type       = attachedIndexerMember.Type;
            _canRead    = attachedIndexerMember.CanRead;
            _canWrite   = attachedIndexerMember.CanWrite;
            _canObserve = attachedIndexerMember.CanObserve;
        }
Beispiel #2
0
        public BindingMemberInfo(string path, Type type)
            : this(path, BindingMemberType.Array, type.GetElementType())
        {
            var indexes = BindingReflectionExtensions
                          .GetIndexerValues(path, null, typeof(int))
                          .ToArrayEx(o => (int)o);
            var arrayAccessor = new ArrayAccessor(indexes);

            _getValueAccessorSingle       = arrayAccessor.GetValue;
            _setValueAccessorSingleAction = arrayAccessor.SetValue;
            _canRead           = true;
            _canWrite          = true;
            _isSingleParameter = true;
        }
Beispiel #3
0
 public BindingMemberInfo(string path, bool expandoObject)
     : this(path, BindingMemberType.Dynamic, typeof(object))
 {
     object[] indexerValues = null;
     if (expandoObject)
     {
         _isSingleParameter      = true;
         _getValueAccessorSingle = o =>
         {
             object value;
             ((IDictionary <string, object>)o).TryGetValue(path, out value);
             return(value);
         };
         _setValueAccessorSingleAction = (o, v) => ((IDictionary <string, object>)o)[path] = v;
     }
     else
     {
         if (path.StartsWith("[", StringComparison.Ordinal) || path.StartsWith("Item[", StringComparison.Ordinal))
         {
             indexerValues = BindingReflectionExtensions.GetIndexerValues(path, castType: typeof(string));
         }
         var accessor = new DynamicObjectAccessor(path, indexerValues);
         if (indexerValues == null)
         {
             _getValueAccessor = accessor.GetValue;
             _setValueAccessor = accessor.SetValue;
         }
         else
         {
             _getValueAccessor = accessor.GetValueIndex;
             _setValueAccessor = accessor.SetValueIndex;
         }
         _isDynamic  = true;
         _canObserve = true;
     }
     _canRead  = true;
     _canWrite = true;
 }