Skip to content
This repository was archived by the owner on Aug 18, 2021. It is now read-only.
This repository was archived by the owner on Aug 18, 2021. It is now read-only.

Duplicated logic to copy from/to LightModel and LightViewModels #28

Open
@guilhermeluizsp

Description

@guilhermeluizsp

Both LightModel and LightViewModel have methods to copy properties from one object to another via reflection:

https://github.com/Avanade/Liquid-Application-Framework/blob/d625dff6d3af90fc9aba210f8898564b7b4f02c7/src/Liquid.Repository/Model/LightModel.cs#L68-L177

https://github.com/Avanade/Liquid-Application-Framework/blob/d625dff6d3af90fc9aba210f8898564b7b4f02c7/src/Liquid.Domain/ViewModel/LightViewModel.cs#L66-L192

We can notice a couple of issues

Violation of the DRY Principle

Both classes have this DynamicHelperData method which does the exact same thing.
Also, the DynamicHelperDataand the MapTo methods have essentially the same logic.

They don't make a deep copy of the object

They just pass the reference around on complex types, resulting in a shallow copy.

The framework already provides a method to make a deep copy of an object. This method can be found at the WorkBenchExtensions class:

https://github.com/Avanade/Liquid-Application-Framework/blob/d625dff6d3af90fc9aba210f8898564b7b4f02c7/src/Liquid.Base/WorkBenchExtensions.cs#L1-L48

We should favor the use of this method as it solves the problems listed above

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcomplexity:highThe complexity of the issue is highsize:largeThe size of the issue is large

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions