public static Build ( string tableName, |
||
tableName | string | |
pi | ||
fieldHandlerFactory | IFieldHandlerFactory | |
handlerOptions | FieldHandlerOptions | |
return |
public static TableFieldInfo Build(string tableName, PropertyInfo pi, IFieldHandlerFactory fieldHandlerFactory,
FieldHandlerOptions handlerOptions)
{
var fieldHandler = fieldHandlerFactory.CreateFromType(pi.PropertyType, handlerOptions);
if (fieldHandler == null) throw new BTDBException(string.Format("FieldHandlerFactory did not build property {0} of type {2} in {1}", pi.Name, tableName, pi.PropertyType.FullName));
var a = pi.GetCustomAttribute<PersistedNameAttribute>();
return new TableFieldInfo(a != null ? a.Name : pi.Name, fieldHandler);
}
internal void EnsureClientTypeVersion() { if (ClientTypeVersion != 0) { return; } EnsureKnownLastPersistedVersion(); var props = _clientType.GetProperties(); var fields = new List <TableFieldInfo>(props.Length); foreach (var pi in props) { fields.Add(TableFieldInfo.Build(Name, pi, _tableInfoResolver.FieldHandlerFactory, ClientType)); } var tvi = new TableVersionInfo(fields.ToArray()); if (LastPersistedVersion == 0) { _tableVersions.TryAdd(1, tvi); ClientTypeVersion = 1; } else { var last = _tableVersions.GetOrAdd(LastPersistedVersion, v => _tableInfoResolver.LoadTableVersionInfo(_id, v, Name)); if (TableVersionInfo.Equal(last, tvi)) { ClientTypeVersion = LastPersistedVersion; } else { _tableVersions.TryAdd(LastPersistedVersion + 1, tvi); ClientTypeVersion = LastPersistedVersion + 1; } } }