Share via


IsolatedStorageFile.GetStore Metode

Definisi

Mendapatkan penyimpanan terisolasi yang sesuai dengan domain aplikasi yang diberikan dan objek bukti perakitan dan cakupan penyimpanan yang terisolasi.

Overload

GetStore(IsolatedStorageScope, Object)

Mendapatkan penyimpanan terisolasi yang sesuai dengan identitas aplikasi yang diberikan.

GetStore(IsolatedStorageScope, Type)

Mendapatkan penyimpanan terisolasi yang sesuai dengan cakupan isolasi dan objek identitas aplikasi.

GetStore(IsolatedStorageScope, Object, Object)

Mendapatkan penyimpanan terisolasi yang sesuai dengan domain aplikasi yang diberikan dan objek bukti perakitan.

GetStore(IsolatedStorageScope, Type, Type)

Mendapatkan penyimpanan terisolasi yang sesuai dengan cakupan penyimpanan terisolasi mengingat domain aplikasi dan jenis bukti perakitan.

GetStore(IsolatedStorageScope, Evidence, Type, Evidence, Type)

Mendapatkan penyimpanan terisolasi yang sesuai dengan domain aplikasi yang diberikan dan objek dan jenis bukti perakitan.

GetStore(IsolatedStorageScope, Object)

Sumber:
IsolatedStorageFile.cs
Sumber:
IsolatedStorageFile.cs
Sumber:
IsolatedStorageFile.cs

Mendapatkan penyimpanan terisolasi yang sesuai dengan identitas aplikasi yang diberikan.

public:
 static System::IO::IsolatedStorage::IsolatedStorageFile ^ GetStore(System::IO::IsolatedStorage::IsolatedStorageScope scope, System::Object ^ applicationIdentity);
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore (System.IO.IsolatedStorage.IsolatedStorageScope scope, object? applicationIdentity);
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore (System.IO.IsolatedStorage.IsolatedStorageScope scope, object applicationIdentity);
static member GetStore : System.IO.IsolatedStorage.IsolatedStorageScope * obj -> System.IO.IsolatedStorage.IsolatedStorageFile
Public Shared Function GetStore (scope As IsolatedStorageScope, applicationIdentity As Object) As IsolatedStorageFile

Parameter

scope
IsolatedStorageScope

Kombinasi bitwise dari nilai enumerasi.

applicationIdentity
Object

Objek yang berisi bukti untuk identitas aplikasi.

Mengembalikan

Objek yang mewakili parameter.

Pengecualian

Izin penyimpanan terisolasi yang memadai belum diberikan.

Identitas applicationIdentity belum diteruskan.

Tidak scope valid.

Lokasi penyimpanan terisolasi tidak dapat diinisialisasi.

-atau-

scope berisi nilai Applicationenumerasi , tetapi identitas aplikasi pemanggil tidak dapat ditentukan, karena ActivationContext untuk domain aplikasi saat ini dikembalikan null.

-atau-

scope berisi nilai Domain, tetapi izin untuk domain aplikasi tidak dapat ditentukan.

-atau-

scope berisi nilai Assembly, tetapi izin untuk rakitan panggilan tidak dapat ditentukan.

Keterangan

Catatan

scope Jika parameter adalah IsolatedStorageScope.Application dan domain aplikasi tempat assembly diinstal tidak memiliki IsolatedStorageFilePermission, GetStore metode akan mengembalikan IsolatedStorageFile objek tanpa kuota. Nantinya mencoba membuat IsolatedStorageFile objek menggunakan IsolatedStorageFile objek yang tidak memiliki kuota akan gagal dengan IsolatedStorageException.

Lihat juga

Berlaku untuk

GetStore(IsolatedStorageScope, Type)

Sumber:
IsolatedStorageFile.cs
Sumber:
IsolatedStorageFile.cs
Sumber:
IsolatedStorageFile.cs

Mendapatkan penyimpanan terisolasi yang sesuai dengan cakupan isolasi dan objek identitas aplikasi.

