Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align with changes in oM and Engine on Reflection -> Base #413

Merged
merged 4 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions BHoM_UI/BHoM_UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,37 @@
<Reference Include="Adapter_oM">
<HintPath>C:\ProgramData\BHoM\Assemblies\Adapter_oM.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="BHoM">
<HintPath>C:\ProgramData\BHoM\Assemblies\BHoM.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="BHoM_Adapter">
<HintPath>C:\ProgramData\BHoM\Assemblies\BHoM_Adapter.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="BHoM_Engine">
<HintPath>C:\ProgramData\BHoM\Assemblies\BHoM_Engine.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Data_Engine">
<HintPath>C:\ProgramData\BHoM\Assemblies\Data_Engine.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Data_oM">
<HintPath>C:\ProgramData\BHoM\Assemblies\Data_oM.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Geometry_Engine">
<HintPath>C:\ProgramData\BHoM\Assemblies\Geometry_Engine.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Geometry_oM">
<SpecificVersion>False</SpecificVersion>
Expand All @@ -67,6 +74,7 @@
<Reference Include="Library_Engine">
<HintPath>C:\ProgramData\BHoM\Assemblies\Library_Engine.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="PresentationCore">
<Private>False</Private>
Expand All @@ -77,22 +85,22 @@
<Reference Include="Programming_oM">
<HintPath>C:\ProgramData\BHoM\Assemblies\Programming_oM.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Quantities_oM">
<HintPath>C:\ProgramData\BHoM\Assemblies\Quantities_oM.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Reflection_Engine">
<HintPath>C:\ProgramData\BHoM\Assemblies\Reflection_Engine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Reflection_oM">
<HintPath>C:\ProgramData\BHoM\Assemblies\Reflection_oM.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Serialiser_Engine">
<HintPath>C:\ProgramData\BHoM\Assemblies\Serialiser_Engine.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="System">
<Private>False</Private>
Expand Down Expand Up @@ -135,10 +143,12 @@
<Reference Include="Versioning_Engine">
<HintPath>C:\ProgramData\BHoM\Assemblies\Versioning_Engine.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Versioning_oM">
<HintPath>C:\ProgramData\BHoM\Assemblies\Versioning_oM.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="WindowsBase">
<Private>False</Private>
Expand Down
1 change: 0 additions & 1 deletion BHoM_UI/Caller/AddToMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

using BH.Engine.Reflection;
using BH.oM.Reflection;
using BH.oM.UI;
using System;
using System.Collections.Generic;
Expand Down
3 changes: 1 addition & 2 deletions BHoM_UI/Caller/Compile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.Engine.Reflection;
using BH.oM.Reflection;
using BH.Engine.Base;
using BH.oM.UI;
using System;
using System.Collections.Generic;
Expand Down
1 change: 0 additions & 1 deletion BHoM_UI/Caller/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

using BH.Engine.Reflection;
using BH.oM.Reflection;
using BH.oM.UI;
using System;
using System.Collections.Generic;
Expand Down
1 change: 0 additions & 1 deletion BHoM_UI/Caller/IO_CRUD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

using BH.Engine.Reflection;
using BH.oM.Reflection;
using BH.oM.UI;
using System;
using System.Collections.Generic;
Expand Down
5 changes: 2 additions & 3 deletions BHoM_UI/Caller/Read.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

