Skip to content

Commit

Permalink
Fix detection of upgraded SelectedItem for Types
Browse files Browse the repository at this point in the history
  • Loading branch information
adecler committed Jun 13, 2020
1 parent f958f00 commit 174bea7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions BHoM_UI/Components/oM/CreateObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,22 @@ public override void AddToMenu(object menu)
base.AddToMenu(menu);
}

/*************************************/

protected override bool AreMatching(List<ParamInfo> newList, List<ParamInfo> oldList, bool isInput)
{
if (isInput && SelectedItem is Type)
{
Type type = SelectedItem as Type;
List<PropertyInfo> props = type.GetProperties().ToList();
return oldList.All(x => props.Exists(p => p.Name == x.Name && p.PropertyType == x.DataType));
}
else
{
return base.AreMatching(newList, oldList, isInput);
}
}


/*************************************/
/**** Private Fields ****/
Expand Down
4 changes: 2 additions & 2 deletions BHoM_UI/Templates/Caller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public virtual bool Read(string json)
OutputParams = outputParams;
CompileOutputSetters();
}
else if (!AreMatching(InputParams, inputParams) || !AreMatching(OutputParams, outputParams))
else if (!AreMatching(InputParams, inputParams, true) || !AreMatching(OutputParams, outputParams, false))
{
FindOldIndex(InputParams, inputParams);
FindOldIndex(OutputParams, outputParams);
Expand Down Expand Up @@ -529,7 +529,7 @@ protected void OnDataUpdated()

/*************************************/

protected bool AreMatching(List<ParamInfo> newList, List<ParamInfo> oldList)
protected virtual bool AreMatching(List<ParamInfo> newList, List<ParamInfo> oldList, bool isInput)
{
if (newList.Count != oldList.Count)
return false;
Expand Down

0 comments on commit 174bea7

Please sign in to comment.