ToolBX.ProjectMaster
2.0.0-beta1
See the version list below for details.
dotnet add package ToolBX.ProjectMaster --version 2.0.0-beta1
NuGet\Install-Package ToolBX.ProjectMaster -Version 2.0.0-beta1
<PackageReference Include="ToolBX.ProjectMaster" Version="2.0.0-beta1" />
paket add ToolBX.ProjectMaster --version 2.0.0-beta1
#r "nuget: ToolBX.ProjectMaster, 2.0.0-beta1"
// Install ToolBX.ProjectMaster as a Cake Addin #addin nuget:?package=ToolBX.ProjectMaster&version=2.0.0-beta1&prerelease // Install ToolBX.ProjectMaster as a Cake Tool #tool nuget:?package=ToolBX.ProjectMaster&version=2.0.0-beta1&prerelease
ProjectMaster
Provides a base class to format and access application data paths in an easy and straightforward way.
This package merely combines your data paths with your application name in a reusable class so that you don't have to repeat yourself.
//Instead of doing this
var path = Path.Combine(Environment.SpecialFolder.LocalApplicationData, "My Application");
//You can just do this
var path = _projectEnvironment.LocalUser;
Getting started
Setup
ProjectMaster works with DI so you're going to have to use the following method wherever you inject things to get it to work:
services.AddNetAbstractions();
You can skip the above line if you are already using either ToolBX.AutoInject or ToolBX.AssemblyInitializer.
Creating your own ProjectEnvironment class
public class MyProjectEnvironment : ProjectEnvironment
{
//Organization is optional and can be left blank
protected override string OrganizationName => "My organization";
//Project is mandatory and your ProjectEnvironment class WILL throw if it is omitted or left blank
protected override string ProjectName => "My project";
public DummyProjectEnvironment(IServiceProvider serviceProvider) : base(serviceProvider)
{
}
}
You can (should) take advantage of the AutoInject library this way but it is entirely up to you :
//It will automatically link to IProjectEnvironment so you don't even need to make your own interface!
[AutoInject]
public class MyProjectEnvironment : ProjectEnvironment
{
...
}
Otherwise, you can use the following to inject it manually :
services.AddSingleton<IProjectEnvironment, MyProjectEnvironment>();
How do I use it?
Once you have your custom class and it is injected in your code :
private readonly IProjectEnvironment _projectEnvironment;
public SomeClass(IProjectEnvironment projectEnvironment)
{
_projectEnvironment = projectEnvironment;
}
public void Something()
{
//On windows would return something like : "c:/Users/Default/AppData/Local/My organization/My project/"
var path = _projectEnvironment.AllUsers;
//"c:/Users/YourName/AppData/Local/My organization/My project/"
path = _projectEnvironment.LocalUser;
//"c:/Users/YourName/AppData/Roaming/My organization/My project/"
path = _projectEnvironment.RoamingUser;
//"c:/Users/YourName/AppData/Local/Temp/My organization/My project/"
path = _projectEnvironment.TemporaryFiles;
}
I'm making a video game : where should save files go?
There is not a one-size fits all response to this. Some put it in the local user's app data but others put it in the user's Documents folder. I even hear that it's not uncommon to keep save files in the game's installation folder.
Steam seems to like putting it in 'Documents/My Games/Game name/'.
Personally, I put it in the roaming user's folder. This approach should work seamlessly across most (if not all) modern operating systems.
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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net7.0
- ToolBX.AutoInject (>= 2.0.0-beta1)
- ToolBX.NetAbstractions (>= 2.0.0-beta1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.0.0 | 114 | 9/27/2024 |
3.0.0-beta1 | 82 | 9/23/2024 |
2.2.0 | 142 | 1/13/2024 |
2.2.0-beta1 | 116 | 1/7/2024 |
2.0.2 | 167 | 6/19/2023 |
2.0.1 | 209 | 4/27/2023 |
2.0.0 | 333 | 11/12/2022 |
2.0.0-beta1 | 137 | 10/7/2022 |
1.0.1 | 428 | 10/7/2022 |
1.0.0 | 444 | 6/22/2022 |