System.Web.UI.Control.SaveViewStateRecursive C# (CSharp) Method

SaveViewStateRecursive() private method

private SaveViewStateRecursive ( ) : object
return object
		internal object SaveViewStateRecursive ()
		{
			TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
#if MONO_TRACE
			string type_name = null;
			if (trace != null) {
				type_name = GetType ().Name;
				trace.Write ("control", String.Concat ("SaveViewStateRecursive ", _userId, " ", type_name));
			}
#endif

			ArrayList controlStates = null;
			bool byId = LoadViewStateByID;
			if (HasControls ()) {
				int len = _controls != null ? _controls.Count : 0;
				for (int i = 0; i < len; i++) {
					Control ctrl = _controls [i];
					object ctrlState = ctrl.SaveViewStateRecursive ();
					if (ctrlState == null)
						continue;

					if (controlStates == null)
						controlStates = new ArrayList ();
					if (byId) {
						ctrl.EnsureID ();
						controlStates.Add (new Pair (ctrl.ID, ctrlState));
					} else
						controlStates.Add (new Pair (i, ctrlState));
				}
			}

			object thisAdapterViewState = null;
			if (Adapter != null)
				thisAdapterViewState = Adapter.SaveAdapterViewState ();

			object thisState = null;

			if (IsViewStateEnabled)
				thisState = SaveViewState ();

			if (thisState == null && controlStates == null) {
				if (trace != null) {
#if MONO_TRACE
					trace.Write ("control", "End SaveViewStateRecursive " + _userId + " " + type_name + " saved nothing");
#endif
					trace.SaveViewState (this, null);
				}
				return null;
			}

			if (trace != null) {
#if MONO_TRACE
				trace.Write ("control", "End SaveViewStateRecursive " + _userId + " " + type_name + " saved a Triplet");
#endif
				trace.SaveViewState (this, thisState);
			}
			thisState = new object[] { thisState, thisAdapterViewState };
			return new Pair (thisState, controlStates);
		}