예제 #1
0
 /// <summary>
 /// Returns a new REST service client instance constructed from a BrightstarDB connection string
 /// </summary>
 /// <param name="connectionString">The connection string providing the parameters for the REST service connection</param>
 /// <returns>A new <see cref="IBrightstarService"/>instance</returns>
 /// <exception cref="ArgumentNullException">The <paramref name="connectionString"/> parameter is NULL</exception>
 /// <exception cref="BrightstarClientException">The <paramref name="connectionString"/> parameter is invalid for some other reason</exception>
 public static IBrightstarService GetRestClient(ConnectionString connectionString)
 {
     if (connectionString == null) throw new ArgumentNullException("connectionString");
     if (String.IsNullOrEmpty(connectionString.ServiceEndpoint))
         throw new BrightstarClientException(
             "Connection string does not contain the required 'endpoint' attribute");
     string endpoint = connectionString.ServiceEndpoint;
     IRequestAuthenticator requestAuthenticator = new PassthroughRequestAuthenticator();
     if (connectionString.Account != null && connectionString.Key != null)
     {
         requestAuthenticator = new SharedSecretAuthenticator(connectionString.Account, connectionString.Key);
     }
     else if (connectionString.UserName != null && connectionString.Password != null)
     {
         requestAuthenticator = new CredentialsRequestAuthenticator(new NetworkCredential(connectionString.UserName, connectionString.Password));
     }
     return new BrightstarRestClient(endpoint, requestAuthenticator, null);
 }
예제 #2
0
 /// <summary>
 /// Returns a new REST service client instance
 /// </summary>
 /// <param name="restEndpoint">The URI of the BrightstarDB REST endpoint to connect to</param>
 /// <param name="requestAuthenticator">The service to use to apply authentication information to outgoing requests</param>
 /// <param name="queryCache">A cache instance for the client to use for caching SPARQL query responses</param>
 /// <returns>A new <see cref="IBrightstarService"/> instance</returns>
 public static IBrightstarService GetRestClient(string restEndpoint, IRequestAuthenticator requestAuthenticator = null, ICache queryCache = null)
 {
     if (requestAuthenticator == null) requestAuthenticator = new PassthroughRequestAuthenticator();
     return new BrightstarRestClient(restEndpoint, requestAuthenticator, queryCache);
 }