Exemple #1
0
        private void RecursiveRestoreDataGridContextsState(DataGridContext dataGridContext)
        {
            WeakDataGridContextKey weakDataGridContextKey = new WeakDataGridContextKey(dataGridContext);

            SaveRestoreDataGridContextStateVisitor saveRestoreDataGridContextStateVisitor;

            if (m_dataGridContextsStateDictionary.TryGetValue(weakDataGridContextKey, out saveRestoreDataGridContextStateVisitor))
            {
                try
                {
                    saveRestoreDataGridContextStateVisitor.RestoreState(dataGridContext as IDataGridContextVisitable);
                }
                finally
                {
                    m_dataGridContextsStateDictionary.Remove(weakDataGridContextKey);
                }
            }

            IEnumerable <DataGridContext> subDataGridContexts = dataGridContext.GetChildContexts();

            foreach (DataGridContext subDataGridContext in subDataGridContexts)
            {
                this.RecursiveRestoreDataGridContextsState(subDataGridContext);
            }
        }
        public override bool Equals(object obj)
        {
            WeakDataGridContextKey weakDataGridContextKey = obj as WeakDataGridContextKey;

            if (weakDataGridContextKey == null)
            {
                return(false);
            }

            if (m_cachedHash != weakDataGridContextKey.m_cachedHash)
            {
                return(false);
            }

            if (m_sourceDetailConfigurationRelationName != weakDataGridContextKey.m_sourceDetailConfigurationRelationName)
            {
                return(false);
            }

            int dataGridContextStatusKeyLength = (weakDataGridContextKey.m_weakItemsTree == null) ? 0 : weakDataGridContextKey.m_weakItemsTree.Length;
            int myLength = (m_weakItemsTree == null) ? 0 : m_weakItemsTree.Length;

            if (myLength != dataGridContextStatusKeyLength)
            {
                return(false);
            }

            for (int i = 0; i < dataGridContextStatusKeyLength; i++)
            {
                object sourceItem = m_weakItemsTree[i].Target;
                object targetItem = weakDataGridContextKey.m_weakItemsTree[i].Target;

                if (!object.Equals(sourceItem, targetItem))
                {
                    return(false);
                }
            }

            return(true);
        }