Esempio n. 1
0
 public FieldInfo GetBackingField()
 {
     if (_backingField == null)
     {
         string fieldName = ReflectionUtil.DeriveBackingFieldName(_property.Name);
         _backingField = ReflectionUtil.GetField(_owner, fieldName);
     }
     return(_backingField);
 }
Esempio n. 2
0
        /// <exception cref="InvalidOperationException">property does not implement backing field.</exception>
        public void SetBackingField(object value)
        {
            if (!HasBackingField())
            {
                throw new InvalidOperationException(string.Format("property {0} does not implement backing field {1}",
                                                                  _property.Name,
                                                                  ReflectionUtil.DeriveBackingFieldName(_property.Name)));
            }

            FieldInfo backingField = GetBackingField();

            backingField.SetValue(_owner, value);
        }