private IStorageProvider GetStorageProvider(string storeName)
 {
     if (_storageProviders.ContainsKey(storeName))
     {
         return(_storageProviders[storeName]);
     }
     if (_configurationGraph != null)
     {
         var obj = DotNetRdfConfigurationHelper.GetConfigurationObject(_configurationGraph, storeName);
         if (obj == null)
         {
             throw new BrightstarClientException(String.Format(Strings.BrightstarServiceClient_StoreDoesNotExist, storeName));
         }
         if (!(obj is IStorageProvider))
         {
             throw new BrightstarClientException(Strings.DotNetRdf_NotAStorageProvider);
         }
         _storageProviders[storeName] = obj as IStorageProvider;
         return(obj as IStorageProvider);
     }
     return(null);
 }
コード例 #2
0
        ///<summary>
        /// Creates a data object context from a connection string
        ///</summary>
        ///<param name="connectionString">The <see cref="ConnectionString"/> that specifies how to connect to a Brightstar server.</param>
        ///<returns>The new data object context</returns>
        public static IDataObjectContext GetDataObjectContext(ConnectionString connectionString)
        {
            switch (connectionString.Type)
            {
            case ConnectionType.Embedded:
                return(new EmbeddedDataObjectContext(connectionString));

#if !WINDOWS_PHONE
            case ConnectionType.Rest:
                return(new RestDataObjectContext(connectionString));
#endif
            case ConnectionType.DotNetRdf:
                var  configurationGraph = DotNetRdfConfigurationHelper.LoadConfiguration(connectionString.Configuration);
                bool optimisticLocking  = connectionString.OptimisticLocking;
                if (String.IsNullOrEmpty(connectionString.DnrStorageServer))
                {
                    return(new DotNetRdfStorageProvidersDataObjectContext(configurationGraph, optimisticLocking));
                }
                var storageServer = DotNetRdfConfigurationHelper.GetConfigurationObject(
                    configurationGraph, connectionString.DnrStorageServer) as IStorageServer;
                if (storageServer == null)
                {
                    throw new BrightstarClientException("Unable to retrieve a DotNetRDF storage server from the provided configuration.");
                }
                return(new DotNetRdfStorageServerDataObjectContext(storageServer, optimisticLocking));

            case ConnectionType.Sparql:
                return(MakeSparqlDataObjectContext(connectionString));

            default:
                throw new BrightstarClientException("Unable to create valid context with connection string " +
                                                    connectionString.Value +
                                                    ". Cause: unrecognised connection string type: " +
                                                    connectionString.Type);
            }
        }