J4JSoftware.DependencyInjection 2.3.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package J4JSoftware.DependencyInjection --version 2.3.3                
NuGet\Install-Package J4JSoftware.DependencyInjection -Version 2.3.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="J4JSoftware.DependencyInjection" Version="2.3.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add J4JSoftware.DependencyInjection --version 2.3.3                
#r "nuget: J4JSoftware.DependencyInjection, 2.3.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install J4JSoftware.DependencyInjection as a Cake Addin
#addin nuget:?package=J4JSoftware.DependencyInjection&version=2.3.3

// Install J4JSoftware.DependencyInjection as a Cake Tool
#tool nuget:?package=J4JSoftware.DependencyInjection&version=2.3.3                

J4JSoftware.DependencyInjection

API Description
J4JHostConfiguration An extended/enhanced version of the IHost interface. It is incorporated into my J4JDeusEx API to provide a ViewModelLocator capability for most common Windows runtime environments (e.g., console, WPF, Windows Applications aka WinApp3)
FileUtilities Provides a static method for searching for and validating files

J4JHostConfiguration

The J4JHostConfiguration API allows you to create objects implementing the IJ4JHost interface. That interface extends Microsoft's IHost interface to include:

  • the app publisher's name;
  • the application name;
  • the path to where user configuration files are stored (and the paths to individual user configuration files);
  • the path to where application configuration files are storedf (and the paths to individual application configuration files);
  • a flag indicating whether or not the operating system the code is running on has a case sensitive filesystem;
  • various items related to how the command line is parsed:
    • the StringComparison object used to compare text entered on the command line to programmatic values;
    • (optional) the text tokens that serve as lexical elements (e.g., the key prefix, the character(s) used to demarcate strings, etc.) on the command line;
    • the options defined for command line processing;
  • the operating system the code is running on; and,
  • the environment in which the code is running (e.g., console, WPF, WPF in design mode, etc.)

The IJ4JHost instance provides a number of useful services:

  • (optional) logging (via J4JLogger)
  • simple data protection (i.e., encryption and decryption of strings, via Microsoft.AspNetCore.DataProtection)
  • (optional) command line parsing (via J4JCommandLine)
  • dependency injection (via Autofac)

This assembly targets Net 7 and has nullability enabled.

The repository is available online at github.

Sandboxed refers to whether or not the app has, potentially, unfettered access to the filesystem. Modern desktop apps (e.g., Windows Application v3 aka WinApp3, and, I think, UWP) are sandboxed, at least so far as storing application data is concerned. Older desktop environments (e.g., Windows Forms, WPF) are not sandboxed.

FileUtilities

FileExtensions.ValidateFilePath validates the existence and, optionally, writeability, of a file. It can search specified alternative folders for the file if it is not found on the original path that's provided. It also supports logging via my IJ4JLogger system. All log events are set at the Verbose level.

  public static bool ValidateFilePath(
      string path,
      out string? result,
      string? reqdExtension = ".json",
      IEnumerable<string>? folders = null,
      bool requireWriteAccess = false,
      IJ4JLogger? logger = null
  )
Argument Description
path the file path to check
result the path to the file if it was found, or null if it was not
reqdExtension the required file extension (optional; default = .json). If specified, path will be forced to match it.
folders a list of folders to search for the file if it isn't found at path (optional). See below for details.
requireWriteAccess require that path be writeable. This is verified by testing to see if a temporary file can be written to the folder where the file was found (the temporary file is deleted after the test).
logger an instance of IJ4JLogger to record log events (optional). All log events are marked at the Verbose level

ValidateFilePath looks for the required file as follows:

  • if write access to path is not required and path exists, result is set to path and true is returned
  • if write access is required and path exists and is writeable, result is set to path and true is returned
  • any specified folders are searched in the following sequence
    • if path is not rooted (i.e., it's relative), the specified folders are searched using the relative path. If a match is found and writeability matches what was specified, result is set to the matching path and true is returned
    • if path was not found, or if path is rooted (i.e., it's absolute), the specified folders are searched for the file name component of path alone. If a match is found and writeability matches what was specified, result is set to the matching path and true is returned
  • if no match is found, result is set to null and false is returned.
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on J4JSoftware.DependencyInjection:

Package Downloads
J4JSoftware.GeoProcessor

a library for processing GPX, KML and KMZ files, and snapping GPS tracks to roadways

J4JSoftware.WPFUtilities

utilities for console applications

J4JSoftware.GeoProcessorApp

a console application for processing GPX, KML and KMZ files, and snapping GPS tracks to roadways

J4JSoftware.GeoProcessorWPF

a WPF application for processing GPX, KML and KMZ files, and snapping GPS tracks to roadways

J4JSoftware.DeusWinApp

provides J4JDeusEx support for Windows Apps (WinUI 3)

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.6.0 204 5/2/2023
2.5.1 217 4/11/2023
2.5.0 196 4/4/2023
2.4.0 306 1/15/2023
2.3.3 299 1/8/2023
2.3.2 300 1/8/2023
2.3.1 293 1/1/2023
2.3.0 292 12/27/2022
2.2.0 441 2/28/2022
2.1.1 569 11/21/2021
2.1.0 304 11/12/2021
2.0.1 930 9/29/2021
2.0.0 1,024 9/28/2021
1.1.0 1,017 2/3/2021
1.0.0 439 1/21/2021
0.8.0 373 1/9/2021

apply validation/searching functionality when adding application configuration files