You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DocSvartz
changed the title
Fix #524 - Added support Update function TDistination in Object Adapter
Fix issue #524 - Added support Update function TDistination in Object Adapter
Oct 19, 2023
DocSvartz
changed the title
Fix issue #524 - Added support Update function TDistination in Object Adapter
Fix issue #524 - Added support Update function TDestination in Object Adapter
Oct 20, 2023
DocSvartz
changed the title
Fix issue #524 - Added support Update function TDestination in Object Adapter
Added support Update function TDestination in Object Adapter
Oct 20, 2023
DocSvartz
changed the title
Added support Update function TDestination in Object Adapter
Fix issue #524. Adding support for working with Types packed into an object to the standard adapter
Oct 20, 2023
Hello @andrerav
It looks like the simplest and most correct solution would actually be to use the mechanism from the special overload of the Adapt Method.
In general, the Expression for an adapt is created based on the types of generic arguments.
With this call, generation will always occur for the object type as a TSource or TDestination. Since the generic method was called for them: Adapt<object,TDestination>(), Adapt<object,object>(), Adapt<TSource ,object> ( but not Adapt<TSource,TDestination>().
The received conversion Adapt function is called with Runtime arguments (variables) passed for updating.
But since the Adapt function has already been generated for the Object type, processing for it will occur as an Object.
Therefore, this is not exactly an ObjectAdapter problem, as I initially decided.
You just need to initially generate the Adapt function for the Type Packed into an object ( TSource or TDestination )
Even to call a function dynamically, need to know the real type of the TSource before calling them.
Without this cannot create this:
var method = (from m in typeof(TypeAdapterConfig).GetMethods(BindingFlags.Instance | BindingFlags.Public)
where m.Name == nameof(GetMapToTargetFunction)
select m).First().MakeGenericMethod(sourceType, destinationType);
The main problem is the following:
For this to work, need to capture the Runtime type of variables _source.GetType() _destination.GetType() somewhere and save them for subsequent construction of the Adapt function (Theory, maybe this won't work either).
andrerav
changed the title
Fix issue #524. Adding support for working with Types packed into an object to the standard adapter
Fix issue #524 - Add support for working with types packed into an object to the standard adapter
Jan 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix issue #524
Before:
if Type was packaged into an object:
object _source = new TSource()Instead of updating with data from TSource, it was converted to the TDestination type
_source.Adapt(_destination) == _source.Adapt<TDistination>