// Recurse through maps and sequences public override AnyValue MapMap(MapValue value) { MapValueBuilder builder = new MapValueBuilder(); value.Foreach((k, v) => builder.Add(k, v.map(this))); return(builder.Build()); }
public static AnyValue Convert(IEnumerable <Notification> notifications) { IList <AnyValue> @out = new List <AnyValue>(); foreach (Notification notification in notifications) { InputPosition pos = notification.Position; // position is optional bool includePosition = !pos.Equals(InputPosition.empty); int size = includePosition ? 5 : 4; MapValueBuilder builder = new MapValueBuilder(size); builder.Add("code", stringValue(notification.Code)); builder.Add("title", stringValue(notification.Title)); builder.Add("description", stringValue(notification.Description)); builder.Add("severity", stringValue(notification.Severity.ToString())); if (includePosition) { // only add the position if it is not empty builder.Add("position", VirtualValues.map(new string[] { "offset", "line", "column" }, new AnyValue[] { intValue(pos.Offset), intValue(pos.Line), intValue(pos.Column) })); } @out.Add(builder.Build()); } return(VirtualValues.fromList(@out)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.values.virtual.MapValue metadataOf(CypherAdapterStream stream) throws Exception private MapValue MetadataOf(CypherAdapterStream stream) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.values.virtual.MapValueBuilder meta = new org.neo4j.values.virtual.MapValueBuilder(); MapValueBuilder meta = new MapValueBuilder(); stream.Accept(new BoltResult_VisitorAnonymousInnerClass(this, meta)); return(meta.Build()); }
private MapValue MapValues(params object[] values) { int i = 0; MapValueBuilder builder = new MapValueBuilder(); while (i < values.Length) { builder.Add(( string )values[i++], ( AnyValue )values[i++]); } return(builder.Build()); }
private MapValue QueryStats(QueryStatistics queryStatistics) { MapValueBuilder builder = new MapValueBuilder(); AddIfNonZero(builder, "nodes-created", queryStatistics.NodesCreated); AddIfNonZero(builder, "nodes-deleted", queryStatistics.NodesDeleted); AddIfNonZero(builder, "relationships-created", queryStatistics.RelationshipsCreated); AddIfNonZero(builder, "relationships-deleted", queryStatistics.RelationshipsDeleted); AddIfNonZero(builder, "properties-set", queryStatistics.PropertiesSet); AddIfNonZero(builder, "labels-added", queryStatistics.LabelsAdded); AddIfNonZero(builder, "labels-removed", queryStatistics.LabelsRemoved); AddIfNonZero(builder, "indexes-added", queryStatistics.IndexesAdded); AddIfNonZero(builder, "indexes-removed", queryStatistics.IndexesRemoved); AddIfNonZero(builder, "constraints-added", queryStatistics.ConstraintsAdded); AddIfNonZero(builder, "constraints-removed", queryStatistics.ConstraintsRemoved); return(builder.Build()); }
private static AnyValue ValueOf(object obj) { if (obj is MappedGraphType) { return((( MappedGraphType )obj).Value); } Value value = Values.unsafeOf(obj, true); if (value != null) { return(value); } //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: if (obj instanceof java.util.List<?>) if (obj is IList <object> ) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: return fromList(((java.util.List<?>) obj).stream().map(ValueMapperTest::valueOf).collect(toList())); return(fromList(((IList <object>)obj).Select(ValueMapperTest.valueOf).ToList())); } //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: if (obj instanceof java.util.Map<?,?>) if (obj is IDictionary <object, ?> ) { //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.Map<String,?> map = (java.util.Map<String,?>) obj; //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: IDictionary <string, ?> map = (IDictionary <string, ?>)obj; MapValueBuilder builder = new MapValueBuilder(map.Count); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: for (java.util.Map.Entry<String,?> entry : map.entrySet()) foreach (KeyValuePair <string, ?> entry in map.SetOfKeyValuePairs()) { builder.Add(entry.Key, ValueOf(entry.Value)); } return(builder.Build()); } //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: throw new AssertionError("cannot convert: " + obj + " (a " + obj.GetType().FullName + ")"); }
public static MapValue Convert(ExecutionPlanDescription plan) { bool hasProfilerStatistics = plan.HasProfilerStatistics(); int size = hasProfilerStatistics ? 9 : 4; MapValueBuilder @out = new MapValueBuilder(size); @out.Add("operatorType", stringValue(plan.Name)); @out.Add("args", ValueUtils.asMapValue(plan.Arguments)); @out.Add("identifiers", ValueUtils.asListValue(plan.Identifiers)); @out.Add("children", Children(plan)); if (hasProfilerStatistics) { Org.Neo4j.Graphdb.ExecutionPlanDescription_ProfilerStatistics profile = plan.ProfilerStatistics; @out.Add("dbHits", longValue(profile.DbHits)); @out.Add("pageCacheHits", longValue(profile.PageCacheHits)); @out.Add("pageCacheMisses", longValue(profile.PageCacheMisses)); @out.Add("pageCacheHitRatio", doubleValue(profile.PageCacheHitRatio)); @out.Add("rows", longValue(profile.Rows)); } return(@out.Build()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings({"unchecked", "WeakerAccess"}) public static org.neo4j.values.AnyValue materializeAnyResult(org.neo4j.kernel.impl.core.EmbeddedProxySPI proxySpi, Object anyValue) public static AnyValue MaterializeAnyResult(EmbeddedProxySPI proxySpi, object anyValue) { if (anyValue == null || anyValue == NO_VALUE) { return(NO_VALUE); } else if (anyValue is AnyValue) { return(MaterializeAnyValueResult(proxySpi, anyValue)); } else if (anyValue is System.Collections.IList) { return(VirtualValues.fromList((IList <AnyValue>)(((System.Collections.IList)anyValue).Select(v => MaterializeAnyResult(proxySpi, v)).ToList()))); } else if (anyValue is System.Collections.IDictionary) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Map<String,?> incoming = (java.util.Map<String,?>) anyValue; IDictionary <string, ?> incoming = (IDictionary <string, ?>)anyValue; MapValueBuilder builder = new MapValueBuilder(incoming.Count); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: for (java.util.Map.Entry<String,?> entry : incoming.entrySet()) foreach (KeyValuePair <string, ?> entry in incoming.SetOfKeyValuePairs()) { builder.Add(entry.Key, MaterializeAnyResult(proxySpi, entry.Value)); } return(builder.Build()); } else if (anyValue is PrimitiveNodeStream) { return(VirtualValues.fromList((( PrimitiveNodeStream )anyValue).LongStream().mapToObj(id => (AnyValue)ValueUtils.fromNodeProxy(proxySpi.NewNodeProxy(id))).collect(Collectors.toList()))); } else if (anyValue is PrimitiveRelationshipStream) { return(VirtualValues.fromList((( PrimitiveRelationshipStream )anyValue).LongStream().mapToObj(id => (AnyValue)ValueUtils.fromRelationshipProxy(proxySpi.NewRelationshipProxy(id))).collect(Collectors.toList()))); } else if (anyValue is LongStream) { long[] array = (( LongStream )anyValue).toArray(); return(Values.longArray(array)); } else if (anyValue is DoubleStream) { double[] array = (( DoubleStream )anyValue).toArray(); return(Values.doubleArray(array)); } else if (anyValue is IntStream) { // IntStream is only used for list of primitive booleans return(VirtualValues.fromList((( IntStream )anyValue).mapToObj(i => Values.booleanValue(i != 0)).collect(Collectors.toList()))); } else if (anyValue.GetType().IsArray) { Type componentType = anyValue.GetType().GetElementType(); int length = Array.getLength(anyValue); if (componentType.IsPrimitive) { object copy = Array.CreateInstance(componentType, length); //noinspection SuspiciousSystemArraycopy Array.Copy(anyValue, 0, copy, 0, length); return(ValueUtils.of(copy)); } else if (anyValue is string[]) { return(Values.stringArray(( string[] )anyValue)); } else { AnyValue[] copy = new AnyValue[length]; for (int i = 0; i < length; i++) { copy[i] = MaterializeAnyResult(proxySpi, Array.get(anyValue, i)); } return(VirtualValues.list(copy)); } } else { return(ValueUtils.of(anyValue)); } }