public PropItemWatcherGen(PSAccessServiceInternalInterface storeAccessor, PropIdType propId, Type propertyType /*, bool isAsynchronous*/) { _storeAccessor_wr = new WeakReference <PSAccessServiceInternalInterface>(storeAccessor); _propId = propId; PropertyType = propertyType; //IsAsynchronous = isAsynchronous; }
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); }
public object GetValueFast(WeakRefKey <IPropBag> propBag_wrKey, PropIdType propId, PropItemSetKeyType propItemSetKey) { BagNode propBagNode = GetBagAndChild(propBag_wrKey, propItemSetKey, propId, out PropNode child); object result = child.PropData_Internal.TypedProp.TypedValueAsObject; return(result); }
//public object AccessToken => WR_AccessToken; //public WeakReference<IPropBagInternal> WR_AccessToken { get; } #endregion #region Public Methods public CompositeKeyType Fuse(ObjectIdType top, PropIdType bot) { CompositeKeyType result = top; result = result << _botFieldLen; result += bot; return(result); }
public ObjectIdType Explode(CompositeKeyType cKey, out PropIdType bot) { bot = (PropIdType)(cKey & _botMask); ObjectIdType result = (cKey >> _botFieldLen) & _topMask; return(result); }
public IManageCViews this[PropIdType propId] { get { IManageCViews result = _dict[propId]; return(result); } }
public PropNode CreateAndAdd(IPropDataInternal propData_Internal, PropNameType propertyName, BagNode parent) { PropIdType nextPropId = GetNextPropId(); PropNode newPropNode = new PropNode(nextPropId, propData_Internal, parent); Add(newPropNode); return(newPropNode); }
public PropNode(PropIdType propId, IPropDataInternal propData_Internal, BagNode parent) { CompKey = new SimpleExKey(parent.ObjectId, propId); PropData_Internal = propData_Internal ?? throw new ArgumentNullException(nameof(propData_Internal)); //parent.AddChild(this); Parent = parent; Child = null; }
public bool RemoveListOfSubscriptionPtrs(PropIdType l2Key) { if (_subCollections.TryRemove(l2Key, out SubscriberCollection sc)) { return(true); } else { return(false); } }
public bool TryGetPropId(PropNameType propertyName, out PropIdType propId) { if (_nameToIdMap.TryGetValue(propertyName, out propId)) { return(true); } else { propId = PropIdType.MaxValue; return(false); } }
public bool TryGetValue(PropIdType propId, out IManageCViews cViewManager) { if (_dict.TryGetValue(propId, out cViewManager)) { return(true); } else { cViewManager = null; return(false); } }
public bool TryGetPropNode(PropIdType propId, out PropNode propNode) { if (_children.TryGetValue(propId, out propNode)) { return(true); } else { propNode = null; return(false); } }
public bool TryGetPropId(PropNameType propertyName, out PropIdType propId) { if (PropItemsByName.TryGetValue(propertyName, out PropNode propNode)) { propId = propNode.PropId; return(true); } else { propId = PropIdType.MaxValue; return(false); } }
public bool TryGetPropertyName(PropIdType propId, out PropNameType propertyName) { if (_children.TryGetValue(propId, out PropNode propNode)) { propertyName = propNode.PropertyName; return(true); } else { propertyName = null; return(false); } }
public bool SetValueFast(WeakRefKey <IPropBag> propBag_wrKey, PropIdType propId, PropItemSetKeyType propItemSetKey, object value) { if (!propBag_wrKey.TryGetTarget(out IPropBag component)) { // The target has been Garbage Collected, its ok to simply return false since the client is no longer waiting for our result. return(false); } BagNode propBagNode = GetBagAndChild(propBag_wrKey, propItemSetKey, propId, out PropNode child); bool result = SetPropValue(component, child, propId, value); return(result); }
public bool TryGetPropNode(PropIdType propId, out PropNode propNode) { lock (_sync) { if (Contains(propId)) { propNode = _children[propId - 1]; // Our Array begin at index 0; PropIds start at 1. (0 is reserved for none or all Properties.) return(true); } } propNode = null; return(false); }
public bool TryGetSubscriberCollection(PropIdType propId, out IEnumerable <ISubscription> subs) { bool result = _subCollections.TryGetValue(propId, out SubscriberCollection sc); if (result) { subs = sc; return(true); } else { subs = Enumerable.Empty <ISubscription>(); return(false); } }
public SubscriberCollection GetOrCreate(PropIdType l2Key, out bool wasAdded) { bool internalWasAdded = false; SubscriberCollection result = _subCollections.GetOrAdd ( key: l2Key, valueFactory: ( x => { internalWasAdded = true; return(new SubscriberCollection()); } ) ); wasAdded = internalWasAdded; return(result); }
public PropItemFixedPropertyDescriptor ( PropertyDescriptorValues <T> tdConfig, PSFastAccessServiceInterface psFastAccessService, PropModelType propModel, PropIdType propId ) : base(tdConfig.Name, tdConfig.Attributes) { _tdConfig = tdConfig; _psFastAccessService = psFastAccessService; _propItemSetKey = new PropItemSetKeyType(propModel); PropId = propId; _compKey = new SimpleExKey(10, propId); }
public object GetValueFast(BagNode propBagNode, PropIdType propId, PropItemSetKeyType propItemSetKey) { if (propItemSetKey != propBagNode.PropItemSetKey) { throw new InvalidOperationException("Bad PropModel."); } if (!propBagNode.TryGetChild(propId, out PropNode child)) { throw new InvalidOperationException("Could not retrieve PropNode for that compKey."); } object result = child.PropData_Internal.TypedProp.TypedValueAsObject; return(result); }
private bool SetPropValue(IPropBag component, PropNode child, PropIdType propId, object value) { try { IProp typedProp = child.PropData_Internal.TypedProp; string propertyName = typedProp.PropertyName; DoSetDelegate dsd = typedProp.PropTemplate.DoSetDelegate; bool result = dsd(component, propId, propertyName, typedProp, value); return(result); } catch { throw; } }
public bool TryRemove(PropIdType propId, out PropNode propNode) { lock (_sync) { if (_children.TryGetValue(propId, out propNode)) { _children.Remove(propId); if (_propItemsByName != null) { _propItemsByName.Remove(propNode.PropertyName); } return(true); } } propNode = null; return(false); }
public PropItemFixedPropertyDescriptor ( PSFastAccessServiceInterface psFastAccessService, PropModelType propModel, PropIdType propId, PropNameType propertyName, Type propertyType, Attribute[] attributes ) : this ( GetTdConfig(propModel.ClassName, attributes, propertyName, propertyType), psFastAccessService, propModel, propId ) { }
public bool SetValueFast(IPropBag component, PropIdType propId, PropItemSetKeyType propItemSetKey, object value) { if (component is IPropBagInternal ipbi) { if (ipbi is IHaveTheStoreNode ihtsn) { BagNode propBagNode = (ipbi as IHaveTheStoreNode)?.PropBagNode; bool result1 = _propStoreAccessServiceProvider.SetValueFast(propBagNode, propId, propItemSetKey, value); return(result1); } } //ExKeyT compKey = GetCompKey(component, propId); WeakRefKey <IPropBag> propBag_wrKey = new WeakRefKey <IPropBag>(component); bool result2 = _propStoreAccessServiceProvider.SetValueFast(propBag_wrKey, propId, propItemSetKey, value); return(result2); }
public bool SetValueFast(BagNode propBagNode, PropIdType propId, PropItemSetKeyType propItemSetKey, object value) { if (propItemSetKey != propBagNode.PropItemSetKey) { throw new InvalidOperationException("Bad PropModel."); } if (!propBagNode.TryGetPropBag(out IPropBag component)) { throw new InvalidOperationException("IPropBag target has been Garbage Collected."); } if (!propBagNode.TryGetChild(propId, out PropNode child)) { throw new InvalidOperationException("Could not retrieve PropNode for that compKey."); } bool result = SetPropValue(component, child, propId, value); return(result); }
//Lazy<IValueConverter> _defaultConverter; //public virtual Lazy<IValueConverter> DefaultConverter //{ // get // { // if(_defaultConverter == null) // { // return new Lazy<IValueConverter>(() => new PropValueConverter()); // } // return _defaultConverter; // } // set // { // _defaultConverter = value; // } //} //Func<BindingTarget, MyBindingInfo, Type, string, object> _defConvParamBuilder; //public virtual Func<BindingTarget, MyBindingInfo, Type, string, object> DefaultConverterParameterBuilder //{ // get // { // if (_defConvParamBuilder == null) // { // return OurDefaultConverterParameterBuilder; // } // return _defConvParamBuilder; // } // set // { // _defConvParamBuilder = value; // } //} #endregion #region Constructor public LocalBinder(PSAccessServiceInterface propStoreAccessService, ExKeyT bindingTarget, LocalBindingInfo bindingInfo) { _bindingTarget = bindingTarget; _bindingInfo = bindingInfo; // Get the PropStore Node for the IPropBag object hosting the property that is the target of the binding. BagNode ourNode = GetPropBagNode(propStoreAccessService); // Get a weak reference to the PropBag hosting the target property. _targetObject = ourNode.PropBagProxy; // Get the name of the target property from the PropId given to us. if (_targetObject.TryGetTarget(out IPropBag propBag)) { PropIdType propId = _bindingTarget.Level2Key; _propertyName = GetPropertyName(propStoreAccessService, propBag, propId, out PropStorageStrategyEnum storageStrategy); if (storageStrategy == PropStorageStrategyEnum.External) { throw new InvalidOperationException($"{storageStrategy} is not a supported Prop Storage Strategy when used as a target of a local binding."); } // We will update the target property depending on how that PropItem stores its value. _targetStorageStrategy = storageStrategy; // Create a instance of our nested, internal class that reponds to Updates to the property store Nodes. IReceivePropStoreNodeUpdates_PropNode <T> propStoreNodeUpdateReceiver = new PropStoreNodeUpdateReceiver(this); // Create a new watcher, the bindingInfo specifies the PropItem for which to listen to changes, // the propStoreNodeUpdateReceiver will be notfied when changes occur. _localWatcher = new LocalWatcher <T>(propStoreAccessService, bindingInfo, propStoreNodeUpdateReceiver); } else { // TODO: consider creating a TryCreateLocalBinding to avoid this situation. System.Diagnostics.Debug.WriteLine("The target was found to have been Garbage Collected when creating a Local Binding."); } }
public object GetValueFast(IPropBag component, PropIdType propId, PropItemSetKeyType propItemSetKey) { if (component is IPropBagInternal ipbi) { //if(ipbi.ItsStoreAccessor is IHaveTheStoreNode ihtsn) //{ // BagNode propBagNode = ihtsn.PropBagNode; // object result1 = _propStoreAccessServiceProvider.GetValueFast(propBagNode, propId, propItemSetKey); // return result1; //} BagNode propBagNode = ((IHaveTheStoreNode)ipbi.ItsStoreAccessor).PropBagNode; object result1 = _propStoreAccessServiceProvider.GetValueFast(propBagNode, propId, propItemSetKey); return(result1); } //ExKeyT compKey = GetCompKey(component, propId); WeakRefKey <IPropBag> propBag_wrKey = new WeakRefKey <IPropBag>(component); object result2 = _propStoreAccessServiceProvider.GetValueFast(propBag_wrKey, propId, propItemSetKey); return(result2); }
public LocalBinder(PSAccessServiceInterface propStoreAccessService, ExKeyT ownerPropId, LocalBindingInfo bindingInfo) { _propStoreAccessService_wr = new WeakReference <PSAccessServiceInterface>(propStoreAccessService); _bindingTarget = ownerPropId; _bindingInfo = bindingInfo; _storeNodeUpdateReceiver = null; // Get the PropStore Node for the IPropBag object hosting the property that is the target of the binding. _ourNode = GetPropBagNode(propStoreAccessService); PropIdType propId = _bindingTarget.Level2Key; _targetObject = _ourNode.PropBagProxy; if (_targetObject.TryGetTarget(out IPropBagInternal propBag)) { _propertyName = GetPropertyName(propStoreAccessService, propBag, propId, out PropStorageStrategyEnum storageStrategy); _targetHasStore = storageStrategy; } _pathElements = GetPathElements(_bindingInfo, out _isPathAbsolute, out _firstNamedStepIndex); if (_isPathAbsolute) { _rootListener = CreateAndListen(_ourNode, "root", SourceKindEnum.AbsRoot); } else { _rootListener = null; } _pathListeners = new OSCollection <T>(); _isComplete = StartBinding(_targetObject, _pathElements, _pathListeners, _isPathAbsolute); }
public bool TryGetSubscriberCollection(PropIdType propId, out SubscriberCollection subs) { bool result = _subCollections.TryGetValue(propId, out subs); return(result); }
public bool ContainsTheListOfSubscriptionPtrs(PropIdType l2Key) { bool result = _subCollections.ContainsKey(l2Key); return(result); }