-
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.
Container logics improved and localization tests
- Loading branch information
1 parent
fc53196
commit 1b92577
Showing
13 changed files
with
147 additions
and
58 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
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
This file was deleted.
Oops, something went wrong.
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
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
20 changes: 20 additions & 0 deletions
20
Hypocrite.Wpf/Localization/LocalizationChangedExpression.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,20 @@ | ||
using System.Windows; | ||
|
||
namespace Hypocrite.Localization | ||
{ | ||
public class LocalizationChangedExpression | ||
{ | ||
/// <summary> | ||
/// Constructor for ResourceReferenceExpression | ||
/// </summary> | ||
/// <param name="resourceKey"> | ||
/// Name of the resource being referenced | ||
/// </param> | ||
public LocalizationChangedExpression(object resourceKey) | ||
{ | ||
_resourceKey = resourceKey; | ||
} | ||
|
||
private object _resourceKey; // Name of the resource being referenced by this expression | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
Hypocrite.Wpf/Localization/LocalizedResourceTestExtension.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,90 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using System.Windows.Data; | ||
using System.Windows.Input; | ||
using System.Windows.Markup; | ||
|
||
namespace Hypocrite.Localization | ||
{ | ||
[MarkupExtensionReturnType(typeof(object))] | ||
public class LocalizedResourceTestExtension : MarkupExtension, INotifyPropertyChanged | ||
{ | ||
/// <summary> | ||
/// Holds the Binding to get the key | ||
/// </summary> | ||
private Binding _binding; | ||
/// <summary> | ||
/// Holds the Key to a .resx object | ||
/// </summary> | ||
private string _key; | ||
/// <summary> | ||
/// Gets or sets the Key to a .resx object | ||
/// </summary> | ||
public string Key | ||
{ | ||
get => _key; | ||
set | ||
{ | ||
if (_key != value) | ||
{ | ||
_key = value; | ||
OnNotifyPropertyChanged(nameof(Key)); | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the initialize value. | ||
/// This is ONLY used to support the localize extension in blend! | ||
/// </summary> | ||
/// <value>The initialize value.</value> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
[ConstructorArgument("key")] | ||
public object InitializeValue { get; set; } | ||
|
||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
/// <summary> | ||
/// Constructor that takes no parameters | ||
/// </summary> | ||
public LocalizedResourceTestExtension() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Constructor that takes the resource key that this is a static reference to. | ||
/// </summary> | ||
public LocalizedResourceTestExtension( | ||
object key) | ||
{ | ||
if (key is Binding binding) | ||
_binding = binding; | ||
else | ||
Key = key?.ToString(); | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Return an object that should be set on the targetObject's targetProperty | ||
/// for this markup extension. For DynamicResourceExtension, this is the object found in | ||
/// a resource dictionary in the current parent chain that is keyed by ResourceKey | ||
/// </summary> | ||
/// <returns> | ||
/// The object to set on this property. | ||
/// </returns> | ||
public override object ProvideValue(IServiceProvider serviceProvider) | ||
{ | ||
if (Key == null) | ||
{ | ||
throw new InvalidOperationException(); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
internal void OnNotifyPropertyChanged(string property) | ||
{ | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property)); | ||
} | ||
} | ||
} |
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