![]() |
VOOZH | about |
dotnet add package DoenaSoft.AbstractionLayer.WPF --version 3.0.6
NuGet\Install-Package DoenaSoft.AbstractionLayer.WPF -Version 3.0.6
<PackageReference Include="DoenaSoft.AbstractionLayer.WPF" Version="3.0.6" />
<PackageVersion Include="DoenaSoft.AbstractionLayer.WPF" Version="3.0.6" />Directory.Packages.props
<PackageReference Include="DoenaSoft.AbstractionLayer.WPF" />Project file
paket add DoenaSoft.AbstractionLayer.WPF --version 3.0.6
#r "nuget: DoenaSoft.AbstractionLayer.WPF, 3.0.6"
#:package DoenaSoft.AbstractionLayer.WPF@3.0.6
#addin nuget:?package=DoenaSoft.AbstractionLayer.WPF&version=3.0.6Install as a Cake Addin
#tool nuget:?package=DoenaSoft.AbstractionLayer.WPF&version=3.0.6Install as a Cake Tool
WPF abstractions that make WPF components easier to mock and unit-test. This project targets multiple frameworks to support legacy .NET Framework and modern .NET desktop applications.
Package Id: DoenaSoft.AbstractionLayer.WPF
Targets: net472, net8.0-windows, net10.0-windows
Usage:
Install the package from NuGet and program against the provided interfaces instead of concrete WPF types to make code testable.
License: MIT
This package provides WPF-specific implementations of the interfaces defined in DoenaSoft.AbstractionLayer.UI. The key interfaces include:
IUIServices - The primary entry point for UI operations. Provides methods to show message boxes and common file/folder dialogs:
ShowMessageBox - Display message boxes with configurable text, caption, buttons, and iconShowOpenFileDialog - Show open file dialogs for single or multiple file selectionShowSaveFileDialog - Show save file dialogsShowFolderBrowserDialog - Show folder browser dialogsIClipboardServices - Comprehensive clipboard operations:
ContainsText, ContainsAudio, ContainsFileDropList, ContainsImage, ContainsDataGetText, GetAudioStream, GetFileDropList, GetImage, GetData, GetDataObjectSetText, SetAudio (byte array or stream), SetFileDropList, SetImage, SetData, SetDataObjectClear - Remove all data from clipboardISynchronizer - Invoke work on the UI thread:
Invoke(Action) - Synchronously invoke an action on the UI threadInvoke<T>(Func<T>) - Synchronously invoke a function and return its resultBeginInvoke(Action) - Asynchronously invoke an action on the UI threadIDispatcherOperation - Represents a posted dispatcher operation:
Result - Gets the result after completionStatus - Gets the current status (Pending, Aborted, Completed, Executing)Task - Gets a Task that represents the operationFileDialogOptions - Base configuration for file dialogsOpenFileDialogOptions - Configuration for open file dialogs (includes multi-select)SaveFileDialogOptions - Configuration for save file dialogsFolderBrowserDialogOptions - Configuration for folder browser dialogsMessageButton - Message box button configuration (OK, YesNo, YesNoCancel)MessageIcon - Message box icon types (None, Information, Warning, Error, Question)Result - Dialog result values (OK, Cancel, Yes, No, etc.)DispatcherStatus - Dispatcher operation status (Pending, Aborted, Completed, Executing)This package provides concrete WPF adapter implementations:
WindowUIServices - Wraps WPF MessageBox and Microsoft.Win32 dialog types and implements IUIServicesWindowClipboardServices - Wraps System.Windows.Clipboard and implements IClipboardServicesWindowSynchronizer - Wraps WPF Dispatcher.Invoke/BeginInvoke and implements ISynchronizerUsage from application code (example view model):
public class MyViewModel
{
private readonly DoenaSoft.AbstractionLayer.UIServices.IUIServices _ui;
private readonly DoenaSoft.AbstractionLayer.UIServices.IClipboardServices _clipboard;
public MyViewModel(
DoenaSoft.AbstractionLayer.UIServices.IUIServices ui,
DoenaSoft.AbstractionLayer.UIServices.IClipboardServices clipboard)
{
_ui = ui;
_clipboard = clipboard;
}
public void OpenFile()
{
var options = new OpenFileDialogOptions
{
Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*",
Title = "Open File"
};
if (_ui.ShowOpenFileDialog(options, out var fileName))
{
// use fileName
}
}
public void PasteFromClipboard()
{
if (_clipboard.ContainsText)
{
var text = _clipboard.GetText();
// use text
}
}
}
Simple fake for unit tests:
class FakeUIServices : DoenaSoft.AbstractionLayer.UIServices.IUIServices
{
public Result ShowMessageBox(string text, string caption, Buttons buttons, Icon icon)
{
return Result.OK;
}
public bool ShowOpenFileDialog(OpenFileDialogOptions options, out string fileName)
{
fileName = "test.txt";
return true;
}
public bool ShowOpenFileDialog(OpenFileDialogOptions options, out string[] fileNames)
{
fileNames = new[] { "test.txt" };
return true;
}
public bool ShowSaveFileDialog(SaveFileDialogOptions options, out string fileName)
{
fileName = "out.txt";
return true;
}
public bool ShowFolderBrowserDialog(FolderBrowserDialogOptions options, out string folder)
{
folder = "C:\\Temp";
return true;
}
}
class FakeClipboardServices : DoenaSoft.AbstractionLayer.UIServices.IClipboardServices
{
public bool ContainsText => true;
public string ClipboardText { get; set; } = string.Empty;
public bool ContainsAudio() => false;
public bool ContainsFileDropList() => false;
public bool ContainsImage() => false;
public bool ContainsData(string format) => false;
public void Clear() => ClipboardText = string.Empty;
public string GetText() => ClipboardText;
public Stream GetAudioStream() => null;
public StringCollection GetFileDropList() => null;
public object GetImage() => null;
public object GetData(string format) => null;
public object GetDataObject() => null;
public bool SetText(string text)
{
ClipboardText = text;
return true;
}
public void SetAudio(byte[] audioBytes) { }
public void SetAudio(Stream audioStream) { }
public void SetFileDropList(StringCollection filePaths) { }
public void SetImage(object image) { }
public void SetData(string format, object data) { }
public void SetDataObject(object data, bool copy, int retryTimes, int retryDelay) { }
}
class FakeSynchronizer : DoenaSoft.AbstractionLayer.UI.Contracts.ISynchronizer
{
public void Invoke(Action action) => action();
public T Invoke<T>(Func<T> func) => func();
public IDispatcherOperation BeginInvoke(Action action)
{
action();
return new FakeDispatcherOperation();
}
}
class FakeDispatcherOperation : DoenaSoft.AbstractionLayer.UI.Contracts.IDispatcherOperation
{
public object Result => null;
public DispatcherStatus Status => DispatcherStatus.Completed;
public Task Task => Task.CompletedTask;
}
DoenaSoft.AbstractionLayer.UI version 2.0.1 or later, which contains the contract interfaces and data types.System.Windows.*) to implement the UI contracts.| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0-windows7.0 net8.0-windows7.0 is compatible. net9.0-windows net9.0-windows was computed. net10.0-windows net10.0-windows was computed. net10.0-windows7.0 net10.0-windows7.0 is compatible. |
| .NET Framework | net472 net472 is compatible. net48 net48 was computed. net481 net481 was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.6 | 106 | 5/18/2026 |
| 3.0.5 | 121 | 4/12/2026 |
| 3.0.4 | 122 | 3/29/2026 |
| 2.0.1 | 239 | 7/27/2024 |
| 2.0.0 | 254 | 5/7/2024 |
| 1.1.8 | 352 | 12/5/2023 |
| 1.1.7 | 237 | 12/3/2023 |
| 1.1.6 | 251 | 12/3/2023 |
| 1.1.5 | 245 | 9/12/2023 |
| 1.1.4 | 275 | 8/28/2023 |
| 1.1.3 | 270 | 8/28/2023 |
| 1.1.2 | 275 | 8/28/2023 |
| 1.1.1 | 258 | 8/28/2023 |
| 1.1.0 | 270 | 8/28/2023 |
| 1.0.0 | 282 | 8/28/2023 |