public string Version(string versionString) { var response = new RootApiResponse { neo4j_version = versionString }; return(response.Version.ToString()); }
public void Version(string versionString, string expectedResult) { var response = new RootApiResponse { Neo4jVersion = versionString }; response.Version.ToString().Should().Be(expectedResult); }
public async Task ShouldParse15M02Version() { RootApiResponse rar = new RootApiResponse { Neo4jVersion = "1.5.M02" }; Assert.Equal("1.5.0.2", rar.Version.ToString()); }
/// <inheritdoc cref="IGraphClient.ConnectAsync"/> public async Task ConnectAsync(NeoServerConfiguration configuration = null) { if (Driver == null) { var driver = configuration == null ? new DriverWrapper(uri, addressResolver, username, password, realm, encryptionLevel) : new DriverWrapper(uri, addressResolver, configuration.Username, configuration.Password, configuration.Realm, configuration.EncryptionLevel); Driver = driver; } var session = Driver.AsyncSession(x => x.WithDefaultAccessMode(AccessMode.Read)); var serverInformation = await session.RunAsync("CALL dbms.components()").ConfigureAwait(false); foreach (var record in await serverInformation.ToListAsync().ConfigureAwait(false)) { var name = record["name"].As <string>(); if (name.ToLowerInvariant() != "neo4j kernel") { continue; } var version = record["versions"].As <List <object> >(); ServerVersion = RootApiResponse.GetVersion(version?.First()?.ToString()); if (ServerVersion >= new Version(3, 0)) { CypherCapabilities = CypherCapabilities.Cypher30; } if (ServerVersion >= new Version(4, 0)) { CypherCapabilities = CypherCapabilities.Cypher40; } if (ServerVersion >= new Version(4, 4)) { CypherCapabilities = CypherCapabilities.Cypher44; } } await session.CloseAsync().ConfigureAwait(false); IsConnected = true; }
/// <inheritdoc /> public Task ConnectAsync(NeoServerConfiguration configuration = null) { if (Driver == null) { var driver = configuration == null ? new DriverWrapper(uri, username, password, realm) : new DriverWrapper(uri, configuration.Username, configuration.Password, configuration.Realm); Driver = driver; } using (var session = Driver.Session(AccessMode.Read)) { var serverInformation = session.Run("CALL dbms.components()"); foreach (var record in serverInformation) { var name = record["name"].As <string>(); if (name.ToLowerInvariant() != "neo4j kernel") { continue; } var version = record["versions"].As <List <object> >(); ServerVersion = RootApiResponse.GetVersion(version?.First()?.ToString()); if (ServerVersion > new Version(3, 0)) { CypherCapabilities = CypherCapabilities.Cypher30; } } } IsConnected = true; #if NET45 return(Task.FromResult(0)); #else return(Task.CompletedTask); #endif }
private NeoServerConfiguration(RootApiResponse apiConfig) { ApiConfig = apiConfig; }
public virtual async Task ConnectAsync(NeoServerConfiguration configuration = null) { if (IsConnected) { return; } var stopwatch = Stopwatch.StartNew(); var operationCompletedArgs = new OperationCompletedEventArgs { QueryText = "Connect", ResourcesReturned = 0 }; void StopTimerAndNotifyCompleted() { stopwatch.Stop(); operationCompletedArgs.TimeTaken = stopwatch.Elapsed; OnOperationCompleted(operationCompletedArgs); } try { configuration = configuration ?? await NeoServerConfiguration.GetConfigurationAsync( RootUri, ExecutionConfiguration.Username, ExecutionConfiguration.Password, ExecutionConfiguration.Realm, ExecutionConfiguration.EncryptionLevel, ExecutionConfiguration).ConfigureAwait(false); RootApiResponse = configuration.ApiConfig; if (!string.IsNullOrWhiteSpace(RootApiResponse.Transaction)) { transactionManager = new TransactionManager(this); } // http://blog.neo4j.org/2012/04/streaming-rest-api-interview-with.html ExecutionConfiguration.UseJsonStreaming = ExecutionConfiguration.UseJsonStreaming && RootApiResponse.Version >= new Version(1, 8); var version = RootApiResponse.Version; if (version < new Version(2, 0)) { CypherCapabilities = CypherCapabilities.Cypher19; } if (version >= new Version(2, 2)) { CypherCapabilities = CypherCapabilities.Cypher22; } if (version >= new Version(2, 2, 6)) { CypherCapabilities = CypherCapabilities.Cypher226; } if (version >= new Version(2, 3)) { CypherCapabilities = CypherCapabilities.Cypher23; } if (version >= new Version(3, 0)) { CypherCapabilities = CypherCapabilities.Cypher30; } if (version >= new Version(4, 0)) { CypherCapabilities = CypherCapabilities.Cypher40; } if (ServerVersion >= new Version(4, 4)) { CypherCapabilities = CypherCapabilities.Cypher44; } } catch (AggregateException ex) { var wasUnwrapped = ex.TryUnwrap(out var unwrappedException); operationCompletedArgs.Exception = wasUnwrapped ? unwrappedException : ex; StopTimerAndNotifyCompleted(); if (wasUnwrapped) { throw unwrappedException; } throw; } catch (Exception e) { operationCompletedArgs.Exception = e; StopTimerAndNotifyCompleted(); throw; } StopTimerAndNotifyCompleted(); }