J4JSoftware.DependencyInjection
2.5.0
See the version list below for details.
dotnet add package J4JSoftware.DependencyInjection --version 2.5.0
NuGet\Install-Package J4JSoftware.DependencyInjection -Version 2.5.0
<PackageReference Include="J4JSoftware.DependencyInjection" Version="2.5.0" />
paket add J4JSoftware.DependencyInjection --version 2.5.0
#r "nuget: J4JSoftware.DependencyInjection, 2.5.0"
// Install J4JSoftware.DependencyInjection as a Cake Addin #addin nuget:?package=J4JSoftware.DependencyInjection&version=2.5.0 // Install J4JSoftware.DependencyInjection as a Cake Tool #tool nuget:?package=J4JSoftware.DependencyInjection&version=2.5.0
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 |
FileLocator | Declarative API for locating files experimental |
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
- 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.
- Changes
- Usage
- Integration with J4JDeusEx
- Examples
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 ILogger
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,
ILogger? 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 ILogger 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 andpath
exists,result
is set topath
andtrue
is returned - if write access is required and
path
exists and is writeable,result
is set topath
andtrue
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 andtrue
is returned - if
path
was not found, or ifpath
is rooted (i.e., it's absolute), the specified folders are searched for the file name component ofpath
alone. If a match is found and writeability matches what was specified,result
is set to the matching path andtrue
is returned
- if
- if no match is found,
result
is set tonull
andfalse
is returned.
Product | Versions 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. |
-
net7.0
- Autofac (>= 7.0.0)
- Autofac.Configuration (>= 6.0.0)
- Autofac.Extensions.DependencyInjection (>= 8.0.0)
- J4JSoftware.Configuration.CommandLine (>= 4.3.0)
- J4JSoftware.DeusEx (>= 1.1.0)
- J4JSoftware.LoggingEnhancements (>= 0.5.0)
- J4JSoftware.MiscellaneousUtilities (>= 2.4.0)
- J4JSoftware.TypeUtilities (>= 1.3.0)
- Microsoft.AspNetCore.DataProtection (>= 7.0.4)
- Microsoft.Extensions.Configuration (>= 7.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 7.0.0)
- Microsoft.Extensions.DependencyInjection (>= 7.0.0)
- Microsoft.Extensions.Hosting (>= 7.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 7.0.0)
- Serilog.Extensions.Hosting (>= 5.0.1)
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 | 203 | 5/2/2023 |
2.5.1 | 216 | 4/11/2023 |
2.5.0 | 195 | 4/4/2023 |
2.4.0 | 305 | 1/15/2023 |
2.3.3 | 298 | 1/8/2023 |
2.3.2 | 299 | 1/8/2023 |
2.3.1 | 292 | 1/1/2023 |
2.3.0 | 291 | 12/27/2022 |
2.2.0 | 440 | 2/28/2022 |
2.1.1 | 568 | 11/21/2021 |
2.1.0 | 303 | 11/12/2021 |
2.0.1 | 929 | 9/29/2021 |
2.0.0 | 1,023 | 9/28/2021 |
1.1.0 | 1,016 | 2/3/2021 |
1.0.0 | 438 | 1/21/2021 |
0.8.0 | 370 | 1/9/2021 |
migrated logging from Serilog to Microsoft