示例#1
0
 public PropItemWatcherGen(PSAccessServiceInternalInterface storeAccessor, PropIdType propId, Type propertyType /*, bool isAsynchronous*/)
 {
     _storeAccessor_wr = new WeakReference <PSAccessServiceInternalInterface>(storeAccessor);
     _propId           = propId;
     PropertyType      = propertyType;
     //IsAsynchronous = isAsynchronous;
 }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        //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);
        }
示例#5
0
        public ObjectIdType Explode(CompositeKeyType cKey, out PropIdType bot)
        {
            bot = (PropIdType)(cKey & _botMask);

            ObjectIdType result = (cKey >> _botFieldLen) & _topMask;

            return(result);
        }
示例#6
0
 public IManageCViews this[PropIdType propId]
 {
     get
     {
         IManageCViews result = _dict[propId];
         return(result);
     }
 }
示例#7
0
        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);
        }
示例#8
0
        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;
        }
示例#9
0
 public bool RemoveListOfSubscriptionPtrs(PropIdType l2Key)
 {
     if (_subCollections.TryRemove(l2Key, out SubscriberCollection sc))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#10
0
 public bool TryGetPropId(PropNameType propertyName, out PropIdType propId)
 {
     if (_nameToIdMap.TryGetValue(propertyName, out propId))
     {
         return(true);
     }
     else
     {
         propId = PropIdType.MaxValue;
         return(false);
     }
 }
示例#11
0
 public bool TryGetValue(PropIdType propId, out IManageCViews cViewManager)
 {
     if (_dict.TryGetValue(propId, out cViewManager))
     {
         return(true);
     }
     else
     {
         cViewManager = null;
         return(false);
     }
 }
示例#12
0
 public bool TryGetPropNode(PropIdType propId, out PropNode propNode)
 {
     if (_children.TryGetValue(propId, out propNode))
     {
         return(true);
     }
     else
     {
         propNode = null;
         return(false);
     }
 }
示例#13
0
 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);
     }
 }
示例#14
0
 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);
     }
 }
示例#15
0
        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);
        }
示例#16
0
        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);
        }
示例#17
0
        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);
            }
        }
示例#18
0
        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);
        }
示例#20
0
        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);
        }
示例#21
0
        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;
            }
        }
示例#22
0
        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
     )
 {
 }
示例#24
0
        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);
        }
示例#25
0
        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);
        }
示例#26
0
        //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.");
            }
        }
示例#27
0
        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);
        }
示例#28
0
        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);
        }
示例#29
0
        public bool TryGetSubscriberCollection(PropIdType propId, out SubscriberCollection subs)
        {
            bool result = _subCollections.TryGetValue(propId, out subs);

            return(result);
        }
示例#30
0
        public bool ContainsTheListOfSubscriptionPtrs(PropIdType l2Key)
        {
            bool result = _subCollections.ContainsKey(l2Key);

            return(result);
        }