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; } } }
internal void EnsureClientTypeVersion() { if (ClientTypeVersion != 0) { return; } EnsureKnownLastPersistedVersion(); var props = _clientType.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); var fields = new StructList <TableFieldInfo>(); fields.Reserve((uint)props.Length); foreach (var pi in props) { if (pi.GetCustomAttributes(typeof(NotStoredAttribute), true).Length != 0) { continue; } if (pi.GetIndexParameters().Length != 0) { continue; } fields.Add(TableFieldInfo.Build(Name, pi, _tableInfoResolver.FieldHandlerFactory, FieldHandlerOptions.None)); } var tvi = new TableVersionInfo(fields.ToArray()); if (LastPersistedVersion == 0) { _tableVersions.TryAdd(1, tvi); ClientTypeVersion = 1; } else { var last = _tableVersions.GetOrAdd(LastPersistedVersion, (ver, tableInfo) => tableInfo._tableInfoResolver.LoadTableVersionInfo(tableInfo._id, ver, tableInfo.Name), this); if (TableVersionInfo.Equal(last, tvi)) { _tableVersions[LastPersistedVersion] = tvi; // tvi was build from real types and not loaded so it is more exact ClientTypeVersion = LastPersistedVersion; } else { _tableVersions.TryAdd(LastPersistedVersion + 1, tvi); ClientTypeVersion = LastPersistedVersion + 1; } } }