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:
Diffstat (limited to 'Xamarin.PropertyEditing.Tests/MockObjectEditor.cs')
-rw-r--r--Xamarin.PropertyEditing.Tests/MockObjectEditor.cs27
1 files changed, 26 insertions, 1 deletions
diff --git a/Xamarin.PropertyEditing.Tests/MockObjectEditor.cs b/Xamarin.PropertyEditing.Tests/MockObjectEditor.cs
index 80f11c0..3adb37e 100644
--- a/Xamarin.PropertyEditing.Tests/MockObjectEditor.cs
+++ b/Xamarin.PropertyEditing.Tests/MockObjectEditor.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
+using System.Threading;
using System.Threading.Tasks;
using Xamarin.PropertyEditing.Reflection;
using Xamarin.PropertyEditing.Tests.MockControls;
@@ -29,7 +30,7 @@ namespace Xamarin.PropertyEditing.Tests
}
internal class MockObjectEditor
- : IObjectEditor, IObjectEventEditor
+ : IObjectEditor, IObjectEventEditor, ICompleteValues
{
public MockObjectEditor ()
{
@@ -111,6 +112,12 @@ namespace Xamarin.PropertyEditing.Tests
set;
}
+ public IResourceProvider Resources
+ {
+ get;
+ set;
+ }
+
public void ChangeAllProperties ()
{
PropertyChanged?.Invoke (this, new EditorPropertyChangedEventArgs (null));
@@ -332,6 +339,24 @@ namespace Xamarin.PropertyEditing.Tests
return Task.FromResult<ITypeInfo> (new TypeInfo (asm, type.Namespace, type.Name));
}
+ public bool CanAutocomplete (string input)
+ {
+ return (input != null && input.Trim ().StartsWith ("@"));
+ }
+
+ public async Task<IReadOnlyList<string>> GetCompletionsAsync (IPropertyInfo property, string input, CancellationToken cancellationToken)
+ {
+ if (Resources == null)
+ return Array.Empty<string> ();
+
+ input = input.Trim ().TrimStart('@');
+ var resources = await Resources.GetResourcesAsync (Target, property, cancellationToken);
+ return resources.Where (r =>
+ r.Name.IndexOf (input, StringComparison.OrdinalIgnoreCase) != -1
+ && r.Name.Length > input.Length) // Skip exact matches
+ .Select (r => "@" + r.Name).ToList ();
+ }
+
internal readonly IDictionary<IPropertyInfo, object> values = new Dictionary<IPropertyInfo, object> ();
internal readonly IDictionary<IEventInfo, string> events = new Dictionary<IEventInfo, string> ();
internal readonly IReadOnlyDictionary<IPropertyInfo, IReadOnlyList<ITypeInfo>> assignableTypes;