Bodoconsult.App.Windows
1.0.8
dotnet add package Bodoconsult.App.Windows --version 1.0.8
NuGet\Install-Package Bodoconsult.App.Windows -Version 1.0.8
<PackageReference Include="Bodoconsult.App.Windows" Version="1.0.8" />
<PackageVersion Include="Bodoconsult.App.Windows" Version="1.0.8" />
<PackageReference Include="Bodoconsult.App.Windows" />
paket add Bodoconsult.App.Windows --version 1.0.8
#r "nuget: Bodoconsult.App.Windows, 1.0.8"
#:package Bodoconsult.App.Windows@1.0.8
#addin nuget:?package=Bodoconsult.App.Windows&version=1.0.8
#tool nuget:?package=Bodoconsult.App.Windows&version=1.0.8
Bodoconsult.App.Windows
Overview
What does the library
Bodoconsult.App.Windows provides features related to Microsoft Windows operating system.
Current features are:
Logging to OS event log via EventLogLoggingProviderConfigurator
Reading data from url files (get the included link address in file)
How to use the library
The source code contain a NUnit test classes, the following source code is extracted from. The samples below show the most helpful use cases for the library.
Logging to OS event log via EventLogLoggingProviderConfigurator
With EventLogLoggingProviderConfigurator you can enhance the logging system from Bodoconsult.App based on IAppLoggerProxy with logging to OS event log.
Sending TOAST messages via WindowsToastMessagingService
[Test]
public void SendSimpleToastMessage_NotifyRequestRecord_NotificationIsShown()
{
// Arrange
var request = new NotifyRequestRecord
{
Text = "Das ist eine Message",
Title = "Title"
};
var s = new WindowsToastMessagingService();
// Act and assert
Assert.DoesNotThrow(() =>
{
s.SendSimpleToastMessage(request);
});
}
Using clipboard with Clipboard class
[Test]
public void TestSetText()
{
// Arrange
const string text = "CopyToClipboard";
// Act
Clipboard.SetText(text);
var result = Clipboard.GetText();
// Assert
Assert.That(result, Is.EqualTo(text));
}
Using DataProtectionService to protect sensible string data
[SetUp]
public void Setup()
{
_service = new DataProtectionService();
}
[Test]
public void ProtectUnprotect_CurrentUser_Successful()
{
const string secret = "Test123!";
_service.CurrentDataProtectionScope = DataProtectionScope.CurrentUser;
//Encrypt the data.
var encryptedSecret = _service.ProtectString(secret);
Debug.Print($"The encrypted byte array is: {ArrayHelper.GetStringFromArray(encryptedSecret)}");
// Decrypt the data and store in a byte array.
var originalData = _service.UnprotectString(encryptedSecret);
Debug.Print($"The original data is: {originalData}");
Assert.That(originalData, Is.EqualTo(secret));
}
[Test]
public void ProtectUnprotect_LocalMachine_Successful()
{
const string secret = "Test123!";
_service.CurrentDataProtectionScope = DataProtectionScope.LocalMachine;
//Encrypt the data.
var encryptedSecret = _service.ProtectString(secret);
Debug.Print($"The encrypted byte array is: {ArrayHelper.GetStringFromArray(encryptedSecret)}");
// Decrypt the data and store in a byte array.
var originalData = _service.UnprotectString(encryptedSecret);
Debug.Print($"The original data is: {originalData}");
Assert.That(originalData, Is.EqualTo(secret));
}
``` csharp
Using FileSystemUrl classes: extract a link address
[Test]
public void TestRead()
{
// Arrange
var url = Path.Combine(TestHelper.TestDataPath, "Bodoconsult.url");
var fri = new FileInfo(url);
var urlFile = new FileSystemUrl(fri);
// Act
urlFile.Read();
// Assert
Assert.That(urlFile.Url, Is.EqualTo("http://www.bodoconsult.de/"));
Assert.That(urlFile.Caption, Is.EqualTo("Bodoconsult"));
}
Using IconsAsFilesHelper to get GIF images from an app icon
[Test]
public void SaveIcons_OfficeDocuments_IconExtracted()
{
var iconDocx = Path.Combine(TestHelper.OutputPath, "docx.gif");
if (File.Exists(iconDocx))
{
File.Delete(iconDocx);
}
var iconXlsx = Path.Combine(TestHelper.OutputPath, "xlsx.gif");
if (File.Exists(iconXlsx))
{
File.Delete(iconXlsx);
}
var icons = new IconsAsFilesHelper {IconPath = TestHelper.OutputPath};
var path = Path.Combine(TestHelper.TestDataPath, "Test.docx");
var fri = new FileInfo(path);
icons.AddExtension(fri);
path = Path.Combine(TestHelper.TestDataPath, "Test.xlsx");
fri = new FileInfo(path);
icons.AddExtension(fri);
icons.SaveIcons();
Assert.That(File.Exists(iconDocx));
Assert.That(File.Exists(iconXlsx));
}
About us
Bodoconsult (http://www.bodoconsult.de) is a Munich based software development company from Germany.
Robert Leisner is senior software developer at Bodoconsult. See his profile on http://www.bodoconsult.de/Curriculum_vitae_Robert_Leisner.pdf.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0-windows10.0.17763 is compatible. net10.0-windows was computed. |
-
net9.0-windows10.0.17763
- Bodoconsult.App (>= 1.0.8)
- Bodoconsult.App.Abstractions (>= 1.0.8)
- Microsoft.Extensions.Logging.EventLog (>= 9.0.11)
- Microsoft.Toolkit.Uwp.Notifications (>= 7.1.3)
- Microsoft.Win32.Registry (>= 5.0.0)
- System.Drawing.Common (>= 9.0.11)
- System.Security.Cryptography.ProtectedData (>= 9.0.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Added API docu and new packages