///<summary> /// Gets a client based on the connection string specified in the configuration. ///</summary> /// <param name="clientConfiguration">Configuration options for the client.</param> ///<returns>A new Brightstar service client</returns> public static IBrightstarService GetClient(ClientConfiguration clientConfiguration = null) { var configuration = Configuration.ConnectionString; if(String.IsNullOrEmpty(configuration)) { throw new BrightstarClientException(Strings.BrightstarServiceClient_NoConnectionStringConfiguration); } // use connection string in config return GetClient(new ConnectionString(Configuration.ConnectionString), clientConfiguration); }
/// <summary> /// Create a new instance of the context that attaches to the specified directory location /// </summary> /// <param name="connectionString">The Brightstar service connection string</param> /// <param name="clientConfiguration">Additional client configuration options</param> /// <remarks>The data context is thread-safe but doesn't support concurrent access to the same base location by multiple /// instances. You should ensure in your code that only one EmbeddedDataObjectContext instance is connected to any given base location /// at a given time.</remarks> public EmbeddedDataObjectContext(ConnectionString connectionString, ClientConfiguration clientConfiguration = null) { if (connectionString == null) throw new ArgumentNullException("connectionString"); if (connectionString.Type != ConnectionType.Embedded) throw new ArgumentException("Invalid connection type", "connectionString"); if (clientConfiguration == null) clientConfiguration = ClientConfiguration.Default; _serverCore = ServerCoreManager.GetServerCore( connectionString.StoresDirectory, clientConfiguration == null ? null : clientConfiguration.PreloadConfiguration); _optimisticLockingEnabled = connectionString.OptimisticLocking; }
///<summary> /// Gets a client based on the connection string parameter ///</summary> ///<param name="connectionString">The connection string</param> /// <param name="clientConfiguration">Configuration options for the client.</param> ///<returns>A new Brightstar service client</returns> public static IBrightstarService GetClient(ConnectionString connectionString, ClientConfiguration clientConfiguration = null) { if (clientConfiguration == null) { clientConfiguration = ClientConfiguration.Default; } switch (connectionString.Type) { case ConnectionType.Embedded: return new EmbeddedBrightstarService(connectionString.StoresDirectory, clientConfiguration); #if !WINDOWS_PHONE case ConnectionType.Rest: return GetRestClient(connectionString); #endif default: throw new BrightstarClientException("Unable to create valid context with connection string " + connectionString.Value); } }
///<summary> /// Gets a client based on the connection string parameter ///</summary> ///<param name="connectionString">The connection string</param> /// <param name="clientConfiguration">Configuration options for the client.</param> ///<returns>A new Brightstar service client</returns> public static IBrightstarService GetClient(string connectionString, ClientConfiguration clientConfiguration = null) { return GetClient(new ConnectionString(connectionString), clientConfiguration); }
///<summary> /// Returns a client for the embededd stores in the specified location ///</summary> ///<param name="baseLocation">The base directory for stores accessed by this client</param> /// <param name="clientConfiguration">Configuration options for the client.</param> ///<returns>A new Brightstar service client</returns> internal static IBrightstarService GetEmbeddedClient(string baseLocation, ClientConfiguration clientConfiguration = null) { return new EmbeddedBrightstarService(baseLocation, clientConfiguration); }
/// <summary> /// Create a new instance of the service that attaches to the specified directory location /// </summary> /// <param name="baseLocation">The full path to the location of the directory that contains one or more Brightstar stores</param> /// <param name="clientConfiguration">An optional configuration for the client.</param> /// <remarks>The embedded server is thread-safe but doesn't support concurrent access to the same base location by multiple /// instances. You should ensure in your code that only one EmbeddedBrightstarService instance is connected to any given base location /// at a given time.</remarks> public EmbeddedBrightstarService(string baseLocation, ClientConfiguration clientConfiguration = null) { _serverCore = ServerCoreManager.GetServerCore( baseLocation, clientConfiguration == null ? null : clientConfiguration.PreloadConfiguration); }