private void AssertVersion(NeoDataRootResponse response) { var serverversion = response.Neo4JVersion; if (string.IsNullOrEmpty(serverversion)) { throw new Exception("Cannot read Neo4j Server Version"); } var versionNumberStrings = serverversion.Split(new[] { '.', '-' }).Take(3).ToArray(); for (var i = 0; i < versionNumberStrings.Count(); i++) { var versionNumberString = versionNumberStrings[i]; var versionNumber = 0; if (!int.TryParse(versionNumberString, out versionNumber)) { throw new Exception("Invalid Neo4j Server Version: " + serverversion); } if (versionNumber < MinimumVersionNumber[i]) { throw new Exception(string.Format("Incompatible Neo4j Server Version: {0}. Cypher.Net is currently only compatible with Neo4j versions {1} and above", serverversion, string.Join(".", MinimumVersionNumber))); } } }
/// <summary> /// The initialize. /// </summary> public void Initialize() { var result = this.httpClient.GetAsync(this.baseUrl).Result; this.serviceRoot = JsonConvert.DeserializeObject <NeoRootResponse>(result); var dataRootResult = this.httpClient.GetAsync(this.serviceRoot.Data).Result; this.dataRoot = JsonConvert.DeserializeObject <NeoDataRootResponse>(dataRootResult); this.AssertVersion(this.dataRoot); }
/// <summary> /// Initialises a new instance of the <see cref="ApiClientFactory"/> class. /// </summary> /// <param name="dataRoot"> /// The base url. /// </param> /// <param name="httpClient"> /// The http client. /// </param> public ApiClientFactory(NeoDataRootResponse dataRoot, IJsonHttpClientWrapper httpClient) { this.dataRoot = dataRoot; this.httpClient = httpClient; }