Exemplo n.º 1
0
        /// <summary>
        /// Sets the entire view state for the collection and everything under it to dirty
        /// </summary>
        internal virtual void SetViewStateDirty()
        {
            if (!((IStateManager)this).IsTrackingViewState)
            {
                ((IStateManager)this).TrackViewState();
            }

            Actions.Clear();
            Action action = new Action();

            action.ActionType = ActionType.Clear;
            Actions.Add(action);
            for (int index = 0; index < Count; index++)
            {
                BaseChildNode item = (BaseChildNode)List[index];

                action            = new Action();
                action.ActionType = ActionType.Insert;
                action.Index      = index;
                action.NodeType   = item.GetType().FullName;

                Actions.Add(action);

                item.SetViewStateDirty();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns>A new object that is a copy of this instance.</returns>
        public virtual object Clone()
        {
            BaseChildNode copy = (BaseChildNode)Activator.CreateInstance(this.GetType(), BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.CreateInstance, null, null, null);

            // Merge in the properties from this object into the copy
            copy._IsTrackingViewState = this._IsTrackingViewState;

            if (this._ViewState != null)
            {
                StateBag viewState = copy.ViewState;
                foreach (string key in this.ViewState.Keys)
                {
                    object item = this.ViewState[key];
                    if (item is ICloneable)
                    {
                        item = ((ICloneable)item).Clone();
                    }

                    viewState[key] = item;
                }
            }

            return(copy);
        }