public:
 static System::IO::IsolatedStorage::IsolatedStorageFile ^ GetStore(System::IO::IsolatedStorage::IsolatedStorageScope scope, Type ^ applicationEvidenceType);
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore (System.IO.IsolatedStorage.IsolatedStorageScope scope, Type? applicationEvidenceType);
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore (System.IO.IsolatedStorage.IsolatedStorageScope scope, Type applicationEvidenceType);
static member GetStore : System.IO.IsolatedStorage.IsolatedStorageScope * Type -> System.IO.IsolatedStorage.IsolatedStorageFile
Public Shared Function GetStore (scope As IsolatedStorageScope, applicationEvidenceType As Type) As IsolatedStorageFile

Parameter

scope
IsolatedStorageScope

Kombinasi bitwise dari nilai enumerasi.

applicationEvidenceType
Type

Objek yang berisi identitas aplikasi.

Mengembalikan

Objek yang mewakili parameter.

Pengecualian

Izin penyimpanan terisolasi yang memadai belum diberikan.

Identitas applicationEvidence belum diteruskan.

Tidak scope valid.

Lokasi penyimpanan terisolasi tidak dapat diinisialisasi.

-atau-

scope berisi nilai Applicationenumerasi , tetapi identitas aplikasi pemanggil tidak dapat ditentukan, karena ActivationContext untuk domain aplikasi saat ini dikembalikan null.

-atau-

scope berisi nilai Domain, tetapi izin untuk domain aplikasi tidak dapat ditentukan.

-atau-

scope berisi nilai Assembly, tetapi izin untuk rakitan panggilan tidak dapat ditentukan.

Keterangan

Catatan

scope Jika parameter adalah Application dan domain aplikasi tempat assembly diinstal tidak memiliki IsolatedStorageFilePermission, GetStore metode akan mengembalikan IsolatedStorageFile objek tanpa kuota. Nantinya mencoba membuat IsolatedStorageFile objek menggunakan IsolatedStorageFile objek yang tidak memiliki kuota akan gagal dengan IsolatedStorageException.

Lihat juga

Berlaku untuk

GetStore(IsolatedStorageScope, Object, Object)

Sumber:
IsolatedStorageFile.cs
Sumber:
IsolatedStorageFile.cs
Sumber:
IsolatedStorageFile.cs

Mendapatkan penyimpanan terisolasi yang sesuai dengan domain aplikasi yang diberikan dan objek bukti perakitan.

public:
 static System::IO::IsolatedStorage::IsolatedStorageFile ^ GetStore(System::IO::IsolatedStorage::IsolatedStorageScope scope, System::Object ^ domainIdentity, System::Object ^ assemblyIdentity);
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore (System.IO.IsolatedStorage.IsolatedStorageScope scope, object? domainIdentity, object? assemblyIdentity);
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore (System.IO.IsolatedStorage.IsolatedStorageScope scope, object domainIdentity, object assemblyIdentity);
static member GetStore : System.IO.IsolatedStorage.IsolatedStorageScope * obj * obj -> System.IO.IsolatedStorage.IsolatedStorageFile
Public Shared Function GetStore (scope As IsolatedStorageScope, domainIdentity As Object, assemblyIdentity As Object) As IsolatedStorageFile

Parameter

scope
IsolatedStorageScope

Kombinasi bitwise dari nilai enumerasi.

domainIdentity
Object

Objek yang berisi bukti untuk identitas domain aplikasi.

assemblyIdentity
Object

Objek yang berisi bukti untuk identitas perakitan kode.

Mengembalikan

Objek yang mewakili parameter.

Pengecualian

Izin penyimpanan terisolasi yang memadai belum diberikan.

Baik domainIdentity maupun assemblyIdentity telah diteruskan. Ini memverifikasi bahwa konstruktor yang benar sedang digunakan.

-atau-

Baik domainIdentity atau assemblyIdentity adalah null.

Tidak scope valid.

Lokasi penyimpanan terisolasi tidak dapat diinisialisasi.

-atau-

scope berisi nilai Applicationenumerasi , tetapi identitas aplikasi pemanggil tidak dapat ditentukan, karena ActivationContext untuk domain aplikasi saat ini dikembalikan null.

-atau-

scope berisi nilai Domain, tetapi izin untuk domain aplikasi tidak dapat ditentukan.

