public bool TryCreate(HomogenizedKeyDictionary data, out object result) { bool anyPropertiesSet = false; object obj = Activator.CreateInstance(_concreteType); foreach (var propertyInfo in _concreteType.GetProperties().Where(pi => CanSetProperty(pi, data))) { propertyInfo.SetValue(obj, data[propertyInfo.Name], null); anyPropertiesSet = true; } result = anyPropertiesSet ? obj : null; return anyPropertiesSet; }
private static bool CanSetProperty(PropertyInfo propertyInfo, HomogenizedKeyDictionary data) { return data.ContainsKey(propertyInfo.Name) && !(propertyInfo.PropertyType.IsValueType && data[propertyInfo.Name] == null); }
public DynamicRecord(Database database) { _data = new HomogenizedKeyDictionary(); _database = database; }
internal DynamicRecord(IEnumerable<KeyValuePair<string, object>> data, string tableName, Database database) { _tableName = tableName; _database = database; _data = new HomogenizedKeyDictionary(data); }
public DynamicRecord() { _data = new HomogenizedKeyDictionary(); }