Skip to content

Commit 081467b

Browse files
committed
Cleanup; Comments; JSON constructors for 2.0
1 parent c704def commit 081467b

16 files changed

+107
-35
lines changed

src/Essentials/NodeModelsEssentials/EssentialsAstReusingFunctionCall.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ namespace NodeModelsEssentials
3737
"Division of A by B",
3838
"Sum of all outputs")]
3939
[IsDesignScriptCompatible]
40-
class AstReuseFunction : NodeModel
40+
class AstReusingFunctionCall : NodeModel
4141
{
4242
[JsonConstructor]
43-
private AstReuseFunction(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
43+
private AstReusingFunctionCall(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
4444
{
4545
}
4646

47-
public AstReuseFunction()
47+
public AstReusingFunctionCall()
4848
{
4949
RegisterAllPorts();
5050
}

src/Essentials/NodeModelsEssentials/EssentialsError.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ namespace NodeModelsEssentials
2626

2727
public class Error : NodeModel
2828
{
29-
//[JsonConstructor]
30-
//private Error(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
31-
//{
32-
//}
29+
[JsonConstructor]
30+
private Error(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
31+
{
32+
}
3333

3434
public Error()
3535
{

src/Essentials/NodeModelsEssentials/EssentialsEvents.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Collections;
43
using Dynamo.Graph.Nodes;
54
using ProtoCore.AST.AssociativeAST;
6-
using NodeModelsEssentials.Functions;
7-
using System.Linq;
8-
using Newtonsoft.Json;
95
using System.Windows;
106
using Dynamo.Events;
7+
using System.Linq;
8+
using Newtonsoft.Json;
119

1210
namespace NodeModelsEssentials
1311
{

src/Essentials/NodeModelsEssentials/EssentialsMultiOperation.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
using ProtoCore.AST.AssociativeAST;
55
using NodeModelsEssentials.Functions;
66
using System.Linq;
7+
using Newtonsoft.Json;
78

8-
namespace NodeModelsEssentials.Examples
9+
namespace NodeModelsEssentials
910
{
1011
// <summary>
1112
// Sample Node Model called MultiplyMulti.
@@ -27,6 +28,11 @@ namespace NodeModelsEssentials.Examples
2728
[IsDesignScriptCompatible]
2829
public class MultiOperation : NodeModel
2930
{
31+
[JsonConstructor]
32+
private MultiOperation(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
33+
{
34+
}
35+
3036
public MultiOperation()
3137
{
3238
RegisterAllPorts();

src/Essentials/NodeModelsEssentials/EssentialsMultiply.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
using ProtoCore.AST.AssociativeAST;
55
using NodeModelsEssentials.Functions;
66
using System.Linq;
7+
using Newtonsoft.Json;
78

8-
namespace NodeModelsEssentials.Examples
9+
namespace NodeModelsEssentials
910
{
1011
/*
1112
* This example shows how to create a node model for Dynamo
@@ -62,6 +63,18 @@ namespace NodeModelsEssentials.Examples
6263
[IsDesignScriptCompatible]
6364
public class Multiply : NodeModel
6465
{
66+
/// <summary>
67+
/// The JSON constructor of a NodeModel is used to
68+
/// instantiate (or deserialize) a node when read
69+
/// from a JSON .dyn file.
70+
/// </summary>
71+
/// <param name="inPorts"></param>
72+
/// <param name="outPorts"></param>
73+
[JsonConstructor]
74+
private Multiply(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
75+
{
76+
}
77+
6578
/// <summary>
6679
/// The constructor for a NodeModel is used to create
6780
/// the input and output ports and specify the argument

src/Essentials/NodeModelsEssentials/EssentialsTimeout.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
using Dynamo.Graph.Nodes;
44
using ProtoCore.AST.AssociativeAST;
55
using NodeModelsEssentials.Functions;
6-
using Newtonsoft.Json;
76
using System.Linq;
7+
using Newtonsoft.Json;
88

99
namespace NodeModelsEssentials
1010
{

src/Essentials/NodeModelsEssentials/GeometryCustomPreview.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
using Dynamo.Graph.Nodes;
44
using ProtoCore.AST.AssociativeAST;
55
using NodeModelsEssentials.Functions;
6-
using Newtonsoft.Json;
76
using System.Linq;
7+
using Newtonsoft.Json;
88

9-
namespace NodeModelsEssentials.Examples
9+
namespace NodeModelsEssentials
1010
{
1111
/*
1212
* This example shows how to create a node model for Dynamo
@@ -63,6 +63,18 @@ namespace NodeModelsEssentials.Examples
6363
[IsDesignScriptCompatible]
6464
public class CustomPreview : NodeModel
6565
{
66+
/// <summary>
67+
/// The JSON constructor of a NodeModel is used to
68+
/// instantiate (or deserialize) a node when read
69+
/// from a JSON .dyn file.
70+
/// </summary>
71+
/// <param name="inPorts"></param>
72+
/// <param name="outPorts"></param>
73+
[JsonConstructor]
74+
private CustomPreview(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
75+
{
76+
}
77+
6678
/// <summary>
6779
/// The constructor for a NodeModel is used to create
6880
/// the input and output ports and specify the argument

src/Essentials/NodeModelsEssentials/GeometrySurfaceFrom4Points.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
using NodeModelsEssentials.Functions;
66
using Autodesk.DesignScript.Geometry;
77
using System.Linq;
8+
using Newtonsoft.Json;
89

9-
namespace NodeModelsEssentials.Examples
10+
namespace NodeModelsEssentials
1011
{
1112
// <summary>
1213
// A simple node to create a surface from four points.
@@ -27,6 +28,11 @@ namespace NodeModelsEssentials.Examples
2728
[IsDesignScriptCompatible]
2829
public class SurfaceFrom4Points : NodeModel
2930
{
31+
[JsonConstructor]
32+
private SurfaceFrom4Points(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
33+
{
34+
}
35+
3036
public SurfaceFrom4Points()
3137
{
3238
RegisterAllPorts();

src/Essentials/NodeModelsEssentials/GeometryUVPlanesOnSurface.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
using NodeModelsEssentials.Functions;
66
using Autodesk.DesignScript.Geometry;
77
using System.Linq;
8+
using Newtonsoft.Json;
89

9-
namespace NodeModelsEssentials.Examples
10+
namespace NodeModelsEssentials
1011
{
1112
// <summary>
1213
// Given a surface, returns a grid of UV tangent planes.
@@ -23,6 +24,11 @@ namespace NodeModelsEssentials.Examples
2324
[IsDesignScriptCompatible]
2425
public class UVPlanesOnSurface : NodeModel
2526
{
27+
[JsonConstructor]
28+
private UVPlanesOnSurface(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
29+
{
30+
}
31+
2632
public UVPlanesOnSurface()
2733
{
2834
RegisterAllPorts();

src/Essentials/NodeModelsEssentials/GeometryWobblySurface.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
using NodeModelsEssentials.Functions;
66
using Autodesk.DesignScript.Geometry;
77
using System.Linq;
8+
using Newtonsoft.Json;
89

9-
namespace NodeModelsEssentials.Examples
10+
namespace NodeModelsEssentials
1011
{
1112

1213
// <summary>
@@ -24,6 +25,11 @@ namespace NodeModelsEssentials.Examples
2425
[IsDesignScriptCompatible]
2526
public class WobblySurface : NodeModel
2627
{
28+
[JsonConstructor]
29+
private WobblySurface(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
30+
{
31+
}
32+
2733
public WobblySurface()
2834
{
2935
RegisterAllPorts();

src/Essentials/NodeModelsEssentials/UIButton.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
using NodeModelsEssentials.Functions;
1111
using NodeModelsEssentials.Controls;
1212
using Dynamo.UI.Commands;
13+
using Newtonsoft.Json;
1314

14-
namespace NodeModelsEssentials.Examples
15+
namespace NodeModelsEssentials
1516
{
1617
[NodeName("UI.Button")]
1718
[NodeDescription("A sample Node Model with custom UI.")]
@@ -53,6 +54,11 @@ public double Number
5354

5455
#region constructor
5556

57+
[JsonConstructor]
58+
private CustomUINodeModelButton(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
59+
{
60+
}
61+
5662
public CustomUINodeModelButton()
5763
{
5864
RegisterAllPorts();

src/Essentials/NodeModelsEssentials/UIButtonFunction.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
using NodeModelsEssentials.Controls;
1212
using Dynamo.UI.Commands;
1313
using VMDataBridge;
14+
using Newtonsoft.Json;
1415

15-
namespace NodeModelsEssentials.Examples
16+
namespace NodeModelsEssentials
1617
{
1718
[NodeName("UI.ButtonFunction")]
1819
[NodeDescription("A sample Node Model with custom UI.")]
@@ -56,6 +57,11 @@ public double Number
5657

5758
#region constructor
5859

60+
[JsonConstructor]
61+
private CustomUINodeModelButtonFunction(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
62+
{
63+
}
64+
5965
public CustomUINodeModelButtonFunction()
6066
{
6167
Executed = new Action(() => {

src/Essentials/NodeModelsEssentials/UICopyableWatch.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
using System;
22
using System.Collections.Generic;
3-
//using System.Windows;
4-
//using System.Windows.Controls;
53
using Dynamo.Controls;
64
using Dynamo.Graph.Nodes;
75
using Dynamo.Events;
8-
//using Dynamo.UI.Commands;
96
using Dynamo.Wpf;
107
using ProtoCore.AST.AssociativeAST;
118
using Autodesk.DesignScript.Runtime;
129
using NodeModelsEssentials.Controls;
13-
//using NodeModelsEssentials.Functions;
1410
using System.Linq;
15-
//using Dynamo.Graph.Workspaces;
1611
using VMDataBridge;
12+
using Newtonsoft.Json;
1713

1814
namespace NodeModelsEssentials
1915
{
@@ -58,6 +54,11 @@ public string Text
5854

5955
#region constructor
6056

57+
[JsonConstructor]
58+
private UICopyableWatch(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
59+
{
60+
}
61+
6162
public UICopyableWatch()
6263
{
6364
Executed = new Action(() => {

src/Essentials/NodeModelsEssentials/UISlider.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Windows;
4-
using System.Windows.Controls;
53
using Dynamo.Controls;
64
using Dynamo.Graph.Nodes;
75
using Dynamo.UI.Commands;
@@ -10,8 +8,9 @@
108
using Autodesk.DesignScript.Runtime;
119
using NodeModelsEssentials.Controls;
1210
using System.Linq;
11+
using Newtonsoft.Json;
1312

14-
namespace NodeModelsEssentials.Examples
13+
namespace NodeModelsEssentials
1514
{
1615
[NodeName("UI.Slider")]
1716
[NodeDescription("A sample Node Model with custom Wpf UI.")]
@@ -74,6 +73,11 @@ public double Number
7473

7574
#region constructor
7675

76+
[JsonConstructor]
77+
private CustomUIWpfNodeModel(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
78+
{
79+
}
80+
7781
public CustomUIWpfNodeModel()
7882
{
7983
RegisterAllPorts();

src/Essentials/NodeModelsEssentials/UISliderBound.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Windows;
4-
using System.Windows.Controls;
53
using Dynamo.Controls;
64
using Dynamo.Graph.Nodes;
75
using Dynamo.UI.Commands;
@@ -11,8 +9,9 @@
119
using NodeModelsEssentials.Controls;
1210
using NodeModelsEssentials.Functions;
1311
using System.Linq;
12+
using Newtonsoft.Json;
1413

15-
namespace NodeModelsEssentials.Examples
14+
namespace NodeModelsEssentials
1615
{
1716
[NodeName("UI.SliderBound")]
1817
[NodeDescription("A sample Node Model with custom Wpf UI.")]
@@ -79,6 +78,11 @@ public int Index
7978

8079
#region constructor
8180

81+
[JsonConstructor]
82+
private CustomUINodeModelWpfSliderBound(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
83+
{
84+
}
85+
8286
public CustomUINodeModelWpfSliderBound()
8387
{
8488
RegisterAllPorts();

src/Essentials/NodeModelsEssentials/UIState.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Windows;
4-
using System.Windows.Controls;
53
using Dynamo.Controls;
64
using Dynamo.Graph.Nodes;
75
using Dynamo.UI.Commands;
@@ -11,8 +9,9 @@
119
using Autodesk.DesignScript.Runtime;
1210
using NodeModelsEssentials.Controls;
1311
using NodeModelsEssentials.Functions;
12+
using Newtonsoft.Json;
1413

15-
namespace NodeModelsEssentials.Examples
14+
namespace NodeModelsEssentials
1615
{
1716
[NodeName("UI.State")]
1817
[NodeDescription("A sample Node Model with custom Wpf UI.")]
@@ -98,6 +97,11 @@ public double Number
9897

9998
#region constructor
10099

100+
[JsonConstructor]
101+
private CustomUINodeModelWpfState(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
102+
{
103+
}
104+
101105
public CustomUINodeModelWpfState()
102106
{
103107
RegisterAllPorts();

0 commit comments

Comments
 (0)