Skip to content

Instantly share code, notes, and snippets.

View digioz's full-sized avatar
😁
Coding in Open Source World!

DigiOz Multimedia digioz

😁
Coding in Open Source World!
View GitHub Profile
@digioz
digioz / ValueInjecter.cs
Created September 1, 2020 13:09
Property Copy between two C# Objects
public static class ValueInjecter
{
public static void CopyPropertiesTo<T, TU>(this T source, TU dest) {
var sourceProps = typeof(T).GetProperties().Where(x => x.CanRead).ToList();
var destProps = typeof(TU).GetProperties()
.Where(x => x.CanWrite)
.ToList();
foreach (var sourceProp in sourceProps) {
if (destProps.Any(x => x.Name == sourceProp.Name)) {
// User Language
var language = getLanguage();
function getLanguage() {
var lang = '';
if (navigator.userLanguage) {
lang = navigator.userLanguage;
}
else if (navigator.language) {
lang = navigator.language;