SourceKind Enumeration

Assembly: CodeEffects.Rule.Repository.dll
Namespace: CodeEffects.Rule.Repository.Common

Summary

Specifies the form in which a source definition was given to Context.SyncSources(..): a Source XML document, a .NET type, or an Adaptive Source provider.

Syntax

public enum SourceKind
{
	// A Source XML document, from SourceSettings.SourceXmls
	Xml = 0,

	// A source object type, from SourceSettings.SourceTypes
	Type = 1,

	// An Adaptive Source, from SourceSettings.SourceProviders
	Provider = 2
}

Remarks

SourceResult.Kind holds the value for each source definition that Context.SyncSources(..) processed. It tells you which of the three lists of SourceSettings the definition came from, and therefore which list SourceResult.Index counts in.

Member List Index counts in
Xml SourceSettings.SourceXmls SourceXmls
Type SourceSettings.SourceTypes SourceTypes
Provider SourceSettings.SourceProviders SourceProviders

Whatever the form, the repository turns the definition into a Source XML document first and then stores, compares, and versions it the same way. A Type is converted as the rule editor converts a type. A Provider is converted from everything its ISourceProvider.GetSource() lists. The numeric values are permanent.

Example

using System;
using CodeEffects.Rule.Repository;
using CodeEffects.Rule.Repository.Common;

try
{
	Context.SyncSources(dbProvider, settings);
}
catch(RepositoryException ex) when(ex.SyncResult != null)
{
	foreach(var source in ex.SyncResult.Sources)
	{
		if(source.Outcome != SourceOutcome.Failed) continue;

		string list = source.Kind == SourceKind.Xml ? "SourceXmls"
			: source.Kind == SourceKind.Type ? "SourceTypes" : "SourceProviders";

		Console.WriteLine($"{list}[{source.Index}] {source.AliasName}: {source.Message}");
	}
}

Ask on Stack Overflow - Yes, it's still active
Ask in GitHub Discussions

p102

l097 --

l102

p101

×