using System.Collections.Generic;
public static void Main()
var dataGeneratorList = new List<DataGenerator>
new StringDataGenerator(() => "Tester", "first", "name"),
new StringDataGenerator(() => "Test", "last", "name"),
new GuidDataGenerator(Guid.NewGuid, "uid", "id")
var writeProperties = typeof (Employee).GetProperties().Where(p => p.CanWrite);
foreach (var property in writeProperties)
foreach (var dataGenerator in dataGeneratorList)
if (property.PropertyType == dataGenerator.Type)
var weigth = dataGenerator.GetWeight(property.Name);
var func = dataGenerator.GetType().GetField("Generator").GetValue(dataGenerator);
var testValue = func.GetType().GetMethod("Invoke").Invoke(func, null);
Console.WriteLine(testValue);
public string FirstName { get; set; }
public string LastName { get; set; }
public Guid EmpUid { get; set; }
public abstract class DataGenerator
public abstract int GetWeight(string matchingProperty);
public abstract Type Type { get;}
public abstract class DataGenerator<T> : DataGenerator
public readonly string[] Tags;
public readonly Func<T> Generator;
protected DataGenerator(Func<T> generator, params string[] tags)
public override int GetWeight(string matchingProperty)
int sum = (from tag in Tags
where matchingProperty.ToLowerInvariant().Contains(tag.ToLowerInvariant())
public override Type Type {
get { return typeof(T); }
public class StringDataGenerator : DataGenerator<string>
public StringDataGenerator(Func<string> generator, params string[] tags) : base(generator, tags)
public class GuidDataGenerator : DataGenerator<Guid>
public GuidDataGenerator(Func<Guid> generator, params string[] tags)