I have kind of a unique scenario that I don’t know how to approach.
I’m using GoXam to build cable assemblies and the ‘Links’ are representing wires that connect my nodes together.
I need to include a wiring diagram for each of the Links and my initial thought was to use a ‘Diagram’ that gets associated with the link. If you look at the screen capture below, my intent is to have the user click on the orange cable (Link) and over on the right, they can ‘Add Wiring Diagram’ and this would show a GoXam Diagram where they could drag links between the connectors to define how the wires inside of the cable should be ‘wired’.
I’m using this as my Link definition:
public class MyLink : GraphLinksModelLinkData<String, String>
{
public string HOSE_LENGTH { get; set; }
public string HOSE_WIRE_COUNT { get; set; }
public string HOSE_AWG { get; set; }
public override XElement MakeXElement(XName n)
{
XElement e = base.MakeXElement(n);
e.Add(XHelper.Attribute("HOSE_LENGTH", this.HOSE_LENGTH, ""));
e.Add(XHelper.Attribute("HOSE_WIRE_COUNT", this.HOSE_WIRE_COUNT, ""));
e.Add(XHelper.Attribute("HOSE_AWG", this.HOSE_AWG, ""));
return e;
}
public override void LoadFromXElement(XElement e)
{
base.LoadFromXElement(e);
this.HOSE_LENGTH = XHelper.Read("HOSE_LENGTH", e, "");
this.HOSE_WIRE_COUNT = XHelper.Read("HOSE_WIRE_COUNT", e, "");
this.HOSE_AWG = XHelper.Read("HOSE_AWG", e, "");
}
}
The problem is that I need to be able to save this entire assembly to a database - so I need someway to translate this to and from XML.
I thought that maybe I could do something like this:
public class MyLink : GraphLinksModelLinkData<String, String>
{
public string HOSE_LENGTH { get; set; }
public string HOSE_WIRE_COUNT { get; set; }
public string HOSE_AWG { get; set; }
<b> public GraphLinksModelNodeData<WiringDiagram> WIRING_DIAGRAM { get; set; }</b>
public override XElement MakeXElement(XName n)
{
XElement e = base.MakeXElement(n);
e.Add(XHelper.Attribute("HOSE_LENGTH", this.HOSE_LENGTH, ""));
e.Add(XHelper.Attribute("HOSE_WIRE_COUNT", this.HOSE_WIRE_COUNT, ""));
e.Add(XHelper.Attribute("HOSE_AWG", this.HOSE_AWG, ""));
return e;
}
public override void LoadFromXElement(XElement e)
{
base.LoadFromXElement(e);
this.HOSE_LENGTH = XHelper.Read("HOSE_LENGTH", e, "");
this.HOSE_WIRE_COUNT = XHelper.Read("HOSE_WIRE_COUNT", e, "");
this.HOSE_AWG = XHelper.Read("HOSE_AWG", e, "");
}
}
public class WiringDiagram : GraphLinksModelNodeData<String>
{
}
public class WiringDiagramLinks : GraphLinksModelLinkData<String, String>
{
}
…but even if I do get this working, how would I even convert this to XML for saving.
I’m wondering if you’ve run into this before and maybe have some other suggestions or maybe a different direction that I should be going in.
Thanks!