-atau-

scope berisi nilai Assembly, tetapi izin untuk rakitan panggilan tidak dapat ditentukan.

Keterangan

Bentuk GetStore ini paling berguna untuk kode administratif yang perlu membuka toko seolah-olah itu adalah rakitan lain. Toko dibuka untuk bukti yang diberikan dan bukan untuk rakitan yang saat ini dijalankan.

Catatan

scope Jika parameter adalah Domain dan domain aplikasi tempat assembly diinstal tidak memiliki IsolatedStorageFilePermission, GetStore metode akan mengembalikan IsolatedStorageFile objek tanpa kuota. Nantinya mencoba membuat IsolatedStorageFile objek menggunakan IsolatedStorageFile objek yang tidak memiliki kuota akan gagal dengan IsolatedStorageException.

Lihat juga

Berlaku untuk

GetStore(IsolatedStorageScope, Type, Type)

Sumber:
IsolatedStorageFile.cs
Sumber:
IsolatedStorageFile.cs
Sumber:
IsolatedStorageFile.cs

Mendapatkan penyimpanan terisolasi yang sesuai dengan cakupan penyimpanan terisolasi mengingat domain aplikasi dan jenis bukti perakitan.

public:
 static System::IO::IsolatedStorage::IsolatedStorageFile ^ GetStore(System::IO::IsolatedStorage::IsolatedStorageScope scope, Type ^ domainEvidenceType, Type ^ assemblyEvidenceType);
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore (System.IO.IsolatedStorage.IsolatedStorageScope scope, Type? domainEvidenceType, Type? assemblyEvidenceType);
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore (System.IO.IsolatedStorage.IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType);
static member GetStore : System.IO.IsolatedStorage.IsolatedStorageScope * Type * Type -> System.IO.IsolatedStorage.IsolatedStorageFile
Public Shared Function GetStore (scope As IsolatedStorageScope, domainEvidenceType As Type, assemblyEvidenceType As Type) As IsolatedStorageFile

Parameter

scope
IsolatedStorageScope

Kombinasi bitwise dari nilai enumerasi.

domainEvidenceType
Type

Jenis Evidence yang dapat Anda pilih dari daftar Evidence yang ada di domain aplikasi panggilan. nullIsolatedStorage membiarkan objek memilih bukti.

assemblyEvidenceType
Type

Jenis Evidence yang dapat Anda pilih dari daftar Evidence yang ada di domain aplikasi panggilan. nullIsolatedStorage membiarkan objek memilih bukti.

Mengembalikan

Objek yang mewakili parameter.

Pengecualian

Izin penyimpanan terisolasi yang memadai belum diberikan.

Tidak scope valid.

Jenis bukti yang diberikan hilang dalam daftar bukti perakitan.

-atau-

Lokasi penyimpanan terisolasi tidak dapat diinisialisasi.

-atau-

scope berisi nilai Applicationenumerasi , tetapi identitas aplikasi pemanggil tidak dapat ditentukan, karena ActivationContext untuk domain aplikasi saat ini dikembalikan null.

-atau-

scope berisi nilai Domain, tetapi izin untuk domain aplikasi tidak dapat ditentukan.

-atau-

scope berisi Assembly, tetapi izin untuk rakitan panggilan tidak dapat ditentukan.

Contoh

Contoh kode berikut menunjukkan GetStore metode . Untuk konteks lengkap contoh ini, lihat IsolatedStorageFile gambaran umum.

// Retrieve an IsolatedStorageFile for the current Domain and Assembly.
IsolatedStorageFile^ isoFile = IsolatedStorageFile::GetStore( static_cast<IsolatedStorageScope>(IsolatedStorageScope::User | IsolatedStorageScope::Assembly | IsolatedStorageScope::Domain), (Type^)nullptr, nullptr );
IsolatedStorageFileStream^ isoStream = gcnew IsolatedStorageFileStream( this->userName,FileMode::Open,FileAccess::ReadWrite,isoFile );

