About EasyMorph Tutorials & Examples Web-help

Example: Transforming data with a custom C# or any other .Net code

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:

  1. Write your custom .Net code
  2. Compile your code to a .Net assembly
  3. Use the PowerShell action to:
    • Load that assembly
    • Process EasyMorph data by calling members from that assembly
    • Produce a PowerShell output collection
  4. 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:

  1. An EasyMorph dataset is passed to a PowerShell when the “Input pipeline” option of the PowerShell action set to “Table”.
  2. A PowerShell script loads .Net assembly with the custom code with [Reflection.Assembly]::LoadFile() method and creates an instance of a custom class.
  3. 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.
  4. 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)

1 Like
To learn more about EasyMorph visit easymorph.com.