start working on security group view
This commit is contained in:
23
UserService.Infrastructure/NodeExtensions.cs
Normal file
23
UserService.Infrastructure/NodeExtensions.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UserService.Infrastructure.DataModels;
|
||||
|
||||
namespace UserService.Infrastructure
|
||||
{
|
||||
public static class NodeExtensions
|
||||
{
|
||||
public static void MapFields(this User user, Dictionary<string, object> values)
|
||||
{
|
||||
if (user == null) throw new ArgumentNullException(nameof(user));
|
||||
if (values == null) throw new ArgumentNullException(nameof(values));
|
||||
var properties = user.GetType().GetProperties();
|
||||
foreach (var keyValuePair in values)
|
||||
{
|
||||
var propertyInfo = properties.FirstOrDefault(x => x.Name == keyValuePair.Key);
|
||||
if (propertyInfo == null) continue;
|
||||
propertyInfo.SetValue(user, keyValuePair.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user