private bool TryGetChildProp(StoreNodeBag objectNode, IPropBagInternal propBag, string propertyName, out StoreNodeProp child) { PropIdType propId = ((PSAccessServiceInternalInterface)propBag.ItsStoreAccessor).Level2KeyManager.FromRaw(propertyName); bool result = objectNode.TryGetChild(propId, out child); return(result); }
private bool AddOrUpdateListener(IPropBagInternal propBag, ExKeyT compKey, string pathComp, SourceKindEnum sourceKind, OSCollection <T> pathListeners, int nPtr) { bool result; if (pathListeners.Count > nPtr) { ObservableSource <T> listener = pathListeners[nPtr]; if (compKey != listener.CompKey || sourceKind != listener.SourceKind) { listener.Dispose(); ObservableSource <T> newListener = CreateAndListen(propBag, compKey, pathComp, sourceKind); pathListeners[nPtr] = newListener; result = true; } else { result = false; } } else { ObservableSource <T> newListener = CreateAndListen(propBag, compKey, pathComp, sourceKind); pathListeners.Add(newListener); result = true; } return(result); }
private bool TryGetPropBag(StoreNodeBag objectNode, out IPropBagInternal propBag) { // Unwrap the weak reference held by the objectNode in it's PropBagProxy.PropBagRef. //bool result = objectNode.PropBagProxy.PropBagRef.TryGetTarget(out propBag); bool result = objectNode.TryGetPropBag(out propBag); return(result); }
private ObservableSource <T> CreateAndListen(IPropBagInternal propBag, ExKeyT compKey, string pathComp, SourceKindEnum sourceKind) { ObservableSource <T> result; if (sourceKind == SourceKindEnum.Down) { result = new ObservableSource <T>((IPropBag)propBag, compKey, pathComp, sourceKind, BINDER_NAME); result.PropertyChangedWithVals += PropertyChangedWithVals_Handler; } else if (sourceKind == SourceKindEnum.TerminalNode) { result = new ObservableSource <T>((IPropBag)propBag, compKey, pathComp, BINDER_NAME); result.PropertyChangedWithTVals += PropertyChangedWithTVals_Handler; } else { throw new InvalidOperationException($"CreateAndListen when supplied a propBag can only process nodes of source kind = {nameof(SourceKindEnum.Down)} and {nameof(SourceKindEnum.TerminalNode)}."); } return(result); }
public PropBagProxy(IPropBagInternal propBag) { PropBagRef = new WeakReference <IPropBagInternal>(propBag ?? throw new ArgumentNullException(nameof(propBag))); }
// TODO: should be able to have IPropStoreAccessServiceInternal provide all of this with a single call. private PropNameType GetPropertyName(PSAccessServiceInterface propStoreAccessService, IPropBagInternal propBag, PropIdType propId, out PropStorageStrategyEnum storageStrategy) { PropNameType result; if (propStoreAccessService.TryGetPropName(propId, out PropNameType propertyName)) { result = propertyName; } else { throw new InvalidOperationException("Cannot retrieve the Target's property name from the TargetPropId."); } if (propStoreAccessService.TryGetValue((IPropBag)propBag, propId, out IPropData genProp)) { storageStrategy = genProp.TypedProp.StorageStrategy; } else { throw new InvalidOperationException("Cannot retrieve the Target's property name from the TargetPropId."); } return(result); }