/// <summary> /// Creates a new BagNode for the specified PropBag, optionally using a collection of PropNodes as the source. /// The source PropNodes are cloned. If the value of a PropNode cannot be cloned, an InvalidOperation exception will be thrown. /// This is the core of IPropBag.Clone() /// </summary> /// <param name="objectId">The new globally unique Id to use for this new BagNode.</param> /// <param name="propBag">The client IPropBag.</param> /// <param name="template">A Collection of PropNodes to use as a template for the new PropBag's Child PropItems. Can be null.</param> /// <param name="maxPropsPerObject">The maximum number of PropItems a single PropBag can have.</param> /// <param name="callPSParentNodeChangedEventSubsCache">A reference to a service that caches Parent Node Change Event dispatchers.</param> public BagNode(ObjectIdType objectId, IPropBag propBag, PropNodeCollectionIntInterface template, int maxPropsPerObject, ICacheDelegates <CallPSParentNodeChangedEventSubDelegate> callPSParentNodeChangedEventSubsCache) { CompKey = new SimpleExKey(objectId, 0); PropBagProxy = new WeakRefKey <IPropBag>(propBag ?? throw new ArgumentNullException(nameof(propBag))); _callPSParentNodeChangedEventSubsCache = callPSParentNodeChangedEventSubsCache ?? throw new ArgumentNullException(nameof(callPSParentNodeChangedEventSubsCache)); _parentNCSubscriberCollection = null; if (template == null) { _propNodeCollection = new PropNodeCollection(maxPropsPerObject); } else { _propNodeCollection = ClonePropNodes(template, this); //var x = EqualityComparer<WeakRefKey<PropModelType>?>.Default; //bool propItemSetIdsMatch = x.Equals(_propNodeCollection.PropItemSetId, template.PropItemSetId); //System.Diagnostics.Debug.Assert(EqualityComparer<WeakRefKey<PropModelType>?>.Default.Equals(_propNodeCollection.PropItemSetId, template.PropItemSetId), "PropItemSetIds don't match."); bool propItemSetIdsMatch = _propNodeCollection.PropItemSetKey == template.PropItemSetKey; System.Diagnostics.Debug.Assert(propItemSetIdsMatch, "PropItemSetIds don't match."); System.Diagnostics.Debug.Assert(_propNodeCollection.IsFixed == template.IsFixed, "IsFixed doesn't match."); } }
public bool TryRemove(IPropBag propBag, PropIdType propId, out IPropGen propData) { SimpleExKey exKey = GetCompKey(propBag, propId); bool result = _theGlobalStore.TryRemove(exKey, out propData); return(result); }
SimpleExKey GetCompKey(IPropBag propBag, PropIdType propId) { ObjectIdType objectId = GetAndCheckObjectRef(propBag); CompositeKeyType cKey = _compKeyManager.JoinComp(objectId, propId); SimpleExKey exKey = new SimpleExKey(cKey, _clientAccessToken, objectId, propId); return(exKey); }
public bool ContainsKey(IPropBag propBag, PropIdType propId) { SimpleExKey exKey = GetCompKey(propBag, propId); bool result = _theGlobalStore.ContainsKey(exKey); return(result); }
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; }
ObjectIdType GetAndCheckObjectRef(IPropBag propBag) { IPropBag client = SimpleExKey.UnwrapWeakRef(_clientAccessToken); if (!object.ReferenceEquals(propBag, client)) { throw new InvalidOperationException("This PropStoreAccessService can only service the PropBag object that created it."); } ObjectIdType result = _objectId; return(result); }
public IPropGen this[IPropBag propBag, PropIdType propId] { get { SimpleExKey exKey = GetCompKey(propBag, propId); IPropGen result = _theGlobalStore[exKey]; return(result); } set { SimpleExKey exKey = GetCompKey(propBag, propId); _theGlobalStore[exKey] = value; } }
SimpleExKey IHaveTheSimpleKey.GetTheKey(IPropBag propBag, PropIdType propId) { SimpleExKey result = GetCompKey(propBag, propId); return(result); }