Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Maupin <ermaup@microsoft.com>2018-05-12 00:51:15 +0300
committerEric Maupin <ermaup@microsoft.com>2018-05-12 02:02:05 +0300
commit64cbe1898b56bb2a40682d5703b7e6063318b84c (patch)
treee7060155b2f021bab4772b3d49f3a42b120b56cb /Xamarin.PropertyEditing
parent920eab7c07a0e85eb6ae7e06a6d1e201d0a32565 (diff)
[Core] Add resource creation error checking APIs
Diffstat (limited to 'Xamarin.PropertyEditing')
-rw-r--r--Xamarin.PropertyEditing/IResourceProvider.cs40
1 files changed, 40 insertions, 0 deletions
diff --git a/Xamarin.PropertyEditing/IResourceProvider.cs b/Xamarin.PropertyEditing/IResourceProvider.cs
index b9db8ce..353dce6 100644
--- a/Xamarin.PropertyEditing/IResourceProvider.cs
+++ b/Xamarin.PropertyEditing/IResourceProvider.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Data;
using System.Threading;
using System.Threading.Tasks;
@@ -30,9 +31,48 @@ namespace Xamarin.PropertyEditing
/// </summary>
Task<IReadOnlyList<ResourceSource>> GetResourceSourcesAsync (object target, IPropertyInfo property);
+ /// <summary>
+ /// Gets an unused type-appropriate resource key for a value of the <paramref name="property"/> being turned into a resource.
+ /// </summary>
+ Task<string> SuggestResourceNameAsync (IReadOnlyCollection<object> targets, IPropertyInfo property);
+
+ /// <summary>
+ /// Checks for issues creating a resource in the given <paramref name="source"/> with <paramref name="name"/> such as name in use, or would be overriden.
+ /// </summary>
+ Task<ResourceCreateError> CheckNameErrorsAsync (object target, ResourceSource source, string name);
+
/// <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>
+ /// <exception cref="DuplicateNameException"><paramref name="name"/> is already present in the given <paramref name="source"/>.</exception>
Task<Resource> CreateResourceAsync<T> (ResourceSource source, string name, T value);
}
+
+ public class ResourceCreateError
+ {
+ public ResourceCreateError (string message, bool isWarning)
+ {
+ if (message == null)
+ throw new ArgumentNullException (nameof(message));
+
+ IsWarning = isWarning;
+ Message = message;
+ }
+
+ /// <summary>
+ /// Gets or sets the localized description of the error
+ /// </summary>
+ public string Message
+ {
+ get;
+ }
+
+ /// <summary>
+ /// Gets or sets whether the error message is just a warning, thereby not preventing creation
+ /// </summary>
+ public bool IsWarning
+ {
+ get;
+ }
+ }
} \ No newline at end of file