using BH.Engine.Reflection;
using BH.oM.Reflection;
using BH.oM.UI;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -78,7 +77,7 @@ public virtual bool Read(string json)
}
catch
{
BH.Engine.Reflection.Compute.RecordError($"{this} failed to deserialise itself.");
BH.Engine.Base.Compute.RecordError($"{this} failed to deserialise itself.");
return false;
}
}
Expand Down Expand Up @@ -137,7 +136,7 @@ protected bool RestoreItem(object selectedItem, List<ParamInfo> inputParams, Lis
// Record warnings if changes happened
List<IParamUpdate> paramUpdates = update.InputUpdates.Concat(update.OutputUpdates).ToList();
if (paramUpdates.Count > 0)
Engine.Reflection.Compute.RecordWarning("This component was upgraded. Here's the resulting changes: \n"
Engine.Base.Compute.RecordWarning("This component was upgraded. Here's the resulting changes: \n"
+ paramUpdates.Select(x => " - " + x.IToText()).Aggregate((a, b) => a + "\n" + b));

// Send the notification
Expand Down
25 changes: 12 additions & 13 deletions BHoM_UI/Caller/Run.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

using BH.Engine.Reflection;
using BH.oM.Reflection;
using BH.Engine.Base;
using BH.oM.UI;
using System;
using System.Collections.Generic;
Expand All @@ -30,9 +30,8 @@
using System.Reflection;
using BH.Engine.Serialiser;
using System.Windows.Forms;
using BH.oM.Base;
using System.Collections;
using BH.oM.Reflection.Debugging;
using BH.oM.Base.Debugging;

namespace BH.UI.Base
{
Expand All @@ -44,7 +43,7 @@ public abstract partial class Caller

public virtual bool Run()
{
BH.Engine.Reflection.Compute.ClearCurrentEvents();
BH.Engine.Base.Compute.ClearCurrentEvents();

// Get all the inputs
List<object> inputs = CollectInputs();
Expand Down Expand Up @@ -87,7 +86,7 @@ public virtual object Run(List<object> inputs)
if (originalMethod != null && originalMethod.IsGenericMethod)
{
// Try to update the generic method to fit the input types
MethodInfo method = Engine.Reflection.Compute.MakeGenericFromInputs(originalMethod, inputs.Select(x => x?.GetType()).ToList());
MethodInfo method = Engine.Base.Compute.MakeGenericFromInputs(originalMethod, inputs.Select(x => x?.GetType()).ToList());
m_CompiledFunc = method.ToFunc();
return m_CompiledFunc(inputs.ToArray());
}
Expand All @@ -97,12 +96,12 @@ public virtual object Run(List<object> inputs)
}
else if (InputParams.Count <= 0)
{
BH.Engine.Reflection.Compute.RecordWarning("This is a magic component. Right click on it and <Select a method>");
BH.Engine.Base.Compute.RecordWarning("This is a magic component. Right click on it and <Select a method>");
return null;
}
else
{
BH.Engine.Reflection.Compute.RecordError("The component is not linked to a method.");
BH.Engine.Base.Compute.RecordError("The component is not linked to a method.");
return null;
}
}
Expand All @@ -123,7 +122,7 @@ protected virtual List<object> CollectInputs()
object input = null;
if (InputParams[i].IsSelected)
{
int preGetterEventCount = Engine.Reflection.Query.CurrentEvents().Where(x => x.Type == EventType.Error).Count();
int preGetterEventCount = Engine.Base.Query.CurrentEvents().Where(x => x.Type == EventType.Error).Count();

try
{
Expand All @@ -133,11 +132,11 @@ protected virtual List<object> CollectInputs()
{
string warning = InputParams[i].DefaultValueWarning;
if (!string.IsNullOrEmpty(warning))
Engine.Reflection.Compute.RecordNote(warning);
Engine.Base.Compute.RecordNote(warning);

// Temporary solution to handle error casting events that didn't throw an exception.
// Long term, we need Events of different types to better identify them instead of relying on message content.
int newErrorCount = Engine.Reflection.Query.CurrentEvents().Skip(preGetterEventCount).Where(x => x.Type == EventType.Error).Where(x => x.Message.StartsWith("Failed to cast")).Count();
int newErrorCount = Engine.Base.Query.CurrentEvents().Skip(preGetterEventCount).Where(x => x.Type == EventType.Error).Where(x => x.Message.StartsWith("Failed to cast")).Count();
if (newErrorCount > 0)
throw new Exception();
}
Expand All @@ -148,7 +147,7 @@ protected virtual List<object> CollectInputs()
MethodInfo originalMethod = m_OriginalItem as MethodInfo;
if (originalInputType != null && originalInputType.IsGenericType && originalMethod != null && originalMethod.IsGenericMethod)
{
Engine.Reflection.Compute.RemoveEvents(Engine.Reflection.Query.CurrentEvents().Skip(preGetterEventCount).ToList());
Engine.Base.Compute.RemoveEvents(Engine.Base.Query.CurrentEvents().Skip(preGetterEventCount).ToList());
UpdateInputGenericType(i);
input = m_CompiledGetters[i](m_DataAccessor, index);
}
Expand All @@ -161,7 +160,7 @@ protected virtual List<object> CollectInputs()
{
string warning = InputParams[i].DefaultValueWarning;
if (!string.IsNullOrEmpty(warning))
Engine.Reflection.Compute.RecordNote(warning);
Engine.Base.Compute.RecordNote(warning);
input = InputParams[i].DefaultValue;
}

Expand Down Expand Up @@ -192,7 +191,7 @@ protected virtual bool PushOutputs(object result)
for (int i = 0; i < m_CompiledSetters.Count; i++)
{
// There is a problem when the output is a list of one apparently (try to explode a tree with a single branch on the first level)
object output = (m_CompiledSetters.Count == 1) ? result : BH.Engine.Reflection.Query.IItem(result, i);
object output = (m_CompiledSetters.Count == 1) ? result : BH.Engine.Base.Query.IItem(result, i);

try
{
Expand Down
1 change: 0 additions & 1 deletion BHoM_UI/Caller/SetComponentDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

using BH.Engine.Reflection;
using BH.oM.Reflection;
using BH.oM.UI;
using System;
using System.Collections.Generic;
Expand Down
5 changes: 2 additions & 3 deletions BHoM_UI/Caller/SetInputs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

using BH.Engine.Reflection;
using BH.oM.Reflection;
using BH.oM.Base;
using BH.oM.UI;
using System;
using System.Collections.Generic;
Expand All @@ -30,10 +30,9 @@
using System.Reflection;
using BH.Engine.Serialiser;
using System.Windows.Forms;
using BH.oM.Base;
using System.Collections;
using BH.Engine.UI;
using BH.oM.Reflection.Attributes;
using BH.oM.Base.Attributes;

namespace BH.UI.Base
{
Expand Down
1 change: 0 additions & 1 deletion BHoM_UI/Caller/SetItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

using BH.Engine.Reflection;
using BH.oM.Reflection;
using BH.oM.UI;
using System;
using System.Collections.Generic;
Expand Down
6 changes: 3 additions & 3 deletions BHoM_UI/Caller/SetOutputs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
*/

using BH.Engine.Reflection;
using BH.oM.Reflection;
using BH.Engine.Base;
using BH.oM.Base;
using BH.oM.UI;
using System;
using System.Collections.Generic;
Expand All @@ -30,9 +31,8 @@
using System.Reflection;
using BH.Engine.Serialiser;
using System.Windows.Forms;
using BH.oM.Base;
using System.Collections;
using BH.oM.Reflection.Attributes;
using BH.oM.Base.Attributes;

namespace BH.UI.Base
{
Expand Down
1 change: 0 additions & 1 deletion BHoM_UI/Caller/SetParamSelectionMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

using BH.Engine.Reflection;
using BH.oM.Reflection;
using BH.oM.UI;
using System;
using System.Collections.Generic;
Expand Down
3 changes: 1 addition & 2 deletions BHoM_UI/Caller/Write.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

using BH.Engine.Reflection;
using BH.oM.Reflection;
using BH.oM.UI;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -53,7 +52,7 @@ public virtual string Write()
}
catch
{
BH.Engine.Reflection.Compute.RecordError($"{this} failed to serialise itself.");
BH.Engine.Base.Compute.RecordError($"{this} failed to serialise itself.");
return "";
}
}
Expand Down
1 change: 0 additions & 1 deletion BHoM_UI/CallerTemplates/MultiChoiceCaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

using BH.Engine.Reflection;
using BH.oM.Reflection;
using BH.oM.UI;
using System;
using System.Collections.Generic;
Expand Down
5 changes: 2 additions & 3 deletions BHoM_UI/Components/Adapter/Execute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@
using BH.oM.Base;
using BH.oM.Adapter;
using BH.oM.Data.Requests;
using BH.oM.Reflection.Attributes;
using BH.oM.Base.Attributes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BH.oM.Reflection;

namespace BH.UI.Base.Components
{
Expand Down Expand Up @@ -97,7 +96,7 @@ public static Output<List<object>, bool> Execute(BHoMAdapter adapter, IExecuteCo
ActionConfig executeConfig = null;
if (!adapter.SetupExecuteConfig(actionConfig, out executeConfig))
{
BH.Engine.Reflection.Compute.RecordError($"Invalid `{nameof(actionConfig)}` input.");
BH.Engine.Base.Compute.RecordError($"Invalid `{nameof(actionConfig)}` input.");
return result;
}

Expand Down
8 changes: 4 additions & 4 deletions BHoM_UI/Components/Adapter/Move.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
using BH.oM.Base;
using BH.oM.Adapter;
using BH.oM.Data.Requests;
using BH.oM.Reflection.Attributes;
using BH.oM.Base.Attributes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
Expand Down Expand Up @@ -93,21 +93,21 @@ public static bool Move(BHoMAdapter source, BHoMAdapter target, object request =
IRequest actualRequest = null;
if (!source.SetupPullRequest(request, out actualRequest))
{
BH.Engine.Reflection.Compute.RecordError($"Invalid `{nameof(request)}` input.");
BH.Engine.Base.Compute.RecordError($"Invalid `{nameof(request)}` input.");
return false;
}

ActionConfig pullCfg = null;
if (!source.SetupPullConfig(pullConfig, out pullCfg))
{
BH.Engine.Reflection.Compute.RecordError($"Invalid `{nameof(pullConfig)}` input.");
BH.Engine.Base.Compute.RecordError($"Invalid `{nameof(pullConfig)}` input.");
return false;
}

ActionConfig pushCfg = null;
if (!source.SetupPushConfig(pushConfig, out pushCfg))
{
BH.Engine.Reflection.Compute.RecordError($"Invalid `{nameof(pushConfig)}` input.");
BH.Engine.Base.Compute.RecordError($"Invalid `{nameof(pushConfig)}` input.");
return false;
}

Expand Down
Loading