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

Aligning with changes in BHoMAdapter Refactoring Level 04 #58

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
31 changes: 31 additions & 0 deletions EnergyPlus_Adapter/AdapterActions/Push.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using BH.oM.Data.Requests;
using BH.oM.Adapter;
using BH.oM.Base;
using System.Reflection;

namespace BH.Adapter.EnergyPlus
{
public partial class EnergyPlusAdapter : BHoMAdapter
{
public override List<object> Push(IEnumerable<object> objects, String tag = "", PushType pushType = PushType.AdapterDefault, ActionConfig actionConfig = null)
{
// If unset, set the pushType to AdapterSettings' value (base AdapterSettings default is FullCRUD).
if (pushType == PushType.AdapterDefault)
pushType = m_AdapterSettings.DefaultPushType;

IEnumerable<IBHoMObject> objectsToPush = ProcessObjectsForPush(objects, actionConfig); // Note: default Push only supports IBHoMObjects.

bool success = true;

CreateModel(objectsToPush.ToList());

return success ? objects.ToList() : new List<object>();
}
}
}
4 changes: 3 additions & 1 deletion EnergyPlus_Adapter/CRUD/Create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
using BHC = BH.oM.Physical.Constructions;
using BHEM = BH.oM.Environment.MaterialFragments;

using BH.oM.Adapter;

namespace BH.Adapter.EnergyPlus
{
public partial class EnergyPlusAdapter : BHoMAdapter
{
protected override bool Create<T>(IEnumerable<T> objects)
protected override bool ICreate<T>(IEnumerable<T> objects, ActionConfig actionConfig = null)
{
bool success = true;

Expand Down
13 changes: 0 additions & 13 deletions EnergyPlus_Adapter/CRUD/Delete.cs

This file was deleted.

26 changes: 0 additions & 26 deletions EnergyPlus_Adapter/CRUD/Read.cs

This file was deleted.

13 changes: 0 additions & 13 deletions EnergyPlus_Adapter/CRUD/Update.cs

This file was deleted.

30 changes: 1 addition & 29 deletions EnergyPlus_Adapter/EnergyPlusAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Threading.Tasks;

using BH.oM.Base;
//using System.Reflection;
using BH.oM.Data.Requests;
using BH.oM.Reflection.Attributes;
using System.ComponentModel;
Expand All @@ -22,36 +21,9 @@ public EnergyPlusAdapter(string idfFilePath)
BH.Engine.Reflection.Compute.RecordWarning("This adapter is under development. Its use is not yet sanctioned for project work. You use this at your own risk. Check the GitHub repo for the latest version and updates on development status");
IDFFilePath = idfFilePath;

AdapterId = "EnergyPlus_Adapter";
Config.UseAdapterId = false; //Set to true when NextId method and id tagging has been implemented
AdapterIdName = "EnergyPlus_Adapter";
}

public override List<IObject> Push(IEnumerable<IObject> objects, String tag = "", Dictionary<String, object> config = null)
{
bool success = true;

//MethodInfo methodInfos = typeof(Enumerable).GetMethod("Cast");
/*foreach (var typeGroup in objects.GroupBy(x => x.GetType()))
{
MethodInfo mInfo = methodInfos.MakeGenericMethod(new[] { typeGroup.Key });
var list = mInfo.Invoke(typeGroup, new object[] { typeGroup });
success &= Create(list as dynamic, false);
}*/

CreateModel(objects.ToList().ConvertAll(x => (IBHoMObject)x).ToList());

return success ? objects.ToList() : new List<IObject>();
}

public override IEnumerable<object> Pull(IRequest request, Dictionary<string, object> config = null)
{
if (request is IRequest)
return Read();

return new List<IBHoMObject>();
}


private string IDFFilePath { get; set; }
}
}
8 changes: 5 additions & 3 deletions EnergyPlus_Adapter/EnergyPlus_Adapter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Adapter_oM">
<HintPath>..\..\BHoM_Adapter\Build\Adapter_oM.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Analytical_oM, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\BHoM\Build\Analytical_oM.dll</HintPath>
Expand Down Expand Up @@ -97,10 +101,8 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AdapterActions\Push.cs" />
<Compile Include="CRUD\Create.cs" />
<Compile Include="CRUD\Delete.cs" />
<Compile Include="CRUD\Read.cs" />
<Compile Include="CRUD\Update.cs" />
<Compile Include="EnergyPlusAdapter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand Down