asign only common fields in c# object
C#
private Func<S,T> AutoMapFactory<S,T>() where T: class, new() where S : class
{
List<Action<T, S>> mapActions = typeof(T).GetProperties().Where(tp => tp.CanWrite)
.SelectMany(tp => typeof(S).GetProperties().Where(sp => sp.CanRead)
.Where(sp => sp.Name == tp.Name && tp.PropertyType.IsAssignableFrom(sp.PropertyType))
.Select(sp => (Action<T,S>)((targetObj, sourceObj) =>
tp.SetValue(targetObj, sp.GetValue(sourceObj)))))
.ToList();
return sourceObj => {
if (sourceObj == null) return null;
T targetObj = new T();
mapActions.ForEach(action => action(targetObj, sourceObj));
return targetObj;
};
}
Also in C#:
- Title
- verifyusertokenasync password reset token
- Category
- C#
- Title
- unity c# is not equal to
- Category
- C#
- Title
- c# index in select
- Category
- C#
- Title
- C# .NET Core linq Distinct
- Category
- C#
- Title
- transform object according to its parent unity
- Category
- C#
- Title
- c# multiple catch exceptions
- Category
- C#
- Title
- generate a dropdown list from array data using razor .net mvc
- Category
- C#
- Title
- iphone
- Category
- C#
- Title
- c# print to console
- Category
- C#
- Title
- windows form rounded corners
- Category
- C#
- Title
- page parent wpf
- Category
- C#
- Title
- unity pingpong
- Category
- C#
- Title
- c# get foreground window
- Category
- C#
- Title
- iterate through xpdictionary devexpress
- Category
- C#
- Title
- C# colours
- Category
- C#
- Title
- dictionary update c#
- Category
- C#
- Title
- unity rigidbody constraints
- Category
- C#
- Title
- initialise icollection c#
- Category
- C#
- Title
- how to get odd saturday in a month in c#
- Category
- C#
- Title
- unity get velocity at point
- Category
- C#
- Title
- c# make http request
- Category
- C#
- Title
- accessing form controls from another class c#
- Category
- C#
- Title
- c# use hashtable check if key exists
- Category
- C#
- Title
- how to raycast unit
- Category
- C#
- Title
- c# static meaning
- Category
- C#
- Title
- c# read char
- Category
- C#
- Title
- class selector to property in asp net core dropdown
- Category
- C#
- Title
- csharp datetime string format
- Category
- C#
- Title
- how to reference scripts in other scenes unity
- Category
- C#
- Title
- c# get all class properties
- Category
- C#
- Title
- c# creating and throwing exceptions
- Category
- C#
- Title
- dynamic group by expression C#
- Category
- C#
- Title
- get out of foreach statement c#
- Category
- C#
- Title
- c# Authorization has been denied for this request
- Category
- C#
- Title
- animations for pause menu
- Category
- C#
- Title
- c# else if
- Category
- C#
- Title
- How to search for a string from readline in c#
- Category
- C#
- Title
- c# repeat string x times
- Category
- C#
- Title
- c# get country code
- Category
- C#
- Title
- flip boolean c#
- Category
- C#
- Title
- pop up element from specific index in array
- Category
- C#
- Title
- windows forms iterate through all controls
- Category
- C#
- Title
- cc# sort list with list if ids
- Category
- C#
- Title
- what type of variable is true or false in c#
- Category
- C#
- Title
- c# send email
- Category
- C#
- Title
- asp.net c# write string to text file
- Category
- C#
- Title
- eventos c#
- Category
- C#
- Title
- c# get pc ip address
- Category
- C#
- Title
- unity print to console
- Category
- C#
- Title
- player script unity
- Category
- C#
- Title
- unity instantiate
- Category
- C#
- Title
- getcomponent c#
- Category
- C#
- Title
- open file in explorer c#
- Category
- C#
- Title
- asp.net model display name
- Category
- C#
- Title
- change canvas color uwp c#
- Category
- C#
- Title
- how to make % posibility to spawn an object C# in unity
- Category
- C#
- Title
- BCrypt c#
- Category
- C#
- Title
- c# method info extension
- Category
- C#
- Title
- unity separator in inspector
- Category
- C#
- Title
- c# edit element in list
- Category
- C#
- Title
- how to cjeck if a string has a word c#
- Category
- C#
- Title
- how to make a datatable in c#
- Category
- C#
- Title
- how to remove space between string in c#
- Category
- C#
- Title
- unity get number of child objects
- Category
- C#
- Title
- asp.net tag helper checkbox
- Category
- C#
- Title
- c# list all files in a directory and subdirectory
- Category
- C#
- Title
- c# skip following code in loop
- Category
- C#
- Title
- c# replace string case insensitive
- Category
- C#
- Title
- resize image c#
- Category
- C#
- Title
- unity cast float to int
- Category
- C#
- Title
- c# remove character from string at index
- Category
- C#
- Title
- while loop in c#
- Category
- C#
- Title
- JavaScriptSerializer() and convert to base64
- Category
- C#
- Title
- how do i limit the amount of prefabs in unity using c# script
- Category
- C#
- Title
- c# docstring
- Category
- C#
- Title
- countdown script in unity
- Category
- C#
- Title
- git checkout reset hard
- Category
- C#
- Title
- convert to base64 c#
- Category
- C#
- Title
- .net core executenonqueryasync transaction
- Category
- C#
- Title
- how to create and trigger a function unity animation events
- Category
- C#
- Title
- C# get pc language
- Category
- C#
- Title
- C# Unknown column 'FundAllocation' in 'field list
- Category
- C#
- Title
- unity onselect gizmos wireframe
- Category
- C#
- Title
- loop gridcontrol devexpress c#
- Category
- C#
- Title
- c# substring from index to end
- Category
- C#
- Title
- how to randomly rotate rigidbody of object in unity
- Category
- C#
- Title
- .netstandard distinctby iqueryable
- Category
- C#
- Title
- c# remove specific character from string
- Category
- C#
- Title
- console application in c# ms crm
- Category
- C#
- Title
- c# string to lowercase
- Category
- C#
- Title
- value is null to insert in c#
- Category
- C#
- Title
- question mark operator in c#
- Category
- C#
- Title
- unity custom editor save changes
- Category
- C#
- Title
- how to find a transform unity
- Category
- C#
- Title
- What is a class in c#
- Category
- C#
- Title
- c# resize bitmap
- Category
- C#
- Title
- draw sphere cast unity with program
- Category
- C#
- Title
- find gameobject with tag
- Category
- C#
- Title
- how to add to an array c#
- Category
- C#
- Title
- razor preview
- Category
- C#