public dynamic Objectify(JToken graphsonObject, GraphSONReader reader) { var x = reader.ToObject(graphsonObject["x"]); var y = reader.ToObject(graphsonObject["y"]); return(new MyType(x, y)); }
public dynamic Objectify(JsonElement graphsonObject, GraphSONReader reader) { var x = reader.ToObject(graphsonObject.GetProperty("x")); var y = reader.ToObject(graphsonObject.GetProperty("y")); return(new MyType(x, y)); }
public GremlinClient(GremlinServer gremlinServer, GraphSONReader graphSONReader, GraphSONWriter graphSONWriter, ConnectionPoolSettings connectionPoolSettings = null, Action <ClientWebSocketOptions> webSocketConfiguration = null, string sessionId = null) : this(gremlinServer, graphSONReader, graphSONWriter, SerializationTokens.GraphSON3MimeType, connectionPoolSettings, webSocketConfiguration, sessionId) { }
/// <summary> /// Initializes a new instance of the <see cref="GremlinClient" /> class for the specified Gremlin Server. /// </summary> /// <param name="gremlinServer">The <see cref="GremlinServer" /> the requests should be sent to.</param> /// <param name="graphSONReader">A <see cref="GraphSONReader" /> instance to read received GraphSON data.</param> /// <param name="graphSONWriter">a <see cref="GraphSONWriter" /> instance to write GraphSON data.</param> /// <param name="mimeType">The GraphSON version mime type, defaults to latest supported by the server.</param> /// <param name="connectionPoolSettings">The <see cref="ConnectionPoolSettings"/> for the connection pool.</param> /// <param name="webSocketConfiguration"> /// A delegate that will be invoked with the <see cref="ClientWebSocketOptions" /> /// object used to configure WebSocket connections. /// </param> /// <param name="sessionId">The session Id if Gremlin Client in session mode, defaults to null as session-less Client.</param> public GremlinClient(GremlinServer gremlinServer, GraphSONReader graphSONReader = null, GraphSONWriter graphSONWriter = null, string mimeType = null, ConnectionPoolSettings connectionPoolSettings = null, Action <ClientWebSocketOptions> webSocketConfiguration = null, string sessionId = null) { var reader = graphSONReader ?? new GraphSON3Reader(); var writer = graphSONWriter ?? new GraphSON3Writer(); var connectionFactory = new ConnectionFactory(gremlinServer, reader, writer, mimeType ?? DefaultMimeType, webSocketConfiguration, sessionId); // make sure one connection in pool as session mode if (!String.IsNullOrEmpty(sessionId)) { if (connectionPoolSettings != null) { if (connectionPoolSettings.PoolSize != 1) { throw new ArgumentOutOfRangeException(nameof(connectionPoolSettings), "PoolSize must be 1 in session mode!"); } } else { connectionPoolSettings = new ConnectionPoolSettings(); connectionPoolSettings.PoolSize = 1; } } _connectionPool = new ConnectionPool(connectionFactory, connectionPoolSettings ?? new ConnectionPoolSettings()); }
/// <summary> /// Initializes a new instance of the <see cref="GraphClient"/> class. /// </summary> /// <param name="gremlinHostname">The hostname.</param> /// <param name="databaseName">Name of the database (case-sensitive).</param> /// <param name="graphName">Name of the graph.</param> /// <param name="accessKey">The access key.</param> public GraphClient(string gremlinHostname, string databaseName, string graphName, string accessKey, int port = 443, bool useSSL = true) { var server = new GremlinServer(gremlinHostname, port, useSSL, $"/dbs/{databaseName}/colls/{graphName}", accessKey); _graphSONReader = new GraphSONJTokenReader(); _gremlinClient = new GremlinClient(server, _graphSONReader, mimeType: GremlinClient.GraphSON2MimeType); }
public ConnectionFactory(GremlinServer gremlinServer, GraphSONReader graphSONReader, GraphSONWriter graphSONWriter, string mimeType) { _gremlinServer = gremlinServer; _mimeType = mimeType; _graphSONReader = graphSONReader ?? throw new ArgumentNullException(nameof(graphSONReader)); _graphSONWriter = graphSONWriter ?? throw new ArgumentNullException(nameof(graphSONWriter)); }
public GremlinClient(GremlinServer gremlinServer, GraphSONReader graphSONReader, GraphSONWriter graphSONWriter, string mimeType, ConnectionPoolSettings connectionPoolSettings = null, Action <ClientWebSocketOptions> webSocketConfiguration = null, string sessionId = null) { IMessageSerializer messageSerializer; switch (mimeType) { case SerializationTokens.GraphSON3MimeType: VerifyGraphSONArgumentTypeForMimeType <GraphSON3Reader>(graphSONReader, nameof(graphSONReader), mimeType); VerifyGraphSONArgumentTypeForMimeType <GraphSON3Writer>(graphSONWriter, nameof(graphSONWriter), mimeType); messageSerializer = new GraphSON3MessageSerializer( (GraphSON3Reader)graphSONReader ?? new GraphSON3Reader(), (GraphSON3Writer)graphSONWriter ?? new GraphSON3Writer()); break; case SerializationTokens.GraphSON2MimeType: VerifyGraphSONArgumentTypeForMimeType <GraphSON2Reader>(graphSONReader, nameof(graphSONReader), mimeType); VerifyGraphSONArgumentTypeForMimeType <GraphSON2Writer>(graphSONWriter, nameof(graphSONWriter), mimeType); messageSerializer = new GraphSON2MessageSerializer( (GraphSON2Reader)graphSONReader ?? new GraphSON2Reader(), (GraphSON2Writer)graphSONWriter ?? new GraphSON2Writer()); break; default: throw new ArgumentException(nameof(mimeType), $"{mimeType} not supported"); } var connectionFactory = new ConnectionFactory(gremlinServer, messageSerializer, new WebSocketSettings { WebSocketConfigurationCallback = webSocketConfiguration }, sessionId); // make sure one connection in pool as session mode if (!string.IsNullOrEmpty(sessionId)) { if (connectionPoolSettings != null) { if (connectionPoolSettings.PoolSize != 1) { throw new ArgumentOutOfRangeException(nameof(connectionPoolSettings), "PoolSize must be 1 in session mode!"); } } else { connectionPoolSettings = new ConnectionPoolSettings { PoolSize = 1 }; } } _connectionPool = new ConnectionPool(connectionFactory, connectionPoolSettings ?? new ConnectionPoolSettings()); }
public ConnectionFactory(GremlinServer gremlinServer, GraphSONReader graphSONReader, GraphSONWriter graphSONWriter, string mimeType, Action <ClientWebSocketOptions> webSocketConfiguration) { _gremlinServer = gremlinServer; _mimeType = mimeType; _graphSONReader = graphSONReader ?? throw new ArgumentNullException(nameof(graphSONReader)); _graphSONWriter = graphSONWriter ?? throw new ArgumentNullException(nameof(graphSONWriter)); _webSocketConfiguration = webSocketConfiguration; }
/// <summary> /// Initializes a new instance of the <see cref="GremlinClient" /> class for the specified Gremlin Server. /// </summary> /// <param name="gremlinServer">The <see cref="GremlinServer" /> the requests should be sent to.</param> /// <param name="graphSONReader">A <see cref="GraphSONReader" /> instance to read received GraphSON data.</param> /// <param name="graphSONWriter">a <see cref="GraphSONWriter" /> instance to write GraphSON data.</param> /// <param name="mimeType">The GraphSON version mime type, defaults to latest supported by the server.</param> public GremlinClient(GremlinServer gremlinServer, GraphSONReader graphSONReader = null, GraphSONWriter graphSONWriter = null, string mimeType = null) { var reader = graphSONReader ?? new GraphSON3Reader(); var writer = graphSONWriter ?? new GraphSON3Writer(); var connectionFactory = new ConnectionFactory(gremlinServer, reader, writer, mimeType ?? DefaultMimeType); _connectionPool = new ConnectionPool(connectionFactory); }
public dynamic Objectify(JToken graphsonObject, GraphSONReader reader) { if (graphsonObject["coordinates"] != null) { return(DeserializePointFromCoordinates(graphsonObject["coordinates"])); } var geometryData = graphsonObject["geometry"]; throw new InvalidOperationException($"Deserialization of type {geometryData["type"]} is not supported."); }
public Connection(Uri uri, string username, string password, GraphSONReader graphSONReader, GraphSONWriter graphSONWriter, string mimeType) { _uri = uri; _username = username; _password = password; _graphSONReader = graphSONReader; _graphSONWriter = graphSONWriter; _messageSerializer = new JsonMessageSerializer(mimeType); }
public dynamic Objectify(JsonElement graphsonObject, GraphSONReader reader) { if (graphsonObject.TryGetProperty("coordinates", out var coordinatesProperty)) { return(DeserializePointFromCoordinates(coordinatesProperty)); } var geometryData = graphsonObject.GetProperty("geometry"); throw new InvalidOperationException( $"Deserialization of type {geometryData.GetProperty("type").GetString()} is not supported."); }
/// <summary> /// Initializes a new instance of the <see cref="GremlinClient" /> class for the specified Gremlin Server. /// </summary> /// <param name="gremlinServer">The <see cref="GremlinServer" /> the requests should be sent to.</param> /// <param name="graphSONReader">A <see cref="GraphSONReader" /> instance to read received GraphSON data.</param> /// <param name="graphSONWriter">a <see cref="GraphSONWriter" /> instance to write GraphSON data.</param> /// <param name="mimeType">The GraphSON version mime type, defaults to latest supported by the server.</param> /// <param name="webSocketConfiguration"> /// A delegate that will be invoked with the <see cref="ClientWebSocketOptions" /> /// object used to configure WebSocket connections. /// </param> public GremlinClient(GremlinServer gremlinServer, GraphSONReader graphSONReader = null, GraphSONWriter graphSONWriter = null, string mimeType = null, Action <ClientWebSocketOptions> webSocketConfiguration = null) { var reader = graphSONReader ?? new GraphSON3Reader(); var writer = graphSONWriter ?? new GraphSON3Writer(); var connectionFactory = new ConnectionFactory(gremlinServer, reader, writer, mimeType ?? DefaultMimeType, webSocketConfiguration); _connectionPool = new ConnectionPool(connectionFactory); }
public Connection(Uri uri, string username, string password, GraphSONReader graphSONReader, GraphSONWriter graphSONWriter, string mimeType, Action <ClientWebSocketOptions> webSocketConfiguration) { _uri = uri; _username = username; _password = password; _graphSONReader = graphSONReader; _graphSONWriter = graphSONWriter; _messageSerializer = new JsonMessageSerializer(mimeType); _webSocketConnection = new WebSocketConnection(webSocketConfiguration); }
// /// <summary> /// Initializes a new instance of the <see cref="GremlinClient" /> class for the specified Gremlin Server. /// </summary> /// <param name="gremlinServer">The <see cref="GremlinServer" /> the requests should be sent to.</param> /// <param name="graphSONReader">A <see cref="GraphSONReader" /> instance to read received GraphSON data.</param> /// <param name="graphSONWriter">a <see cref="GraphSONWriter" /> instance to write GraphSON data.</param> /// <param name="mimeType">The GraphSON version mime type, defaults to latest supported by the server.</param> /// <param name="connectionPoolSettings">The <see cref="ConnectionPoolSettings"/> for the connection pool.</param> /// <param name="webSocketConfiguration"> /// A delegate that will be invoked with the <see cref="ClientWebSocketOptions" /> /// object used to configure WebSocket connections. /// </param> public GremlinClient(GremlinServer gremlinServer, GraphSONReader graphSONReader = null, GraphSONWriter graphSONWriter = null, string mimeType = null, ConnectionPoolSettings connectionPoolSettings = null, Action <ClientWebSocketOptions> webSocketConfiguration = null) { // _gremlinServer = gremlinServer; _graphSONReader = graphSONReader; _graphSONWriter = graphSONWriter; _mimeType = mimeType; _connectionPoolSettings = connectionPoolSettings; _webSocketConfiguration = webSocketConfiguration; // NewConnectionPool(); }
public Connection(Uri uri, string username, string password, GraphSONReader graphSONReader, GraphSONWriter graphSONWriter, string mimeType, Action <ClientWebSocketOptions> webSocketConfiguration, string sessionId) { _uri = uri; _username = username; _password = password; _sessionId = sessionId; if (!string.IsNullOrEmpty(sessionId)) { _sessionEnabled = true; } _graphSONReader = graphSONReader; _graphSONWriter = graphSONWriter; _messageSerializer = new JsonMessageSerializer(mimeType); _webSocketConnection = new WebSocketConnection(webSocketConfiguration); }
public dynamic Objectify(JsonElement graphsonObject, GraphSONReader reader) { return(new RelationIdentifier(graphsonObject.GetProperty("relationId").GetString())); }
/// <summary> /// Initializes a new instance of the <see cref="GraphClient"/> class. /// </summary> /// <param name="gremlinClient">The gremlin client.</param> /// <exception cref="ArgumentNullException">gremlinClient</exception> internal GraphClient(IGremlinClient gremlinClient) { _graphSONReader = new GraphSONJTokenReader(); _gremlinClient = gremlinClient ?? throw new ArgumentNullException(nameof(gremlinClient)); }
public dynamic Objectify(JToken graphsonObject, GraphSONReader reader) { return(new RelationIdentifier((string)graphsonObject["relationId"])); }
public dynamic Objectify(JsonElement graphsonObject, GraphSONReader reader) { return(DeserializationResult); }
public ResponseHandlerForSingleRequestMessage(GraphSONReader graphSonReader) { _graphSONReader = graphSonReader; }
public dynamic Objectify(JsonElement graphsonObject, GraphSONReader reader) { return(new TestClass { Value = graphsonObject.GetString() }); }
public dynamic Objectify(JToken graphsonObject, GraphSONReader reader) { var duration = graphsonObject.ToObject <double>(); return(TimeSpan.FromMilliseconds(duration)); }
public dynamic Objectify(JToken graphsonObject, GraphSONReader reader) { return(new TestClass { Value = graphsonObject.ToString() }); }
public dynamic Objectify(JToken graphsonObject, GraphSONReader reader) { var milliseconds = graphsonObject.ToObject <long>(); return(UnixStart.AddTicks(TimeSpan.TicksPerMillisecond * milliseconds)); }