StateManagedCollection.SetDirtyObject(Object) 메서드

정의

파생 클래스에서 재정의되는 경우 변경 정보만 기록하는 대신 컬렉션에 포함된 상태를 보고 상태를 기록하도록 지시 object 합니다.

protected:
 abstract void SetDirtyObject(System::Object ^ o);
protected abstract void SetDirtyObject(object o);
abstract member SetDirtyObject : obj -> unit
Protected MustOverride Sub SetDirtyObject (o As Object)

매개 변수

o
Object

IStateManager 자체적으로 완전히 직렬화해야 합니다.

예제

다음 코드 예제에서는 강력한 형식 StateManagedCollection 의 클래스가 추상 SetDirtyObject 메서드를 구현하는 방법을 보여 줍니다. 개체 CycleCollectionStateBag 사용하여 뷰 상태 정보를 저장하고 단순히 개체의 SetDirty 메서드에 호출을 StateBag 위임합니다. 이 코드 예제는 클래스에 제공된 더 큰 예제의 StateManagedCollection 일부입니다.

//////////////////////////////////////////////////////////////
//
// 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 strongly typed CycleCollection class is a collection
' that contains Cycle class instances, which implement the
' IStateManager interface.
'
'////////////////////////////////////////////////////////////
<AspNetHostingPermission(SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
               Public NotInheritable Class CycleCollection
    Inherits StateManagedCollection

    Private Shared _typesOfCycles() As Type = _
        {GetType(Bicycle), GetType(Tricycle)}

    Protected Overrides Function CreateKnownType(ByVal index As Integer) As Object
        Select Case index
            Case 0
                Return New Bicycle()
            Case 1
                Return New Tricycle()
            Case Else
                Throw New ArgumentOutOfRangeException("Unknown Type")
        End Select

    End Function


    Protected Overrides Function GetKnownTypes() As Type()
        Return _typesOfCycles

    End Function


    Protected Overrides Sub SetDirtyObject(ByVal o As Object)
        CType(o, Cycle).SetDirty()

    End Sub
End Class

설명

메서드는 SetDirtyObject 내부적으로 , IStateManager.SaveViewStateIList.Add 메서드에 IList.Insert의해 호출됩니다.

적용 대상

추가 정보