diff options
author | Eric Maupin <ermaup@microsoft.com> | 2018-05-08 23:13:15 +0300 |
---|---|---|
committer | Eric Maupin <ermaup@microsoft.com> | 2018-05-12 02:02:05 +0300 |
commit | 386c68c6fbc27e9cb5136d65681471c41d31eba8 (patch) | |
tree | 8a39f865cb84c00855f7ff1f59f1e651757f786c /Xamarin.PropertyEditing | |
parent | 61c4e1004cdda6d3f66a14ac51ec74bef6057a7b (diff) |
[Core] Change ResourceSource.IsLocal to Type enum
Diffstat (limited to 'Xamarin.PropertyEditing')
-rw-r--r-- | Xamarin.PropertyEditing/IResourceProvider.cs | 6 | ||||
-rw-r--r-- | Xamarin.PropertyEditing/ResourceSource.cs | 20 | ||||
-rw-r--r-- | Xamarin.PropertyEditing/ViewModels/ResourceSelectorViewModel.cs | 4 |
3 files changed, 22 insertions, 8 deletions
diff --git a/Xamarin.PropertyEditing/IResourceProvider.cs b/Xamarin.PropertyEditing/IResourceProvider.cs index 2b17e11..b9db8ce 100644 --- a/Xamarin.PropertyEditing/IResourceProvider.cs +++ b/Xamarin.PropertyEditing/IResourceProvider.cs @@ -8,6 +8,11 @@ namespace Xamarin.PropertyEditing public interface IResourceProvider { /// <summary> + /// Gets whether or not the resource provider can create resources. + /// </summary> + bool CanCreateResources { get; } + + /// <summary> /// Gets the resources available to the given <paramref name="target"/> and <paramref name="property"/>. /// </summary> /// <exception cref="ArgumentNullException"><paramref name="property"/> or <paramref name="target"/> is <c>null</c>.</exception> @@ -27,6 +32,7 @@ namespace Xamarin.PropertyEditing /// <typeparam name="T">The representation type.</typeparam> /// <param name="value">The value of the resource in it's representative form.</param> + /// <exception cref="NotSupportedException"><see cref="CanCreateResources"/> is <c>false</c>.</exception> Task<Resource> CreateResourceAsync<T> (ResourceSource source, string name, T value); } }
\ No newline at end of file diff --git a/Xamarin.PropertyEditing/ResourceSource.cs b/Xamarin.PropertyEditing/ResourceSource.cs index e892d4b..dca3bdc 100644 --- a/Xamarin.PropertyEditing/ResourceSource.cs +++ b/Xamarin.PropertyEditing/ResourceSource.cs @@ -2,16 +2,24 @@ using System; namespace Xamarin.PropertyEditing { + public enum ResourceSourceType + { + System = 0, + Application = 1, + ResourceDictionary = 2, + Document = 3 + } + public sealed class ResourceSource : IEquatable<ResourceSource> { - public ResourceSource (string name, bool isLocal) + public ResourceSource (string name, ResourceSourceType type) { if (name == null) throw new ArgumentNullException (nameof (name)); Name = name; - IsLocal = isLocal; + Type = type; } public string Name @@ -20,9 +28,9 @@ namespace Xamarin.PropertyEditing } /// <summary> - /// Gets whether the source is local/relative to a target object. + /// Gets the type of resource source. /// </summary> - public bool IsLocal + public ResourceSourceType Type { get; } @@ -34,7 +42,7 @@ namespace Xamarin.PropertyEditing if (ReferenceEquals (other, this)) return true; - return IsLocal == other.IsLocal && Name == other.Name; + return Type == other.Type && Name == other.Name; } public override bool Equals (object obj) @@ -53,7 +61,7 @@ namespace Xamarin.PropertyEditing { unchecked { int hashCode = Name.GetHashCode(); - hashCode = (hashCode * 397) ^ IsLocal.GetHashCode(); + hashCode = (hashCode * 397) ^ Type.GetHashCode(); return hashCode; } } diff --git a/Xamarin.PropertyEditing/ViewModels/ResourceSelectorViewModel.cs b/Xamarin.PropertyEditing/ViewModels/ResourceSelectorViewModel.cs index 2c8d57e..dad70cb 100644 --- a/Xamarin.PropertyEditing/ViewModels/ResourceSelectorViewModel.cs +++ b/Xamarin.PropertyEditing/ViewModels/ResourceSelectorViewModel.cs @@ -162,9 +162,9 @@ namespace Xamarin.PropertyEditing.ViewModels var r = (Resource)item; if (!String.IsNullOrWhiteSpace (FilterText) && !r.Name.Contains (FilterText, StringComparison.OrdinalIgnoreCase)) return false; - if (ShowOnlySystemResources && r.Source.IsLocal) + if (ShowOnlySystemResources && r.Source.Type == ResourceSourceType.System) return false; - if (ShowOnlyLocalResources && !r.Source.IsLocal) + if (ShowOnlyLocalResources && r.Source.Type != ResourceSourceType.System) return false; return true; |