forked from unoplatform/uno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(xamlreader): Support CustomResource
- Loading branch information
Showing
5 changed files
with
111 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/Uno.UI.Tests/Windows_UI_Xaml_Markup/XamlReaderTests/TestCustomResourceLoader.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Windows.UI.Xaml.Resources; | ||
|
||
namespace Uno.UI.Tests.Windows_UI_Xaml_Markup.XamlReaderTests | ||
{ | ||
internal class TestCustomXamlResourceLoader : CustomXamlResourceLoader | ||
{ | ||
internal Dictionary<string, object> TestCustomResources { get; set; } = new Dictionary<string, object>(); | ||
|
||
public string LastResourceId { get; set; } | ||
public string LastObjectType { get; set; } | ||
public string LastPropertyName { get; set; } | ||
public string LastPropertyType { get; set; } | ||
|
||
protected override object GetResource(string resourceId, string objectType, string propertyName, string propertyType) | ||
{ | ||
LastResourceId = resourceId; | ||
LastObjectType = objectType; | ||
LastPropertyName = propertyName; | ||
LastPropertyType = propertyType; | ||
if (TestCustomResources.ContainsKey(resourceId) && TestCustomResources[resourceId].GetType().FullName == propertyType) | ||
{ | ||
return TestCustomResources[resourceId]; | ||
} | ||
return null; | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/Uno.UI.Tests/Windows_UI_Xaml_Markup/XamlReaderTests/When_CustomResource.xamltest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
Name="rootPage" | ||
mc:Ignorable="d"> | ||
|
||
<TextBlock Text="{CustomResource myCustomResource}" /> | ||
</Page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters