Freigeben über


InstanceStoreProvider-Klasse

Stellt die Basisklasse für alle Instanzspeicheranbieter dar.

Namespace: Microsoft.ApplicationServer.StoreProvider
Assembly: Microsoft.ApplicationServer.StoreProvider (in microsoft.applicationserver.storeprovider.dll)

Verwendung

Syntax

'Declaration
Public MustInherit Class InstanceStoreProvider
    Inherits ProviderBase
public abstract class InstanceStoreProvider : ProviderBase
public ref class InstanceStoreProvider abstract : public ProviderBase
public abstract class InstanceStoreProvider extends ProviderBase
public abstract class InstanceStoreProvider extends ProviderBase

Hinweise

Dies ist eine Beispielimplementierung von InstanceStoreProvider:

using Microsoft.ApplicationServer.StoreProvider;
using System.Runtime.DurableInstancing;
using System.Activities.DurableInstancing;

              
//for the sample code provided in the methods
using System.Collections.Specialized; 
using System.Data;
using System.Data.SqlClient;

namespace MySqlStoreProviderNS
{
    public sealed class MySqlWorkflowInstanceStoreProvider : InstanceStoreProvider
    {
        string ConnectionString { get; set; }
        public override void Initialize(string name, NameValueCollection config)
        {
            this.ConnectionString= config["connectionString"];

            // Initialize the base class
            base.Initialize(name, config);
        }


        public override InstanceStore CreateInstanceStore()
        {
            // the following line creates an instance of the SqlWorkflowInstanceStore class
            SqlWorkflowInstanceStore store = new SqlWorkflowInstanceStore(this.ConnectionString);
            return store;
        }

        string UniqueStoreIdentifier { get; set; }

        public override string UniqueProviderIdentifier()
        {   
            this.UniqueStoreIdentifier = GetUniqueStoreIdentifier(this.ConnectionString); 
            return this.UniqueStoreIdentifier;
        }

        private string GetUniqueStoreIdentifier(string connectionString)
        {
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                using (SqlCommand command = new SqlCommand())
                {
                    command.CommandType = CommandType.Text;
                    command.CommandText = "SELECT TOP (1) [StoreIdentifier] FROM [Microsoft.ApplicationServer.DurableInstancing].[StoreVersion]";
                    command.Connection = connection;

                    command.Connection.Open();

                    Guid identifier = (Guid)command.ExecuteScalar();
                    return identifier.ToString();
                }
            }
        }

    }
}

Vererbungshierarchie

System.Object
   System.Configuration.Provider.ProviderBase
    Microsoft.ApplicationServer.StoreProvider.InstanceStoreProvider
       Microsoft.ApplicationServer.StoreProvider.Sql.SqlWorkflowInstanceStoreProvider

Threadsicherheit

Alle öffentlichen statischen (Freigegebenen in Visual Basic) Member dieses Typs sind threadsicher. Instanzmember sind nicht garantiert threadsicher.

Plattformen

Entwicklungsplattformen

Visual Studio 2010 und höher, .NET Framework 4

Zielplattformen

Windows 7; Windows Server 2008 R2; Windows Server 2008 Service Pack 2; Windows Vista Service Pack 2

Change History

Siehe auch

Verweis

InstanceStoreProvider-Member
Microsoft.ApplicationServer.StoreProvider-Namespace