Skip to content

Commit 5839457

Browse files
committed
Add concrete dispatching over as dynamic
Fix for now. Previous code should, and was, working, but stopped. Changing to explicit type checking and casting to make code work for now
1 parent 211fd2d commit 5839457

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

Robot_Adapter/CRUD/Create/Loads/Loads.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
using BH.Engine.Structure;
2828
using System.Linq;
2929
using RobotOM;
30+
using BH.oM.Structure.Elements;
3031

3132
namespace BH.Adapter.Robot
3233
{
@@ -61,7 +62,29 @@ private bool CreateCollection(IEnumerable<ILoad> loads)
6162

6263
private bool ICheckLoad(ILoad load)
6364
{
64-
return CheckLoad(load as dynamic);
65+
//Dynamic dispatching should be working, and was working up to a point where it all of a sudden stopped.
66+
//SHould try commenting out this line of code, and/or make a bigger investigation as to why dynamic dispatching is causing an issue in Robot toolkit
67+
//Code further down as a fix for now
68+
69+
//return CheckLoad(load as dynamic);
70+
71+
//This _should_ not be needed. as dynamic call above _should_ work and _was_ working.
72+
if(load is IElementLoad<Bar>)
73+
return CheckLoad(load as IElementLoad<Bar>);
74+
if(load is IElementLoad<Node>)
75+
return CheckLoad(load as IElementLoad<Node>);
76+
if(load is IElementLoad<IAreaElement>)
77+
return CheckLoad(load as IElementLoad<IAreaElement>);
78+
if(load is IElementLoad<BHoMObject>)
79+
return CheckLoad(load as IElementLoad<BHoMObject>);
80+
if (load is IElementLoad<IBHoMObject>)
81+
return CheckLoad(load as IElementLoad<IBHoMObject>);
82+
if (load is IElementLoad<Panel>)
83+
return CheckLoad(load as IElementLoad<Panel>);
84+
if(load is IElementLoad<FEMesh>)
85+
return CheckLoad(load as IElementLoad<FEMesh>);
86+
87+
return CheckLoad(load);
6588
}
6689

6790
/***************************************************/

0 commit comments

Comments
 (0)