Search Results for

    Show / Hide Table of Contents

    Class ConnectionProviderRegistry

    The entry point of the Maestro API. The ConnectionProviderRegistry is used to create IServerConnection objects. IServerConnection is the root object of the Maestro API, and is where most of the functionality provided by this API is accessed from.

    The ConnectionProviderRegistry supports dynamic creation of IServerConnection objects given a provider name and a connection string, which specifies the initialization parameters of the connection. The connection providers are defined in an XML file called ConnectionProviders.xml which contains all the registered providers. Each provider has the following properties:

    1. The name of the provider
    2. The assembly containing the IServerConnection implementation
    3. The name of this IServerConnection implementation

    The IServerConnection implementation is expected to have a non-public constructor which takes a single parameter, a System.Collections.Specialized.NameValueCollection containing the initialization parameters parsed from the given connection string.

    Inheritance
    System.Object
    ConnectionProviderRegistry
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: OSGeo.MapGuide.MaestroAPI
    Assembly: OSGeo.MapGuide.MaestroAPI.dll
    Syntax
    public static class ConnectionProviderRegistry
    Examples

    This example shows how to create a http-based MapGuide Server connection to the server's mapagent interface.

    using OSGeo.MapGuide.MaestroAPI;
    
    ...
    
    IServerConnection conn = ConnectionProviderRegistry.CreateConnection("Maestro.Http",
        "Url", "http://localhost/mapguide/mapagent/mapagent.fcgi",
        "Username", "Administrator",
        "Password", "admin");

    This example shows how to create a TCP/IP connection that wraps the official MapGuide API

    using OSGeo.MapGuide.MaestroAPI;
    
    ...
    
    IServerConnection conn = ConnectionProviderRegistry.CreateConnection("Maestro.LocalNative",
        "ConfigFile", "webconfig.ini",
        "Username", "Administrator",
        "Password", "admin");

    Methods

    | Improve this Doc View Source

    CreateConnection(String, NameValueCollection)

    Creates an initialized IServerConnection object given the provider name and the initalization parameters

    Declaration
    public static IServerConnection CreateConnection(string provider, NameValueCollection connInitParams)
    Parameters
    Type Name Description
    System.String provider
    System.Collections.Specialized.NameValueCollection connInitParams
    Returns
    Type Description
    IServerConnection
    | Improve this Doc View Source

    CreateConnection(String, String)

    Creates an initialized IServerConnection object given the provider name and connection string

    Declaration
    public static IServerConnection CreateConnection(string provider, string connectionString)
    Parameters
    Type Name Description
    System.String provider
    System.String connectionString
    Returns
    Type Description
    IServerConnection
    Remarks

    The Maestro.Local provider (that wraps mg-desktop) and Maestro.LocalNative providers (that wraps the official MapGuide API) are unique in that it has global connection state. What this means is that subsequent connections after the first one for these providers may re-use existing state for the first connection. The reason for this is that creating this connection internally calls MgdPlatform.Initialize(iniFile) and MapGuideApi.MgInitializeWebTier(iniFile) respectively, that initializes the necessary library parameters in the process space of your application. Creating another connection will call MgdPlatform.Initialize and MapGuideApi.MgInitializeWebTier again, but these methods are by-design only made to be called once as subsequent calls are returned immediately.

    Basically, the connection parameters you pass in are for initializing the provider the first time round. Subsequent calls may not (most likely will not) respect the values of your connection parameters.

    You can programmatically check this via the HasGlobalState property

    | Improve this Doc View Source

    CreateConnection(String, String[])

    Creates an initialized IServerConnection object given the provider name and the initalization parameters.

    Declaration
    public static IServerConnection CreateConnection(string provider, params string[] initParameters)
    Parameters
    Type Name Description
    System.String provider
    System.String[] initParameters

    A variable list of initialization parameters. They must be specified in the form: [Param1], [Value1], [Param2], [Value2], etc

    Returns
    Type Description
    IServerConnection
    | Improve this Doc View Source

    FindProvider(String)

    Gets the entry for the given connection provider name

    Declaration
    public static ConnectionProviderEntry FindProvider(string provider)
    Parameters
    Type Name Description
    System.String provider
    Returns
    Type Description
    ConnectionProviderEntry
    | Improve this Doc View Source

    GetInvocationCount(String)

    Gets the invocation count for the given provider (the number of times a connection has been created for that provider)

    Declaration
    public static int GetInvocationCount(string provider)
    Parameters
    Type Name Description
    System.String provider
    Returns
    Type Description
    System.Int32

    The invocation count for the given provider. -1 if the provider is not registered or does not exist

    Remarks

    This (in conjunction with the HasGlobalState property) can be used to programmatically determine if creating a connection for a given provider will respect the connection parameter values you pass to it. (0 calls will respect your parameter values. 1 or more will not)

    | Improve this Doc View Source

    GetProviders()

    Gets a list of registered provider names. The returned names are in upper-case.

    Declaration
    public static ConnectionProviderEntry[] GetProviders()
    Returns
    Type Description
    ConnectionProviderEntry[]
    | Improve this Doc View Source

    InitRegistry(String)

    Initializes the connection provider registry. You only need to do this if you intend to load connections from providers registered in ConnectionProviders.xml

    The HTTP connection provider is built-in and does not require calling this method first

    Declaration
    public static void InitRegistry(string dir = null)
    Parameters
    Type Name Description
    System.String dir

    The path to the directory containing ConnectionProviders.xml

    | Improve this Doc View Source

    ParseConnectionString(String)

    Parses the given Maestro connection string into a System.Collections.Specialized.NameValueCollection

    Declaration
    public static NameValueCollection ParseConnectionString(string connectionString)
    Parameters
    Type Name Description
    System.String connectionString
    Returns
    Type Description
    System.Collections.Specialized.NameValueCollection
    | Improve this Doc View Source

    RegisterProvider(ConnectionProviderEntry, ConnectionFactoryMethod)

    Registers a new connection provider

    Declaration
    public static void RegisterProvider(ConnectionProviderEntry entry, ConnectionFactoryMethod method)
    Parameters
    Type Name Description
    ConnectionProviderEntry entry

    The provider entry.

    ConnectionFactoryMethod method

    The factory method.

    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2009 - 2022 Jackie Ng