Hi All,
I have a custom data structure - e.g. Person class as seen below and want to send an instance of this as my nodes output.
I initialise a new class and assign all values, then try to create an associative node via AstFactory.BuildPrimitiveNodeFromObject since this seems to be the only way to support custom data and afterwards I want to assign this to the output 0 using AstFactory.BuildAssignment.
However, this does not work and the plugin crashes with the following message:
ProtoCore.Exceptions.CompilerInternalException: ‘Exception of type ‘ProtoCore.Exceptions.CompilerInternalException’ was thrown.’
Any idea what went wrong or how to do this in a better way (preferably not using the detour of a zero touch function)?
Code:
using System;
using System.Collections.Generic;
using Dynamo.Graph.Nodes;
using ProtoCore.AST.AssociativeAST;
namespace Plugin
{
public class Person
{
public int ID { get; set; }
public string Prename { get; set; }
public string Surname { get; set; }
public Person() { }
}
[IsDesignScriptCompatible]
[NodeName("Plugin")]
[NodeDescription("Plugin")]
[NodeCategory("Plugin")]
[OutPortNames("P")]
[OutPortTypes("")]
[OutPortDescriptions("Person")]
public class Person_Node : NodeModel
{
public Person_Node()
{
RegisterAllPorts();
}
public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
{
Person p = new Person() { ID = 1, Prename = "Frank", Surname = "Gehry" };
var assnode = AstFactory.BuildPrimitiveNodeFromObject((object)p);
return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), assnode) };
}
}
}