SourceOutcome Enumeration
Assembly: CodeEffects.Rule.Repository.dll
Namespace: CodeEffects.Rule.Repository.Common
Summary
Specifies what Context.SyncSources(..) did with one source definition: left it alone, updated its labels, created the source, created a version, or failed to process it.
Syntax
public enum SourceOutcome
{
// The definition matched a stored version exactly. Nothing was written
Unchanged = 0,
// The definition matched a stored version except for display names or descriptions. The stored version was updated in place
LabelsUpdated = 1,
// The alias was not in the repository. A new source and its first version were created
SourceCreated = 2,
// The definition differs from the version or versions it was compared with. A new version was created
VersionCreated = 3,
// The definition could not be processed. Nothing was written for it
Failed = 4
}
SourceResult.Outcome holds the value for each definition in the SyncResult that Context.SyncSources(..) returns. SyncResult.Success is true when no entry has the outcome Failed.
Which stored versions a definition is compared with is decided by SourceVersionComparisonType. What happens to existing tests when VersionCreated applies is decided by TestsHandlingType.
The other members of the SourceResult entry depend on the outcome:
| Outcome |
What the entry carries |
Unchanged |
The IDs of the matched version. DifferenceCount and LabelChangeCount are zero. |
LabelsUpdated |
LabelChangeCount holds the number of display name and description changes written to the stored version. No new version exists. |
SourceCreated |
The IDs of the new source and its first version. There is no compared version. |
VersionCreated |
DifferenceCount holds the number of differences that made the new version necessary, ComparedVersionId the version it was compared with. |
Failed |
Message and Error say why. SourceRecordId and SourceVersionId are null when the definition failed before a source was found or created. |
A failed definition does not stop the others: every definition is processed. After all of them are processed, Context.SyncSources(..) throws a RepositoryException when at least one has the outcome Failed. The exception carries the complete SyncResult.
Example
using System;
using CodeEffects.Rule.Repository;
using CodeEffects.Rule.Repository.Common;
SyncResult result = Context.SyncSources(dbProvider, settings);
foreach(SourceResult source in result.Sources)
{
switch(source.Outcome)
{
case SourceOutcome.SourceCreated:
Console.WriteLine($"{source.AliasName}: new source, version {source.SourceVersionId}");
break;
case SourceOutcome.VersionCreated:
Console.WriteLine($"{source.AliasName}: new version {source.SourceVersionId}, {source.DifferenceCount} difference(s)");
break;
case SourceOutcome.LabelsUpdated:
Console.WriteLine($"{source.AliasName}: {source.LabelChangeCount} label(s) updated");
break;
}
}