Rename `OnSourceChanged` and expand on xmldoc to mention that it doesn't fire `SourceChanged`

This commit is contained in:
Dean Herbert 2021-10-12 13:04:48 +09:00
parent a849e7343e
commit d7cbacc5a0
3 changed files with 8 additions and 5 deletions

View File

@ -64,7 +64,7 @@ public TestSkinProvidingContainer(IEnumerable<ISkin> sources)
public new void TriggerSourceChanged() => base.TriggerSourceChanged();
protected override void OnSourceChanged()
protected override void RefreshSources()
{
SetSources(sources);
}

View File

@ -58,7 +58,7 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl
return base.CreateChildDependencies(parent);
}
protected override void OnSourceChanged()
protected override void RefreshSources()
{
// Populate a local list first so we can adjust the returned order as we go.
var sources = new List<ISkin>();

View File

@ -173,6 +173,9 @@ public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
/// <summary>
/// Replace the sources used for lookups in this container.
/// </summary>
/// <remarks>
/// This does not implicitly fire a <see cref="SourceChanged"/> event. Consider calling <see cref="TriggerSourceChanged"/> if required.
/// </remarks>
/// <param name="sources">The new sources.</param>
protected void SetSources(IEnumerable<ISkin> sources)
{
@ -195,15 +198,15 @@ protected void SetSources(IEnumerable<ISkin> sources)
}
/// <summary>
/// Invoked when any source has changed (either <see cref="ParentSource"/> or sources replaced via <see cref="SetSources"/>).
/// Invoked after any consumed source change, before the external <see cref="SourceChanged"/> event is fired.
/// This is also invoked once initially during <see cref="CreateChildDependencies"/> to ensure sources are ready for children consumption.
/// </summary>
protected virtual void OnSourceChanged() { }
protected virtual void RefreshSources() { }
protected void TriggerSourceChanged()
{
// Expose to implementations, giving them a chance to react before notifying external consumers.
OnSourceChanged();
RefreshSources();
SourceChanged?.Invoke();
}