ContextStackとは? わかりやすく解説

ContextStack クラス

入れ子のシリアライザで情報使用できるように、シリアライザによって使用するスタック オブジェクト提供します

名前空間: System.ComponentModel.Design.Serialization
アセンブリ: System (system.dll 内)
構文構文

Public NotInheritable Class
 ContextStack
public sealed class ContextStack
public ref class ContextStack sealed
public final class ContextStack
public final class ContextStack
解説解説

一部のシリアライザでは、オブジェクトの状態を一貫して正しく維持するために、オブジェクトコンテキスト情報が必要です。ContextStack クラス使用すると、シリアル化するオブジェクトコンテキスト データを、シリアライザによって、他のシリアライザからアクセスできるスタック設定できますContext プロパティの値は、シリアライザの使用について情報共有するために IDesignerSerializationManager によって提供されます。

デザイン ドキュメントシリアル化するプロセスは、多階層入れ子構成される場合ありますオブジェクトの状態を正しく永続化するには、各入れ子レベルオブジェクトコンテキスト情報が必要です。このような状況では、コンテキスト スタック使用すると便利です。シリアライザは、入れ子のシリアライザを呼び出す前にコンテキスト オブジェクトスタック設定できますオブジェクト設定したシリアライザは、入れ子のシリアライザへの呼び出し対す戻り値返され後でスタック設定された各オブジェクト削除する必要があります

通常スタック上のオブジェクトには、シリアル化されている現在のオブジェクトコンテキストについての情報格納されます。親シリアライザは、次にシリアル化されるオブジェクトについてコンテキスト情報スタック追加し適切なシリアライザを呼び出し、そのシリアライザがオブジェクトへの実行完了した時点スタックからコンテキスト情報削除します。このスタックでどのオブジェクトプッシュされるかは、各シリアライザの実装によって異なります

たとえば、Enabled というプロパティを持つオブジェクトBoolean データ型があるとします。シリアライザがこの値をデータ ストリーム書き込む場合コンテキストまたはプロパティの型も含める必要が生じ場合あります。しかし、シリアライザに対してBoolean 値の書き込みだけが命令されているため、シリアライザは必要な情報取得できません。シリアライザにこの情報提供するために、親シリアライザは、コンテキスト スタック上で Enabled プロパティを指す PropertyDescriptor をプッシュできます

メモメモ

このクラス適用される HostProtectionAttribute 属性Resources プロパティの値は、SharedState です。HostProtectionAttribute は、デスクトップ アプリケーション (一般的にはアイコンダブルクリックコマンド入力、またはブラウザURL入力して起動するアプリケーション) には影響しません。詳細については、HostProtectionAttribute クラストピックまたは「SQL Server プログラミングホスト保護属性」を参照してください

使用例使用例

ContextStack使用して 10 個の値をプッシュし、その後削除するコード例次に示します

Imports System
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.ComponentModel.Design.Serialization

Module ContextStackExample

    Sub Main()
        ' Create a ContextStack.
        Dim stack As New
 ContextStack

        ' Push ten items on to the stack and output the value of each.
        Dim number As Integer
        For number = 0 To 9
            Console.WriteLine(("Value pushed to stack: "
 + number.ToString()))
            stack.Push(number)
        Next number

        ' Pop each item off the stack.        
        Dim item As Object
 = stack.Pop()
        While Not item Is
 Nothing
            Console.WriteLine(("Value popped from stack: "
 + item.ToString()))
            item = stack.Pop()
        End While
    End Sub

End Module
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using System.Windows.Forms;

namespace ContextStackExample
{
    class ContextStackExample
    {
        [STAThread]
        static void Main(string[]
 args)
        {            
            // Create a ContextStack.
            ContextStack stack = new ContextStack();
            
            // Push ten items on to the stack and output the value of
 each.
            for( int number = 0; number <
 10; number ++ )
            {
                Console.WriteLine( "Value pushed to stack: "+number.ToString()
 );
                stack.Push( number );
            }

            // Pop each item off the stack.
            object item = null;
            while( (item = stack.Pop()) != null
 )
                Console.WriteLine( "Value popped from stack: "+item.ToString()
 );
        }
    }
}
#using <System.Windows.Forms.dll>
#using <System.dll>

using namespace System;
using namespace System::ComponentModel;
using namespace System::ComponentModel::Design;
using namespace System::ComponentModel::Design::Serialization;
using namespace System::Windows::Forms;

int main()
{
   // Create a ContextStack.
   ContextStack^ stack = gcnew ContextStack;
   
   // Push ten items on to the stack and output the value of each.
   for ( int number = 0; number < 10; number++
 )
   {
      Console::WriteLine( "Value pushed to stack: {0}", number );
      stack->Push( number );
   }
   
   // Pop each item off the stack.
   Object^ item = nullptr;
   while ( (item = stack->Pop()) != 0 )
      Console::WriteLine( "Value popped from stack: {0}", item );
}
.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
  System.ComponentModel.Design.Serialization.ContextStack
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ContextStack メンバ
System.ComponentModel.Design.Serialization 名前空間
IDesignerSerializationManager

ContextStack コンストラクタ


ContextStack プロパティ


ContextStack メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

ContextStack クラス
System.ComponentModel.Design.Serialization 名前空間
IDesignerSerializationManager

ContextStack メンバ

入れ子のシリアライザで情報使用できるように、シリアライザによって使用するスタック オブジェクト提供します

ContextStack データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド ContextStack ContextStack クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

ContextStack クラス
System.ComponentModel.Design.Serialization 名前空間
IDesignerSerializationManager


このページでは「.NET Framework クラス ライブラリ リファレンス」からContextStackを検索した結果を表示しています。
Weblioに収録されているすべての辞書からContextStackを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からContextStack を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ContextStack」の関連用語

ContextStackのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ContextStackのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS