Пример #1
0
        private void UpdatePropertyNode(PropertyInfo property)
        {
            if (this.Settings.IsIgnoringProperty(property) ||
                !Is.Trackable(property.PropertyType))
            {
                return;
            }

            var getter = this.Settings.GetOrCreateGetterAndSetter(property);
            var value  = getter.GetValue(this.Source);
            IRefCounted <ChangeTrackerNode> node;

            if (TryGetOrCreate(value, this.Settings, false, out node))
            {
                using (node)
                {
                    var propertyNode = ChildNodes <ChangeTrackerNode> .CreateChildNode(this, node.Value, property);

                    propertyNode.Changed += this.OnChildNodeChanged;
                    IUnsubscriber <IChildNode <ChangeTrackerNode> > childNode = propertyNode.UnsubscribeAndDispose(n => n.Changed -= this.OnChildNodeChanged);
                    this.Children.SetValue(property, childNode);
                }
            }
            else
            {
                this.Children.Remove(property);
            }
        }
Пример #2
0
        private bool TryCreateChildNode(int index, out IUnsubscriber <IChildNode <ChangeTrackerNode> > result)
        {
            var value = this.SourceList.ElementAtOrMissing(index);

            if (value == PaddedPairs.MissingItem)
            {
                result = null;
                return(false);
            }

            IRefCounted <ChangeTrackerNode> node;

            if (TryGetOrCreate(value, this.Settings, false, out node))
            {
                using (node)
                {
                    var indexNode = ChildNodes <ChangeTrackerNode> .CreateChildNode(this, node.Value, index);

                    indexNode.Changed += this.OnChildNodeChanged;
                    result             = indexNode.UnsubscribeAndDispose(n => n.Changed -= this.OnChildNodeChanged);
                    return(true);
                }
            }

            result = null;
            return(false);
        }
    private bool FlipRightToLeft(int newIndex)
    {
        if (m_isFlipping)
        {
            return(false);
        }

        m_isFlipping = true;
        IUnsubscriber inputBlocker = MainRaycastHelper.Singleton.BlockPageInput();

        m_pagePairs[m_pageIndex].DisableRaycasters();

        m_pagePairs[newIndex].SetCameraRenderTargets(m_bufferLeft, m_bufferRight);
        m_pagePairs[newIndex].EnableCameras();
        m_pagePairs[newIndex].EnableRaycasters();

        animatedPageMaterial.SetTexture("_LeftPageImage", m_bufferLeft);
        animatedPageMaterial.SetTexture("_RightPageImage", m_currentRight);

        // TODO: This should always return true. Check to make sure.
        animatedPage.FlipRightToLeft(() =>
        {
            FinishRightToLeftFlip(newIndex);
            inputBlocker.Unsubscribe();
        });

        // Do this after the animated page is made active.
        staticPageMaterial.SetTexture("_RightPageImage", m_bufferRight);

        return(true);
    }
Пример #4
0
 public Worker(IMessageVisitorFactory msgVisitorFactory, Func <TIn, TOut> funWork, Func <ISharedPipe <IMessage> > pipeFactory, bool shouldStopOnError)
 {
     _funWork             = funWork;
     _msgVisitor          = msgVisitorFactory.Create(this);
     OnEndOfStream       += OnEndOfStreamHandler;
     (_toReader, _writer) = pipeFactory().GetReaderWriterCouple();
     // Dispose handler
     _unsubscriber = new Unsubscriber();
     // unsubscribe the event on dispose
     _unsubscriber.RegisterSubscription(() => OnEndOfStream -= OnEndOfStreamHandler);
 }
 public void AddListenerToRemoveLater(Type type, IUnsubscriber unsubscriber)
 {
     lock (_lock)
     {
         if (!AllDisposers.ContainsKey(type))
         {
             AllDisposers.Add(type, new List<IUnsubscriber>());
         }
         AllDisposers[type].Add(unsubscriber);
     }
 }
Пример #6
0
        public void PubSubUnsubscribe()
        {
            Channel <string>        channel = new Channel <string>();
            SynchronousCommandQueue queue   = new SynchronousCommandQueue();
            bool            received        = false;
            Action <string> onReceive       = delegate(string data)
            {
                Assert.AreEqual("hello", data);
                received = true;
            };
            IUnsubscriber unsub = channel.Subscribe(queue, onReceive);

            Assert.IsTrue(channel.Publish("hello"));
            Assert.IsTrue(received);
            unsub.Dispose();
            Assert.IsFalse(channel.Publish("hello"));
            unsub.Dispose();
        }
Пример #7
0
 internal void SetValue(PropertyInfo property, IUnsubscriber <IChildNode <T> > childNode)
 {
     if (childNode == null)
     {
         this.Remove(property);
     }
     else
     {
         Debug.Assert(childNode.Value is PropertyNode, "childNode.Value is PropertyNode");
         lock (this.nodes)
         {
             var index = this.IndexOf(property);
             if (index < 0)
             {
                 this.nodes.Add(childNode);
             }
             else
             {
                 this.nodes[index].Dispose();
                 this.nodes[index] = childNode;
             }
         }
     }
 }
Пример #8
0
 internal void SetValue(int index, IUnsubscriber <IChildNode <T> > childNode)
 {
     if (childNode == null)
     {
         this.Remove(index);
     }
     else
     {
         Debug.Assert(childNode.Value is IndexNode, "childNode.Value is IndexNode");
         lock (this.nodes)
         {
             var indexOf = this.IndexOf(index);
             if (indexOf < 0)
             {
                 this.Insert(index, childNode);
             }
             else
             {
                 this.nodes[indexOf].Dispose();
                 this.nodes[indexOf] = childNode;
             }
         }
     }
 }
Пример #9
0
            internal void Insert(int index, IUnsubscriber <IChildNode <T> > childNode)
            {
                if (childNode == null)
                {
                    this.Remove(index);
                }
                else
                {
                    Debug.Assert(childNode.Value is IndexNode, "childNode.Value is IndexNode");
                    lock (this.nodes)
                    {
                        var indexOf     = this.IndexOf(index);
                        var insertIndex = indexOf < 0
                                              ? ~indexOf
                                              : indexOf;
                        for (var j = insertIndex; j < this.nodes.Count; j++)
                        {
                            ((IndexNode)this.nodes[j].Value).Index++;
                        }

                        this.nodes.Insert(insertIndex, childNode);
                    }
                }
            }
Пример #10
0
 public void Add(IUnsubscriber unsub)
 {
     mUnsubscribers.Add(unsub);
 }
Пример #11
0
 internal void Replace(int index, IUnsubscriber <IChildNode <T> > childNode)
 {
     this.indexNodes.SetValue(index, childNode);
 }
Пример #12
0
 internal void Insert(int index, IUnsubscriber <IChildNode <T> > childNode)
 {
     this.indexNodes.Insert(index, childNode);
 }
Пример #13
0
 internal void SetValue(PropertyInfo property, IUnsubscriber <IChildNode <T> > childNode)
 {
     this.propertyNodes.SetValue(property, childNode);
 }