public override bool TrySetMember(SetMemberBinder binder, object value) { if (IsReadOnly) { throw new PropertyReadonlyException(); } string name = binder.Name; if (dynamicProxies.ContainsKey(name)) { if (Unbox(value) is DynamicPropertyProxy newProxy) { return(ObservableProperty.TrySetMember(name, newProxy.ObservableProperty)); } } if (collectionProxies.TryGetValue(name, out ICollectionProxy dynamicCollectionObservable)) { bool result; if (result = ObservableProperty.TrySetMember(name, value)) { dynamicCollectionObservable.Recycle(); } return(result); } return(ObservableProperty.TrySetMember(name, value)); }
public void SetValue(string propertyName, object value) { if (IsReadOnly) { throw new PropertyReadonlyException(); } if (runtimeProxies.ContainsKey(propertyName)) { if (value is IRuntimeProxy runtimeProxy) { if (!ObservableProperty.TrySetMember(propertyName, runtimeProxy.Manager.ObservableProperty)) { throw new NotSupportedException(propertyName); } } } if (collectionProxies.TryGetValue(propertyName, out ICollectionProxy collectionProxy)) { if (ObservableProperty.TrySetMember(propertyName, value)) { collectionProxy.Recycle(); } #if DEBUG else { throw new Exception(); } #endif } if (!ObservableProperty.TrySetMember(propertyName, value)) { throw new NotSupportedException(propertyName); } }