Skip to content

Commit

Permalink
Add concrete dispatching over as dynamic
Browse files Browse the repository at this point in the history
Fix for now. Previous code should, and was, working, but stopped. Changing to explicit type checking and casting to make code work for now
  • Loading branch information
IsakNaslundBh committed Jan 24, 2023
1 parent 211fd2d commit 5839457
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion Robot_Adapter/CRUD/Create/Loads/Loads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
using BH.Engine.Structure;
using System.Linq;
using RobotOM;
using BH.oM.Structure.Elements;

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

private bool ICheckLoad(ILoad load)
{
return CheckLoad(load as dynamic);
//Dynamic dispatching should be working, and was working up to a point where it all of a sudden stopped.
//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
//Code further down as a fix for now

//return CheckLoad(load as dynamic);

//This _should_ not be needed. as dynamic call above _should_ work and _was_ working.
if(load is IElementLoad<Bar>)
return CheckLoad(load as IElementLoad<Bar>);
if(load is IElementLoad<Node>)
return CheckLoad(load as IElementLoad<Node>);
if(load is IElementLoad<IAreaElement>)
return CheckLoad(load as IElementLoad<IAreaElement>);
if(load is IElementLoad<BHoMObject>)
return CheckLoad(load as IElementLoad<BHoMObject>);
if (load is IElementLoad<IBHoMObject>)
return CheckLoad(load as IElementLoad<IBHoMObject>);
if (load is IElementLoad<Panel>)
return CheckLoad(load as IElementLoad<Panel>);
if(load is IElementLoad<FEMesh>)
return CheckLoad(load as IElementLoad<FEMesh>);

return CheckLoad(load);
}

/***************************************************/
Expand Down

0 comments on commit 5839457

Please sign in to comment.