Пример #1
0
        public PersistentData <T> GetData(ViewNode viewNode)
        {
            List <PersistentData <T> > persistentDatas;
            PersistentData <T>         persistentDatum;

            if (this.dictionary.TryGetValue(viewNode.DocumentNode, out persistentDatas))
            {
                DocumentNodePath correspondingNodePath = this.viewNodeManager.GetCorrespondingNodePath(viewNode);
                if (correspondingNodePath == null)
                {
                    return(null);
                }
                List <PersistentData <T> > .Enumerator enumerator = persistentDatas.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        PersistentData <T> current = enumerator.Current;
                        if (!PersistentViewNodeDictionary <T> .CompareNodePaths(current.Target, correspondingNodePath))
                        {
                            continue;
                        }
                        persistentDatum = current;
                        return(persistentDatum);
                    }
                    return(null);
                }
                finally
                {
                    ((IDisposable)enumerator).Dispose();
                }
                return(persistentDatum);
            }
            return(null);
        }
Пример #2
0
        public void SetData(ViewNode target, DocumentNode innerSource, T data)
        {
            List <PersistentData <T> > persistentDatas;
            DocumentNodePath           correspondingNodePath = this.viewNodeManager.GetCorrespondingNodePath(target);
            PersistentData <T>         persistentDatum       = new PersistentData <T>(data, correspondingNodePath, innerSource);

            if (!this.dictionary.TryGetValue(target.DocumentNode, out persistentDatas))
            {
                persistentDatas = new List <PersistentData <T> >()
                {
                    persistentDatum
                };
                this.dictionary[target.DocumentNode] = persistentDatas;
                PersistentViewNodeDictionary <T> persistentViewNodeDictionary = this;
                persistentViewNodeDictionary.count = persistentViewNodeDictionary.count + 1;
                return;
            }
            for (int i = 0; i < persistentDatas.Count; i++)
            {
                if (PersistentViewNodeDictionary <T> .CompareNodePaths(persistentDatas[i].Target, correspondingNodePath))
                {
                    persistentDatas[i] = persistentDatum;
                    return;
                }
            }
            persistentDatas.Add(persistentDatum);
        }
Пример #3
0
 private void Remove(DocumentNode documentNode)
 {
     if (this.count > 0 && this.dictionary.Remove(documentNode))
     {
         PersistentViewNodeDictionary <T> persistentViewNodeDictionary = this;
         persistentViewNodeDictionary.count = persistentViewNodeDictionary.count - 1;
     }
 }
Пример #4
0
        public void Remove(ViewNode viewNode)
        {
            List <PersistentData <T> > persistentDatas;

            if (this.count > 0 && this.dictionary.TryGetValue(viewNode.DocumentNode, out persistentDatas))
            {
                DocumentNodePath correspondingNodePath = this.viewNodeManager.GetCorrespondingNodePath(viewNode);
                persistentDatas.RemoveAll((PersistentData <T> item) => PersistentViewNodeDictionary <T> .CompareNodePaths(item.Target, correspondingNodePath));
                if (persistentDatas.Count == 0)
                {
                    this.Remove(viewNode.DocumentNode);
                }
            }
        }