EasyMorph datasets can be relatively easily transformed or validated using a custom C# code (or code in any other CLI language). In order to do that:
- Write your custom .Net code
- Compile your code to a .Net assembly
- Use the PowerShell action to:
- Load that assembly
- Process EasyMorph data by calling members from that assembly
- Produce a PowerShell output collection
- Parse the output collection, captured by the PowerShell action.
In the same way, a third-party .Net assembly (from a NuGet package, for example) can be executed from an EasyMorph project. That gives EasyMorph users the ability to implement import and export to/from file formats or services which are not natively supported by EasyMorph, apply complex calculation logic (e.g. scoring models), or perform domain-specific data parsing/validation.
Here is a simple example that modifies an EasyMorph dataset by calling methods of a custom C# class.
It works as follows:
- An EasyMorph dataset is passed to a PowerShell when the “Input pipeline” option of the PowerShell action set to “Table”.
- A PowerShell script loads .Net assembly with the custom code with
[Reflection.Assembly]::LoadFile()method and creates an instance of a custom class.
- The PowerShell script iterates over the passed dataset, transforms its elements by executing static and instance methods of the custom class and outputs execution results.
- The output is captured by the PowerShell action and then parsed with other EasyMorph actions.
Here is a ZIP archive with the example project with custom DLL and a Visual Studio solution which was used to create that DLL: TransformDataWithCustomDll.zip (54.7 KB)