IsolatedStorageContainment 列挙体
アセンブリ: mscorlib (mscorlib.dll 内)

<SerializableAttribute> _ <ComVisibleAttribute(True)> _ Public Enumeration IsolatedStorageContainment


分離ストレージは、証拠を使用して、アプリケーションまたはコンポーネントで使用する一意のストレージ エリアを決定します。アセンブリの ID によって、そのアセンブリが使用する仮想ファイル システムのルートは一意になります。このため、多くのアプリケーションとコンポーネントは、ファイル システムやレジストリなどの共通リソースを共有するのではなく、それぞれに独自のファイル領域が割り当てられます。
分離ストレージを割り当てる場合は、4 つの基本分離スコープを使用します。
-
User - コードでは、常に現在のユーザーに従ってスコープが割り当てられます。異なるユーザーが実行すると、同じアセンブリが異なるストアを受け取ります。
-
Machine - コードでは、コンピュータに従ってスコープが割り当てられます。同じコンピュータ上で異なるユーザーが実行すると、同じアセンブリは同じストアを受け取ります。
-
Assembly - コードは、厳密な名前 (たとえば Microsoft.Office.* または Microsoft.Office.Word)、発行元 (公開キーに基づく)、URL (たとえば http://www.fourthcoffee.com/process/grind.htm)、サイト、またはゾーンによって暗号を使用して識別されます。
-
Domain - コードは、アプリケーション ドメインと関連付けた証拠に基づいて識別されます。Web アプリケーション ID は、サイトの URL、Web ページの URL、サイト、またはゾーンから派生します。ローカル コード ID は、アプリケーション ディレクトリ パスに基づきます。
URL、サイト、およびゾーンの定義については、UrlIdentityPermission、SiteIdentityPermission、ZoneIdentityPermission の各トピックを参照してください。
これらの ID は共にグループ化されます。この場合、ID は必要な分離ストレージが作成されるまで相互に適用されます。有効なグループ化は、User+Assembly と User+Assembly+Domain です。この ID のグループ化は、さまざまなアプリケーションで役に立ちます。
ドメイン、ユーザー、およびアセンブリごとにデータを格納する場合、データはそのアセンブリ内のコードだけがデータにアクセスできるという点でプライベートです。データ ストアが内部で実行されるアプリケーションによっても、そのストアは分離され、これによってアセンブリがデータを他のアプリケーションに公開することによって生じる可能性があるリークが回避されます。
アセンブリとユーザーごとの分離は、複数のアプリケーションにわたって適用されるユーザー データで使用できます。たとえば、これにはライセンス情報、またはアプリケーションに依存しないユーザーの個人情報 (名前、資格情報など) があります。
IsolatedStorageContainment は、アプリケーションが分離ストレージを使用できるかどうかと、使用できる場合は、使用を許可されている ID の組み合わせを決定するフラグを公開します。これは、アプリケーションがユーザーと共に移動する場所に情報を保存できるかどうかも決定します。Windows ローミング ユーザー プロファイルまたはフォルダ リダイレクトを構成する必要があります。

このアセンブリのコードに IsolatedStoragePermission が必要なことを CLR に伝える方法を次のコード例に示します。この例では、分離ストレージの書き込みと読み取りを行う方法も示します。
using System; using System.Security.Permissions; using System.IO.IsolatedStorage; using System.IO; // Notify the CLR to grant this assembly the IsolatedStorageFilePermission. // This allows the assembly to work with storage files that are isolated // by user and assembly. [assembly: IsolatedStorageFilePermission(SecurityAction.RequestMinimum, UsageAllowed = IsolatedStorageContainment.AssemblyIsolationByUser)] public sealed class App { static void Main() { // Attempt to create a storage file that is isolated by user and assembly. // IsolatedStorageFilePermission granted to the attribute at the top of this file // allows CLR to load this assembly and execution of this statement. using (Stream s = new IsolatedStorageFileStream("AssemblyData", FileMode.Create, IsolatedStorageFile.GetUserStoreForAssembly())) { // Write some data out to the isolated file. using (StreamWriter sw = new StreamWriter(s)) { sw.Write("This is some test data."); } } // Attempt to open the file that was previously created. using (Stream s = new IsolatedStorageFileStream("AssemblyData", FileMode.Open, IsolatedStorageFile.GetUserStoreForAssembly())) { // Read the data from the file and display it. using (StreamReader sr = new StreamReader(s)) { Console.WriteLine(sr.ReadLine()); } } } } // This code produces the following output. // // Some test data.
using namespace System; using namespace System::Security; using namespace System::Security::Permissions; using namespace System::IO::IsolatedStorage; using namespace System::IO; // Notify the CLR to grant this assembly the IsolatedStorage- // FilePermission. This allows the assembly to work with storage // files that are isolated by user and assembly. [assembly: IsolatedStorageFilePermission( SecurityAction::RequestMinimum, UsageAllowed = IsolatedStorageContainment::AssemblyIsolationByUser)]; int main() { try { // Attempt to create a storage file that is isolated by // user and assembly. IsolatedStorageFilePermission // granted to the attribute at the top of this file // allows CLR to load this assembly and execution of this // statement. Stream^ fileCreateStream = gcnew IsolatedStorageFileStream( "AssemblyData", FileMode::Create, IsolatedStorageFile::GetUserStoreForAssembly()); StreamWriter^ streamWriter = gcnew StreamWriter( fileCreateStream); try { // Write some data out to the isolated file. streamWriter->Write("This is some test data."); streamWriter->Close(); } finally { delete fileCreateStream; delete streamWriter; } } catch (IOException^ ex) { Console::WriteLine(ex->Message); } try { Stream^ fileOpenStream = gcnew IsolatedStorageFileStream( "AssemblyData", FileMode::Open, IsolatedStorageFile::GetUserStoreForAssembly()); // Attempt to open the file that was previously created. StreamReader^ streamReader = gcnew StreamReader( fileOpenStream); try { // Read the data from the file and display it. Console::WriteLine(streamReader->ReadLine()); streamReader->Close(); } finally { delete fileOpenStream; delete streamReader; } } catch (FileNotFoundException^ ex) { Console::WriteLine(ex->Message); } catch (IOException^ ex) { Console::WriteLine(ex->Message); } } // This code produces the following output. // // This is some test data.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からIsolatedStorageContainment 列挙体を検索する場合は、下記のリンクをクリックしてください。

- IsolatedStorageContainment 列挙体のページへのリンク