// Retrieve an IsolatedStorageFile for the current Domain and Assembly.
IsolatedStorageFile isoFile =
    IsolatedStorageFile.GetStore(IsolatedStorageScope.User |
    IsolatedStorageScope.Assembly |
    IsolatedStorageScope.Domain,
    null,
    null);

IsolatedStorageFileStream isoStream =
    new IsolatedStorageFileStream("substituteUsername",
    System.IO.FileMode.Open,
    System.IO.FileAccess.Read,
     System.IO.FileShare.Read);
' Retrieve an IsolatedStorageFile for the current Domain and Assembly.
Dim isoFile As IsolatedStorageFile = _
    IsolatedStorageFile.GetStore(IsolatedStorageScope.User _
    Or IsolatedStorageScope.Assembly _
    Or IsolatedStorageScope.Domain, Nothing, Nothing)

Dim isoStream As New IsolatedStorageFileStream("substituteUsername", System.IO.FileMode.Open, _
    System.IO.FileAccess.Read, System.IO.FileShare.Read)

Keterangan

Ini adalah kelebihan beban GetStore kemungkinan besar akan dipanggil dari kode aplikasi.

Kelebihan beban GetStore ini membuka penyimpanan terisolasi untuk jenis bukti yang diteruskan.

Catatan

scope Jika parameter adalah Domain dan domain aplikasi tempat assembly diinstal tidak memiliki IsolatedStorageFilePermission, GetStore metode akan mengembalikan IsolatedStorageFile objek tanpa kuota. Nantinya mencoba membuat IsolatedStorageFile objek menggunakan IsolatedStorageFile objek yang tidak memiliki kuota akan gagal dengan IsolatedStorageException.

Lihat juga

Berlaku untuk

GetStore(IsolatedStorageScope, Evidence, Type, Evidence, Type)

Mendapatkan penyimpanan terisolasi yang sesuai dengan domain aplikasi yang diberikan dan objek dan jenis bukti perakitan.

public:
 static System::IO::IsolatedStorage::IsolatedStorageFile ^ GetStore(System::IO::IsolatedStorage::IsolatedStorageScope scope, System::Security::Policy::Evidence ^ domainEvidence, Type ^ domainEvidenceType, System::Security::Policy::Evidence ^ assemblyEvidence, Type ^ assemblyEvidenceType);
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore (System.IO.IsolatedStorage.IsolatedStorageScope scope, System.Security.Policy.Evidence domainEvidence, Type domainEvidenceType, System.Security.Policy.Evidence assemblyEvidence, Type assemblyEvidenceType);
static member GetStore : System.IO.IsolatedStorage.IsolatedStorageScope * System.Security.Policy.Evidence * Type * System.Security.Policy.Evidence * Type -> System.IO.IsolatedStorage.IsolatedStorageFile
Public Shared Function GetStore (scope As IsolatedStorageScope, domainEvidence As Evidence, domainEvidenceType As Type, assemblyEvidence As Evidence, assemblyEvidenceType As Type) As IsolatedStorageFile

Parameter

scope
IsolatedStorageScope

Kombinasi bitwise dari nilai enumerasi.

domainEvidence
Evidence

Objek yang berisi identitas domain aplikasi.

domainEvidenceType
Type

Jenis identitas untuk dipilih dari bukti domain aplikasi.

assemblyEvidence
Evidence

Objek yang berisi identitas rakitan kode.

assemblyEvidenceType
Type

Jenis identitas untuk dipilih dari bukti rakitan kode aplikasi.

Mengembalikan

Objek yang mewakili parameter.

Pengecualian

Izin penyimpanan terisolasi yang memadai belum diberikan.

Identitas domainEvidence atau assemblyEvidence belum diteruskan.

Tidak scope valid.

Lokasi penyimpanan terisolasi tidak dapat diinisialisasi.

-atau-

scope berisi nilai Applicationenumerasi , tetapi identitas aplikasi pemanggil tidak dapat ditentukan, karena ActivationContext untuk domain aplikasi saat ini dikembalikan null.

-atau-

scope berisi nilai Domain, tetapi izin untuk domain aplikasi tidak dapat ditentukan.

-atau-

scope berisi nilai Assembly, tetapi izin untuk rakitan panggilan tidak dapat ditentukan.

