|
Dieser Artikel wurde manuell übersetzt. Bewegen Sie den Mauszeiger über die Sätze im Artikel, um den Originaltext anzuzeigen.
|
Übersetzung
Original
|
StateManagedCollection-Klasse
Assembly: System.Web (in System.Web.dll)
Der StateManagedCollection-Typ macht die folgenden Member verfügbar.
| Name | Beschreibung | |
|---|---|---|
![]() | StateManagedCollection |
| Name | Beschreibung | |
|---|---|---|
![]() | Count |
| Name | Beschreibung | |
|---|---|---|
![]() | Clear | |
![]() | CopyTo | |
![]() | CreateKnownType | |
![]() | Equals(Object) | |
![]() | Finalize | |
![]() | GetEnumerator | |
![]() | GetHashCode | |
![]() | GetKnownTypes | |
![]() | GetType | |
![]() | MemberwiseClone | |
![]() | OnClear | |
![]() | OnClearComplete | |
![]() | OnInsert | |
![]() | OnInsertComplete | |
![]() | OnRemove | |
![]() | OnRemoveComplete | |
![]() | OnValidate | |
![]() | SetDirty | |
![]() | SetDirtyObject | |
![]() | ToString |
| Name | Beschreibung | |
|---|---|---|
![]() | AsParallel | |
![]() | AsQueryable | |
![]() | Cast<TResult> | |
![]() | OfType<TResult> |
| Name | Beschreibung | |
|---|---|---|
![]() ![]() | ICollection.Count | Infrastruktur. |
![]() ![]() | ICollection.IsSynchronized | Infrastruktur. |
![]() ![]() | ICollection.SyncRoot | Infrastruktur. |
![]() ![]() | IEnumerable.GetEnumerator | Infrastruktur. |
![]() ![]() | IList.Add | |
![]() ![]() | IList.Clear | Infrastruktur. |
![]() ![]() | IList.Contains | |
![]() ![]() | IList.IndexOf | |
![]() ![]() | IList.Insert | |
![]() ![]() | IList.IsFixedSize | Infrastruktur. |
![]() ![]() | IList.IsReadOnly | Infrastruktur. |
![]() ![]() | IList.Item | Infrastruktur. |
![]() ![]() | IList.Remove | |
![]() ![]() | IList.RemoveAt | |
![]() ![]() | IStateManager.IsTrackingViewState | |
![]() ![]() | IStateManager.LoadViewState | |
![]() ![]() | IStateManager.SaveViewState | |
![]() ![]() | IStateManager.TrackViewState |
Sicherheitshinweis |
|---|
|
namespace Samples.AspNet.CS.Controls { using System; using System.Security.Permissions; using System.Collections; using System.ComponentModel; using System.Drawing; using System.Web; using System.Web.UI; ////////////////////////////////////////////////////////////// // // The strongly typed CycleCollection class is a collection // that contains Cycle class instances, which implement the // IStateManager interface. // ////////////////////////////////////////////////////////////// [AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)] public sealed class CycleCollection : StateManagedCollection { private static readonly Type[] _typesOfCycles = new Type[] { typeof(Bicycle), typeof(Tricycle) }; protected override object CreateKnownType(int index) { switch(index) { case 0: return new Bicycle(); case 1: return new Tricycle(); default: throw new ArgumentOutOfRangeException("Unknown Type"); } } protected override Type[] GetKnownTypes() { return _typesOfCycles; } protected override void SetDirtyObject(object o) { ((Cycle)o).SetDirty(); } } ////////////////////////////////////////////////////////////// // // The abstract Cycle class represents bicycles and tricycles. // ////////////////////////////////////////////////////////////// public abstract class Cycle : IStateManager { protected internal Cycle(int numWheels) : this(numWheels, "Red"){ } protected internal Cycle(int numWheels, String color) { numberOfWheels = numWheels; CycleColor = color; } private int numberOfWheels = 0; public int NumberOfWheels { get { return numberOfWheels; } } public string CycleColor { get { object o = ViewState["Color"]; return (null == o) ? String.Empty : o.ToString() ; } set { ViewState["Color"] = value; } } internal void SetDirty() { ViewState.SetDirty(true); } // Because Cycle does not derive from Control, it does not // have access to an inherited view state StateBag object. private StateBag viewState; private StateBag ViewState { get { if (viewState == null) { viewState = new StateBag(false); if (isTrackingViewState) { ((IStateManager)viewState).TrackViewState(); } } return viewState; } } // The IStateManager implementation. private bool isTrackingViewState; bool IStateManager.IsTrackingViewState { get { return isTrackingViewState; } } void IStateManager.LoadViewState(object savedState) { object[] cycleState = (object[]) savedState; // In SaveViewState, an array of one element is created. // Therefore, if the array passed to LoadViewState has // more than one element, it is invalid. if (cycleState.Length != 1) { throw new ArgumentException("Invalid Cycle View State"); } // Call LoadViewState on the StateBag object. ((IStateManager)ViewState).LoadViewState(cycleState[0]); } // Save the view state by calling the StateBag's SaveViewState // method. object IStateManager.SaveViewState() { object[] cycleState = new object[1]; if (viewState != null) { cycleState[0] = ((IStateManager)viewState).SaveViewState(); } return cycleState; } // Begin tracking view state. Check the private variable, because // if the view state has not been accessed or set, then it is not // being used and there is no reason to store any view state. void IStateManager.TrackViewState() { isTrackingViewState = true; if (viewState != null) { ((IStateManager)viewState).TrackViewState(); } } } public sealed class Bicycle : Cycle { // Create a red Cycle with two wheels. public Bicycle() : base(2) {} } public sealed class Tricycle : Cycle { // Create a red Cycle with three wheels. public Tricycle() : base(3) {} } }
Windows 7, Windows Vista SP1 oder höher, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core wird nicht unterstützt), Windows Server 2008 R2 (Server Core wird mit SP1 oder höher unterstützt), Windows Server 2003 SP2
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen für .NET Framework.
System.Web.UI.StateManagedCollection
System.Web.UI.WebControls.DataControlFieldCollection
System.Web.UI.WebControls.DataPagerFieldCollection
System.Web.UI.WebControls.Expressions.DataSourceExpressionCollection
System.Web.UI.WebControls.HotSpotCollection
System.Web.UI.WebControls.MenuItemBindingCollection
System.Web.UI.WebControls.MenuItemStyleCollection
System.Web.UI.WebControls.ParameterCollection
System.Web.UI.WebControls.StyleCollection
System.Web.UI.WebControls.SubMenuStyleCollection
System.Web.UI.WebControls.TreeNodeBindingCollection
System.Web.UI.WebControls.TreeNodeStyleCollection

