-
Notifications
You must be signed in to change notification settings - Fork 7
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
BHoM_Adapter refactoring Lvl3_01 - workaround to have the CRUD working for non-BHoMObjects #142
Conversation
…here the deepclone and the tag addition
…fig and config to pushConfig for clarity.
…). Moved the function back in the Push.
BHoM_Adapter/BHoMAdapter.cs
Outdated
// Wrap non-BHoM objects into a Custom BHoMObject to make them work as BHoMObjects. | ||
List<IObject> objectsToPush = Modify.WrapNonBHoMObjects(objects, Config, tag, pushConfig).ToList(); | ||
|
||
// Clone the objects for immutability in the UI. CloneBeforePush should always be true, except for very specific cases. | ||
objectsToPush = Config.CloneBeforePush ? objects.Select(x => x.DeepClone()).ToList() : objects.ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IsakNaslundBh the reason for WrapNonBHoMObjects()
checking the boolean WrapNonBHoMObjects
inside the method itself is because this way we can freely override the default Adapter setting through the Push config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small error in picking correct objects when wrapping is done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Works as expected
Issues addressed by this PR
Closes #140
Also adds some comments and a few renamings for clarity.
Test script
https://burohappold.sharepoint.com/:u:/s/BHoM/ERekpoPskXFOuC66VS7yG74BFNT5HaGuqKBFTcOj_qRvfw?e=qCF92Q
Changelog
WrapNonBHoMObjects()
method. Wraps non-BHoMObjects into Custom BHoM Objects so they can make use of the Adapter Replace/Crud methods as the BHoMObjects (they get an ID, CustomData, etc).AdapterConfig.WrapNonBHoMObjects
that defines default Toolkit behaviour for that method. Defaults to false, as it should be used only in few specific Toolkits.config
boolean option that overrides the defaultAdapterConfig
setting if specified, so the user has control over the specific Push case.