Skip to content

Commit

Permalink
small (but slow) return payloads
Browse files Browse the repository at this point in the history
  • Loading branch information
cdriesler committed Jul 8, 2023
1 parent be8a04a commit 5f8777b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
26 changes: 24 additions & 2 deletions apps/rhino-compute-server/Endpoints/GrasshopperEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,29 @@ public class NodePenSolutionData : Base
public NodePenSolutionDataManifest Manifest { get; set; } = new NodePenSolutionDataManifest();

[JsonProperty("values")]
public Dictionary<string, Dictionary<string, NodePenDataTree>> Values { get; set; } = new Dictionary<string, Dictionary<string, NodePenDataTree>>();
public NodePenSolutionDataSolutionValues Values { get; set; } = new NodePenSolutionDataSolutionValues();

public void ToDto()
{
foreach (var node in Values.Values)
{
foreach (var port in node.Values)
{
foreach (var branch in port.Values)
{
foreach (var entry in branch)
{
entry.ToDto();
}
}
}
}
}
}

public class NodePenSolutionDataSolutionValues : Dictionary<string, Dictionary<string, NodePenDataTree>>
{

}

public class NodePenSolutionDataManifest : Base
Expand Down Expand Up @@ -249,7 +271,7 @@ public Response SolveGrasshopperDocument(NancyContext context)
solutionData["Id"] = requestData.SolutionId;
solutionData.Manifest.StreamObjectIds.Add(objectId);

solutionData.Values = new Dictionary<string, Dictionary<string, NodePenDataTree>>();
solutionData.ToDto();

return Response.AsJson(solutionData);
}
Expand Down
32 changes: 31 additions & 1 deletion packages/converters/models/NodePenDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ public class NodePenDataTree : Dictionary<string, List<NodePenDataTreeValue>>

public class NodePenDataTreeValue : Base
{

[JsonProperty("type")]
public string Type { get; set; }

Expand All @@ -154,6 +153,17 @@ public class NodePenDataTreeValue : Base

public dynamic Geometry { get; set; } = null;

public void ToDto()
{
Value = null;
Geometry = null;
}

public bool ShouldSerializeGeometry()
{
return Geometry != null;
}

public double UnwrapAsDouble()
{
return Convert.ToDouble(this["Value"]);
Expand All @@ -166,4 +176,24 @@ public int UnwrapAsInteger()

}

public class NodePenDataTreeDto : Dictionary<string, List<NodePenDataTreeValueDto>>
{

}

public class NodePenDataTreeValueDto
{
[JsonProperty("type")]
public string Type { get; set; }

[JsonProperty("description")]
public string Description { get; set; }

public NodePenDataTreeValueDto(NodePenDataTreeValue value)
{
Type = value.Type;
Description = value.Description;
}
}

}

0 comments on commit 5f8777b

Please sign in to comment.