protected bool Equals(Neo4jClientNode other) { return(Equals(properties, other.properties)); }
private static dynamic ParseAnonymousAsDynamic(this IRecord record, IGraphClient graphClient, bool onlyReturnData) { var data = new List <dynamic>(); var inner = new List <dynamic>(); foreach (var identifier in record.Keys) { dynamic expando = new ExpandoObject(); var t = (IDictionary <string, object>)expando; var obj = record[identifier]; if (obj == null) { inner.Add(null); } else if (obj is IPath path) { inner.Add(ParsePathResponse(path)); } else if (obj is INode node) { foreach (var property in node.Properties) { t[property.Key] = ParseElementInCollectionForAnonymous(graphClient, property.Value, identifier); } inner.Add(new Dictionary <string, dynamic> { { "data", expando } }); } else if (obj is IRelationship relationship) { foreach (var property in relationship.Properties) { t[property.Key] = ParseElementInCollectionForAnonymous(graphClient, property.Value, identifier); } inner.Add(new Dictionary <string, dynamic> { { "data", expando } }); } else if (obj is IEnumerable && !(obj is string)) { var listObj = ((IEnumerable)obj).Cast <object>().ToList(); var first = listObj.FirstOrDefault(); if (first is KeyValuePair <string, object> ) { var newNode = new Neo4jClientNode(listObj.Cast <KeyValuePair <string, object> >()); dynamic expando2 = new ExpandoObject(); var t2 = (IDictionary <string, object>)expando2; foreach (var property in newNode.Properties) { var parsedValue = ParseElementInCollectionForAnonymous(graphClient, property.Value, identifier); t2[property.Key] = parsedValue; } inner.Add(expando2); } else { var parsedItems = new List <dynamic>(); foreach (var o in listObj) { parsedItems.Add(ParseElementInCollectionForAnonymous(graphClient, o, identifier)); } inner.Add(parsedItems); } } else { var method = typeof(StatementResultHelper).GetMethod(nameof(Parse), BindingFlags.Static | BindingFlags.NonPublic); var generic = method?.MakeGenericMethod(obj.GetType()); var res = generic?.Invoke(null, new object[] { record, identifier, graphClient }); if (res == null) { throw new JsonSerializationException($"Unable to serialize {obj.GetType().FullName} correctly. This is likely an error and should be reported to Neo4jClient's github page."); } inner.Add(res); } } data.Add(inner); if (onlyReturnData) { return(inner); } //TODO: Ugh! this is about as hacky as it can get dynamic output = new { columns = new List <string>(record.Keys), data }; return(output); }