From 26d41741a1bd1d884776382570299ff278b7119f Mon Sep 17 00:00:00 2001 From: jbe2277 Date: Fri, 19 Jul 2024 21:50:34 +0200 Subject: [PATCH] InfoMan: Reference ValueConverters via Static instead of StaticResource --- .../Properties/DesignTimeResources.xaml | 1 - .../Properties/DesignTimeResources.xaml | 1 - .../Views/ContactListView.xaml | 9 +++++---- .../Samples/InformationManager/Assembler/App.xaml | 1 - .../Converters/TargetStringEmptyValueConverter.cs | 3 +++ .../Properties/DesignTimeResources.xaml | 1 - .../Resources/ControlResources.xaml | 5 +++-- .../Resources/ConverterResources.xaml | 12 ------------ .../Converters/StringCollectionToStringConverter.cs | 2 ++ .../Properties/DesignTimeResources.xaml | 3 --- .../Resources/ConverterResources.xaml | 7 ------- .../Services/PresentationService.cs | 11 ----------- .../Views/EmailListView.xaml | 3 ++- .../Views/EmailView.xaml | 7 ++++--- .../Views/Pop3SettingsView.xaml | 5 +++-- .../Converters/ItemCountToStringConverter.cs | 2 ++ .../Properties/DesignTimeResources.xaml | 3 --- .../Resources/ConverterResources.xaml | 7 ------- .../Services/PresentationService.cs | 3 --- .../Views/ShellWindow.xaml | 3 ++- 20 files changed, 26 insertions(+), 63 deletions(-) delete mode 100644 src/System.Waf/Samples/InformationManager/Common.Presentation/Resources/ConverterResources.xaml delete mode 100644 src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Resources/ConverterResources.xaml delete mode 100644 src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Services/PresentationService.cs delete mode 100644 src/System.Waf/Samples/InformationManager/Infrastructure.Modules.Presentation/Resources/ConverterResources.xaml diff --git a/src/System.Waf/Samples/BookLibrary/BookLibrary.Reporting.Presentation/Properties/DesignTimeResources.xaml b/src/System.Waf/Samples/BookLibrary/BookLibrary.Reporting.Presentation/Properties/DesignTimeResources.xaml index c4589b7b..dec51af4 100644 --- a/src/System.Waf/Samples/BookLibrary/BookLibrary.Reporting.Presentation/Properties/DesignTimeResources.xaml +++ b/src/System.Waf/Samples/BookLibrary/BookLibrary.Reporting.Presentation/Properties/DesignTimeResources.xaml @@ -4,7 +4,6 @@ - diff --git a/src/System.Waf/Samples/InformationManager/AddressBook.Modules.Presentation/Properties/DesignTimeResources.xaml b/src/System.Waf/Samples/InformationManager/AddressBook.Modules.Presentation/Properties/DesignTimeResources.xaml index 7651054b..3628b8da 100644 --- a/src/System.Waf/Samples/InformationManager/AddressBook.Modules.Presentation/Properties/DesignTimeResources.xaml +++ b/src/System.Waf/Samples/InformationManager/AddressBook.Modules.Presentation/Properties/DesignTimeResources.xaml @@ -2,7 +2,6 @@ - diff --git a/src/System.Waf/Samples/InformationManager/AddressBook.Modules.Presentation/Views/ContactListView.xaml b/src/System.Waf/Samples/InformationManager/AddressBook.Modules.Presentation/Views/ContactListView.xaml index 97c270a0..07730ac4 100644 --- a/src/System.Waf/Samples/InformationManager/AddressBook.Modules.Presentation/Views/ContactListView.xaml +++ b/src/System.Waf/Samples/InformationManager/AddressBook.Modules.Presentation/Views/ContactListView.xaml @@ -2,6 +2,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ctrl="clr-namespace:Waf.InformationManager.Common.Presentation.Controls;assembly=Waf.InformationManager.Common.Presentation" + xmlns:cc="clr-namespace:Waf.InformationManager.Common.Presentation.Converters;assembly=Waf.InformationManager.Common.Presentation" xmlns:dd="clr-namespace:Waf.InformationManager.AddressBook.Modules.Presentation.DesignData" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" @@ -34,13 +35,13 @@ - + - + - + - + diff --git a/src/System.Waf/Samples/InformationManager/Assembler/App.xaml b/src/System.Waf/Samples/InformationManager/Assembler/App.xaml index aa4d7322..45ed4ad6 100644 --- a/src/System.Waf/Samples/InformationManager/Assembler/App.xaml +++ b/src/System.Waf/Samples/InformationManager/Assembler/App.xaml @@ -5,7 +5,6 @@ - diff --git a/src/System.Waf/Samples/InformationManager/Common.Presentation/Converters/TargetStringEmptyValueConverter.cs b/src/System.Waf/Samples/InformationManager/Common.Presentation/Converters/TargetStringEmptyValueConverter.cs index 7552ae18..7d6c2707 100644 --- a/src/System.Waf/Samples/InformationManager/Common.Presentation/Converters/TargetStringEmptyValueConverter.cs +++ b/src/System.Waf/Samples/InformationManager/Common.Presentation/Converters/TargetStringEmptyValueConverter.cs @@ -6,6 +6,9 @@ namespace Waf.InformationManager.Common.Presentation.Converters; /// Value converter that returns a special string if the (string) value is null or empty. public class TargetStringEmptyValueConverter : IValueConverter { + /// Default instance of the TargetStringEmptyValueConverter. + public static TargetStringEmptyValueConverter Default { get; } = new(); + /// Returns a special string if the (string) value is null or empty. Otherwise it returns value. /// The string value to convert. /// The type of the binding target property. This parameter will be ignored. diff --git a/src/System.Waf/Samples/InformationManager/Common.Presentation/Properties/DesignTimeResources.xaml b/src/System.Waf/Samples/InformationManager/Common.Presentation/Properties/DesignTimeResources.xaml index df04ab3e..6bfef78c 100644 --- a/src/System.Waf/Samples/InformationManager/Common.Presentation/Properties/DesignTimeResources.xaml +++ b/src/System.Waf/Samples/InformationManager/Common.Presentation/Properties/DesignTimeResources.xaml @@ -2,7 +2,6 @@ - diff --git a/src/System.Waf/Samples/InformationManager/Common.Presentation/Resources/ControlResources.xaml b/src/System.Waf/Samples/InformationManager/Common.Presentation/Resources/ControlResources.xaml index 265464e6..f7ef3e1e 100644 --- a/src/System.Waf/Samples/InformationManager/Common.Presentation/Resources/ControlResources.xaml +++ b/src/System.Waf/Samples/InformationManager/Common.Presentation/Resources/ControlResources.xaml @@ -1,5 +1,6 @@  + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:waf="http://waf.codeplex.com/schemas"> @@ -8,7 +9,7 @@ - + diff --git a/src/System.Waf/Samples/InformationManager/Common.Presentation/Resources/ConverterResources.xaml b/src/System.Waf/Samples/InformationManager/Common.Presentation/Resources/ConverterResources.xaml deleted file mode 100644 index 4d9371fc..00000000 --- a/src/System.Waf/Samples/InformationManager/Common.Presentation/Resources/ConverterResources.xaml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Converters/StringCollectionToStringConverter.cs b/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Converters/StringCollectionToStringConverter.cs index 2fd62ca2..4a75eaea 100644 --- a/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Converters/StringCollectionToStringConverter.cs +++ b/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Converters/StringCollectionToStringConverter.cs @@ -5,6 +5,8 @@ namespace Waf.InformationManager.EmailClient.Modules.Presentation.Converters; public class StringCollectionToStringConverter : IValueConverter { + public static StringCollectionToStringConverter Default { get; } = new(); + public object Convert(object? value, Type? targetType, object? parameter, CultureInfo? culture) => string.Join("; ", (IEnumerable)value!); public object ConvertBack(object? value, Type? targetType, object? parameter, CultureInfo? culture) => throw new NotSupportedException(); diff --git a/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Properties/DesignTimeResources.xaml b/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Properties/DesignTimeResources.xaml index 8a83138e..6a554e03 100644 --- a/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Properties/DesignTimeResources.xaml +++ b/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Properties/DesignTimeResources.xaml @@ -2,12 +2,9 @@ - - - \ No newline at end of file diff --git a/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Resources/ConverterResources.xaml b/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Resources/ConverterResources.xaml deleted file mode 100644 index 58a3ece4..00000000 --- a/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Resources/ConverterResources.xaml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Services/PresentationService.cs b/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Services/PresentationService.cs deleted file mode 100644 index 9818ce9d..00000000 --- a/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Services/PresentationService.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.ComponentModel.Composition; -using System.Waf.Presentation; -using Waf.InformationManager.Common.Applications.Services; - -namespace Waf.InformationManager.EmailClient.Modules.Presentation.Services; - -[Export(typeof(IPresentationService))] -internal sealed class PresentationService : IPresentationService -{ - public void Initialize() => ResourceHelper.AddToApplicationResources(typeof(PresentationService).Assembly, "Resources/ConverterResources.xaml"); -} diff --git a/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Views/EmailListView.xaml b/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Views/EmailListView.xaml index 113cd358..9d644ea2 100644 --- a/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Views/EmailListView.xaml +++ b/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Views/EmailListView.xaml @@ -1,6 +1,7 @@  - diff --git a/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Views/EmailView.xaml b/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Views/EmailView.xaml index 93d52073..ad36c6b4 100644 --- a/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Views/EmailView.xaml +++ b/src/System.Waf/Samples/InformationManager/EmailClient.Modules.Presentation/Views/EmailView.xaml @@ -1,6 +1,7 @@  \ No newline at end of file diff --git a/src/System.Waf/Samples/InformationManager/Infrastructure.Modules.Presentation/Resources/ConverterResources.xaml b/src/System.Waf/Samples/InformationManager/Infrastructure.Modules.Presentation/Resources/ConverterResources.xaml deleted file mode 100644 index d1e82ab7..00000000 --- a/src/System.Waf/Samples/InformationManager/Infrastructure.Modules.Presentation/Resources/ConverterResources.xaml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/System.Waf/Samples/InformationManager/Infrastructure.Modules.Presentation/Services/PresentationService.cs b/src/System.Waf/Samples/InformationManager/Infrastructure.Modules.Presentation/Services/PresentationService.cs index bb555fb5..ba08318a 100644 --- a/src/System.Waf/Samples/InformationManager/Infrastructure.Modules.Presentation/Services/PresentationService.cs +++ b/src/System.Waf/Samples/InformationManager/Infrastructure.Modules.Presentation/Services/PresentationService.cs @@ -1,6 +1,5 @@ using System.ComponentModel.Composition; using System.Globalization; -using System.Waf.Presentation; using System.Windows; using System.Windows.Markup; using Waf.InformationManager.Common.Applications.Services; @@ -13,7 +12,5 @@ internal sealed class PresentationService : IPresentationService public void Initialize() { FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); - - ResourceHelper.AddToApplicationResources(typeof(PresentationService).Assembly, "Resources/ConverterResources.xaml"); } } diff --git a/src/System.Waf/Samples/InformationManager/Infrastructure.Modules.Presentation/Views/ShellWindow.xaml b/src/System.Waf/Samples/InformationManager/Infrastructure.Modules.Presentation/Views/ShellWindow.xaml index 17c0dfbc..132a73ae 100644 --- a/src/System.Waf/Samples/InformationManager/Infrastructure.Modules.Presentation/Views/ShellWindow.xaml +++ b/src/System.Waf/Samples/InformationManager/Infrastructure.Modules.Presentation/Views/ShellWindow.xaml @@ -1,6 +1,7 @@  - +