Browse Source

IResourceProvider -> IResourceNode

pull/1136/head
Steven Kirk 9 years ago
parent
commit
e81b22b9d2
  1. 8
      src/Avalonia.Controls/Application.cs
  2. 6
      src/Avalonia.Controls/Control.cs
  3. 2
      src/Avalonia.Controls/IControl.cs
  4. 4
      src/Avalonia.Styling/Controls/IResourceNode.cs
  5. 6
      src/Avalonia.Styling/Controls/ResourceProviderExtensions.cs
  6. 2
      src/Avalonia.Styling/Styling/ISetStyleParent.cs
  7. 2
      src/Avalonia.Styling/Styling/IStyle.cs
  8. 8
      src/Avalonia.Styling/Styling/Style.cs
  9. 6
      src/Avalonia.Styling/Styling/Styles.cs
  10. 8
      src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/DynamicResourceExtension.cs
  11. 4
      src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/StaticResourceExtension.cs
  12. 8
      src/Markup/Avalonia.Markup.Xaml/Styling/StyleInclude.cs
  13. 2
      tests/Avalonia.Layout.UnitTests/FullLayoutTests.cs

8
src/Avalonia.Controls/Application.cs

@ -29,7 +29,7 @@ namespace Avalonia
/// method.
/// - Tracks the lifetime of the application.
/// </remarks>
public class Application : IApplicationLifecycle, IGlobalDataTemplates, IGlobalStyles, IStyleRoot, IResourceProvider
public class Application : IApplicationLifecycle, IGlobalDataTemplates, IGlobalStyles, IStyleRoot, IResourceNode
{
/// <summary>
/// The application-global data templates.
@ -126,10 +126,10 @@ namespace Avalonia
IStyleHost IStyleHost.StylingParent => null;
/// <inheritdoc/>
bool IResourceProvider.HasResources => _resources?.Count > 0;
bool IResourceNode.HasResources => _resources?.Count > 0;
/// <inheritdoc/>
IResourceProvider IResourceProvider.ResourceParent => null;
IResourceNode IResourceNode.ResourceParent => null;
/// <summary>
/// Initializes the application by loading XAML etc.
@ -159,7 +159,7 @@ namespace Avalonia
}
/// <inheritdoc/>
bool IResourceProvider.TryGetResource(string key, out object value)
bool IResourceNode.TryGetResource(string key, out object value)
{
value = null;
return (_resources?.TryGetResource(key, out value) ?? false) ||

6
src/Avalonia.Controls/Control.cs

@ -390,10 +390,10 @@ namespace Avalonia.Controls
IAvaloniaReadOnlyList<ILogical> ILogical.LogicalChildren => LogicalChildren;
/// <inheritdoc/>
bool IResourceProvider.HasResources => _resources?.Count > 0 || Styles.HasResources;
bool IResourceNode.HasResources => _resources?.Count > 0 || Styles.HasResources;
/// <inheritdoc/>
IResourceProvider IResourceProvider.ResourceParent => ((IStyleHost)this).StylingParent as IResourceProvider;
IResourceNode IResourceNode.ResourceParent => ((IStyleHost)this).StylingParent as IResourceNode;
/// <inheritdoc/>
IAvaloniaReadOnlyList<string> IStyleable.Classes => Classes;
@ -480,7 +480,7 @@ namespace Avalonia.Controls
}
/// <inheritdoc/>
bool IResourceProvider.TryGetResource(string key, out object value)
bool IResourceNode.TryGetResource(string key, out object value)
{
value = null;
return (_resources?.TryGetResource(key, out value) ?? false) ||

2
src/Avalonia.Controls/IControl.cs

@ -14,7 +14,7 @@ namespace Avalonia.Controls
/// <summary>
/// Interface for Avalonia controls.
/// </summary>
public interface IControl : IVisual, ILogical, ILayoutable, IInputElement, INamed, IResourceProvider, IStyleable, IStyleHost
public interface IControl : IVisual, ILogical, ILayoutable, IInputElement, INamed, IResourceNode, IStyleable, IStyleHost
{
/// <summary>
/// Occurs when the control has finished initialization.

4
src/Avalonia.Styling/Controls/IResourceProvider.cs → src/Avalonia.Styling/Controls/IResourceNode.cs

@ -5,7 +5,7 @@ namespace Avalonia.Controls
/// <summary>
/// Defines an element that can be queried for resources.
/// </summary>
public interface IResourceProvider
public interface IResourceNode
{
/// <summary>
/// Raised when resources in the element are changed.
@ -20,7 +20,7 @@ namespace Avalonia.Controls
/// <summary>
/// Gets the parent resource provider, if any.
/// </summary>
IResourceProvider ResourceParent { get; }
IResourceNode ResourceParent { get; }
/// <summary>
/// Tries to find a resource within the element.

6
src/Avalonia.Styling/Controls/ResourceProviderExtensions.cs

@ -14,7 +14,7 @@ namespace Avalonia.Controls
/// <param name="control">The control.</param>
/// <param name="key">The resource key.</param>
/// <returns>The resource, or <see cref="AvaloniaProperty.UnsetValue"/> if not found.</returns>
public static object FindResource(this IResourceProvider control, string key)
public static object FindResource(this IResourceNode control, string key)
{
Contract.Requires<ArgumentNullException>(control != null);
Contract.Requires<ArgumentNullException>(key != null);
@ -23,7 +23,7 @@ namespace Avalonia.Controls
while (current != null)
{
if (current is IResourceProvider host)
if (current is IResourceNode host)
{
if (host.TryGetResource(key, out var value))
{
@ -37,7 +37,7 @@ namespace Avalonia.Controls
return AvaloniaProperty.UnsetValue;
}
public static IObservable<object> GetResourceObservable(this IResourceProvider target, string key)
public static IObservable<object> GetResourceObservable(this IResourceNode target, string key)
{
return Observable.FromEventPattern<ResourcesChangedEventArgs>(
x => target.ResourcesChanged += x,

2
src/Avalonia.Styling/Styling/ISetStyleParent.cs

@ -17,7 +17,7 @@ namespace Avalonia.Styling
/// Sets the style parent.
/// </summary>
/// <param name="parent">The parent.</param>
void SetParent(IResourceProvider parent);
void SetParent(IResourceNode parent);
/// <summary>
/// Notifies the style that a change has been made to resources that apply to it.

2
src/Avalonia.Styling/Styling/IStyle.cs

@ -8,7 +8,7 @@ namespace Avalonia.Styling
/// <summary>
/// Defines the interface for styles.
/// </summary>
public interface IStyle : IResourceProvider
public interface IStyle : IResourceNode
{
/// <summary>
/// Attaches the style to a control if the style's selector matches.

8
src/Avalonia.Styling/Styling/Style.cs

@ -17,7 +17,7 @@ namespace Avalonia.Styling
{
private static Dictionary<IStyleable, List<IDisposable>> _applied =
new Dictionary<IStyleable, List<IDisposable>>();
private IResourceProvider _parent;
private IResourceNode _parent;
private ResourceDictionary _resources;
/// <summary>
@ -68,10 +68,10 @@ namespace Avalonia.Styling
public IList<ISetter> Setters { get; set; } = new List<ISetter>();
/// <inheritdoc/>
bool IResourceProvider.HasResources => _resources?.Count > 0;
bool IResourceNode.HasResources => _resources?.Count > 0;
/// <inheritdoc/>
IResourceProvider IResourceProvider.ResourceParent => _parent;
IResourceNode IResourceNode.ResourceParent => _parent;
/// <summary>
/// Attaches the style to a control if the style's selector matches.
@ -139,7 +139,7 @@ namespace Avalonia.Styling
}
/// <inheritdoc/>
void ISetStyleParent.SetParent(IResourceProvider parent)
void ISetStyleParent.SetParent(IResourceNode parent)
{
if (_parent != null && parent != null)
{

6
src/Avalonia.Styling/Styling/Styles.cs

@ -14,7 +14,7 @@ namespace Avalonia.Styling
/// </summary>
public class Styles : AvaloniaList<IStyle>, IStyle, ISetStyleParent
{
private IResourceProvider _parent;
private IResourceNode _parent;
private ResourceDictionary _resources;
public Styles()
@ -78,7 +78,7 @@ namespace Avalonia.Styling
}
/// <inheritdoc/>
IResourceProvider IResourceProvider.ResourceParent => _parent;
IResourceNode IResourceNode.ResourceParent => _parent;
/// <summary>
/// Attaches the style to a control if the style's selector matches.
@ -116,7 +116,7 @@ namespace Avalonia.Styling
}
/// <inheritdoc/>
void ISetStyleParent.SetParent(IResourceProvider parent)
void ISetStyleParent.SetParent(IResourceNode parent)
{
if (_parent != null && parent != null)
{

8
src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/DynamicResourceExtension.cs

@ -15,7 +15,7 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions
{
public class DynamicResourceExtension : MarkupExtension, IBinding
{
private IResourceProvider _anchor;
private IResourceNode _anchor;
public DynamicResourceExtension()
{
@ -33,9 +33,9 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions
var context = (ITypeDescriptorContext)serviceProvider;
var provideTarget = context.GetService<IProvideValueTarget>();
if (!(provideTarget.TargetObject is IResourceProvider))
if (!(provideTarget.TargetObject is IResourceNode))
{
_anchor = GetAnchor<IResourceProvider>(context);
_anchor = GetAnchor<IResourceNode>(context);
}
return this;
@ -47,7 +47,7 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions
object anchor,
bool enableDataValidation)
{
var control = target as IResourceProvider ?? _anchor;
var control = target as IResourceNode ?? _anchor;
if (control != null)
{

4
src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/StaticResourceExtension.cs

@ -31,7 +31,7 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions
var context = (ITypeDescriptorContext)serviceProvider;
var schemaContext = context.GetService<IXamlSchemaContextProvider>()?.SchemaContext;
var ambientProvider = context.GetService<IAmbientProvider>();
var resourceProviderType = schemaContext.GetXamlType(typeof(IResourceProvider));
var resourceProviderType = schemaContext.GetXamlType(typeof(IResourceNode));
var ambientValues = ambientProvider.GetAllAmbientValues(resourceProviderType);
// Look upwards though the ambient context for IResourceProviders which might be able
@ -47,7 +47,7 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions
{
// We override XamlType.CanAssignTo in BindingXamlType so the results we get back
// from GetAllAmbientValues aren't necessarily of the correct type.
if (ambientValue is IResourceProvider resourceProvider)
if (ambientValue is IResourceNode resourceProvider)
{
if (resourceProvider is IControl control && control.StylingParent != null)
{

8
src/Markup/Avalonia.Markup.Xaml/Styling/StyleInclude.cs

@ -14,7 +14,7 @@ namespace Avalonia.Markup.Xaml.Styling
{
private Uri _baseUri;
private IStyle _loaded;
private IResourceProvider _parent;
private IResourceNode _parent;
/// <summary>
/// Initializes a new instance of the <see cref="StyleInclude"/> class.
@ -52,10 +52,10 @@ namespace Avalonia.Markup.Xaml.Styling
}
/// <inheritdoc/>
bool IResourceProvider.HasResources => Loaded.HasResources;
bool IResourceNode.HasResources => Loaded.HasResources;
/// <inheritdoc/>
IResourceProvider IResourceProvider.ResourceParent => _parent;
IResourceNode IResourceNode.ResourceParent => _parent;
/// <inheritdoc/>
public void Attach(IStyleable control, IStyleHost container)
@ -76,7 +76,7 @@ namespace Avalonia.Markup.Xaml.Styling
}
/// <inheritdoc/>
void ISetStyleParent.SetParent(IResourceProvider parent)
void ISetStyleParent.SetParent(IResourceNode parent)
{
if (_parent != null && parent != null)
{

2
tests/Avalonia.Layout.UnitTests/FullLayoutTests.cs

@ -162,7 +162,7 @@ namespace Avalonia.Layout.UnitTests
private void RegisterServices()
{
var globalStyles = new Mock<IGlobalStyles>();
var globalStylesResources = globalStyles.As<IResourceProvider>();
var globalStylesResources = globalStyles.As<IResourceNode>();
var outObj = (object)10;
globalStylesResources.Setup(x => x.TryGetResource("FontSizeNormal", out outObj)).Returns(true);

Loading…
Cancel
Save