Classe InstanceControlProvider

Rappresenta la classe di base per tutti i provider di controllo delle istanze

Spazio dei nomi: Microsoft.ApplicationServer.StoreManagement.Control
Assembly: Microsoft.ApplicationServer.StoreManagement (in microsoft.applicationserver.storemanagement.dll)

public abstract class InstanceControlProvider : ProviderBase
public abstract class InstanceControlProvider extends ProviderBase
public abstract class InstanceControlProvider extends ProviderBase

Il codice riportato di seguito illustra un esempio di implementazione di questa classe.


    public class MySqlInstanceControlProvider : InstanceControlProvider
    {

        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 InstanceControl CreateInstanceControl()
        {
            SqlConnectionStringBuilder connectionStringBuilder = new SqlConnectionStringBuilder(this.ConnectionString);
            connectionStringBuilder.AsynchronousProcessing = true;
            return new MySqlInstanceControl(connectionStringBuilder.ConnectionString);
        }
        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 = System.Data.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();
                }
            }
        }
    }



Qualsiasi membro statico (condiviso in Visual Basic) di questo tipo è thread safe, diversamente dai membri istanza.

Piattaforme di sviluppo

Visual Studio 2010 e versioni successive, .NET Framework 4

Piattaforme di destinazione

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