Contoh

Contoh kode berikut mendapatkan penyimpanan berdasarkan bukti penerbit.

using System;
using System.IO;
using System.IO.IsolatedStorage;
using System.Security;
using System.Security.Policy;
using System.Security.Permissions;
using System.Security.Cryptography.X509Certificates;

class Program
{
    static void Main(string[] args)
    {
        try
        {

            if (Test())
            {
                Console.WriteLine("PASSED.");
                Environment.ExitCode = 100;
            }
            else
            {
                Console.WriteLine("FAILED.");
                Environment.ExitCode = 101;
            }
        }
        catch (Exception e)
        {
            Console.Write("Exception occurred: {0}", e.ToString());
            Environment.ExitCode = 101;
        }
        return;
    }

    public static Boolean Test()
    {
        Boolean bRes = true;

        Evidence evidence1 = GetTestEvidence();
        Evidence evidence2 = GetTestEvidence();

        IsolatedStorageFile isf = IsolatedStorageFile.GetStore(
                                    IsolatedStorageScope.User | IsolatedStorageScope.Assembly,
                                    evidence1,
                                    typeof(System.Security.Policy.Publisher),
                                    evidence2,
                                    typeof(System.Security.Policy.Publisher));

        IsolatedStorageFileStream isfs = new IsolatedStorageFileStream("AdminEvd1.testfile", FileMode.OpenOrCreate, isf);
        isfs.WriteByte(5);
        isfs.Flush();
        isfs.Close();

        return bRes;
    }

    public static Evidence GetTestEvidence()
    {
        // For demonsration purposes, use a blank certificate.
        Publisher pub = new Publisher(new X509Certificate(new Byte[64]));
        Object[] arrObj = new Object[1];
        arrObj[0] = (Object)pub;
        return new Evidence(arrObj, arrObj);
    }
}
Imports System.IO
Imports System.IO.IsolatedStorage
Imports System.Security
Imports System.Security.Policy
Imports System.Security.Permissions
Imports System.Security.Cryptography.X509Certificates

Class Program

    Public Shared Sub Main(ByVal args() As String)
        Try
            If Test Then
                Console.WriteLine("PASSED.")
                Environment.ExitCode = 100
            Else
                Console.WriteLine("FAILED.")
                Environment.ExitCode = 101
            End If
        Catch e As Exception
            Console.Write("Exception occurred: {0}", e.ToString)
            Environment.ExitCode = 101
        End Try
        Return
    End Sub

    Public Shared Function Test() As Boolean
        Dim bRes As Boolean = True
        Dim evidence1 As Evidence = GetTestEvidence
        Dim evidence2 As Evidence = GetTestEvidence
        Dim isf As IsolatedStorageFile = IsolatedStorageFile.GetStore((IsolatedStorageScope.User _
         Or IsolatedStorageScope.Assembly), _
         evidence1, _
         GetType(System.Security.Policy.Publisher), _
         evidence2, _
         GetType(System.Security.Policy.Publisher))
        Dim isfs As IsolatedStorageFileStream = New IsolatedStorageFileStream("AdminEvd1.testfile", _
         FileMode.OpenOrCreate, isf)
        isfs.WriteByte(5)
        isfs.Flush()
        isfs.Close()
        Return bRes
    End Function

    Public Shared Function GetTestEvidence() As Evidence

        ' For demonsration purposes, use a blank certificate.
        Dim CertTemp(63) As Byte
        Dim pub As Publisher = New Publisher(New X509Certificate(CertTemp))
        Dim arrObj(0) As Object
        arrObj(0) = CType(pub, Object)
        Return New Evidence(arrObj, arrObj)
    End Function
End Class

Keterangan

Catatan

scope Jika parameter adalah Domain dan domain aplikasi tempat assembly diinstal tidak memiliki IsolatedStorageFilePermission, GetStore metode akan mengembalikan IsolatedStorageFile objek tanpa kuota. Nantinya mencoba membuat IsolatedStorageFile objek menggunakan IsolatedStorageFile objek yang tidak memiliki kuota akan gagal dengan IsolatedStorageException.

Lihat juga

Berlaku untuk