public void CheckVersion <TClass>(TClass instance) where TClass : class, IDocument { var type = typeof(TClass); var documentVersion = instance.Version.ToString(); var latestVersion = _migrationLocator.GetLatestVersion(type); var currentVersion = _versionLocator.GetCurrentVersion(type) ?? latestVersion; if (documentVersion == currentVersion) { return; } if (latestVersion == documentVersion) { return; } if (DocumentVersion.Default() == documentVersion) { DetermineCurrentVersion(instance, currentVersion, latestVersion); return; } throw new VersionViolationException(currentVersion.ToString(), documentVersion, latestVersion); }
public DocumentVersion GetCurrentOrLatestMigrationVersion(Type type) { var latestVersion = _migrationLocator.GetLatestVersion(type); return(GetCurrentVersion(type) ?? latestVersion); }