This repository has been archived on 2023-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
mfgames-nitride-cil/examples/CopyFiles/CopyFilesProgram.cs

50 lines
1.8 KiB
C#
Raw Normal View History

using System.IO;
using System.Threading.Tasks;
using Autofac;
using MfGames.IO.Extensions;
2022-09-06 05:53:22 +00:00
using MfGames.Nitride;
using MfGames.Nitride.IO;
namespace CopyFiles;
/// <summary>
/// Main entry point into the CopyFiles sample generator.
/// </summary>
public static class CopyFilesProgram
{
public static async Task<int> Main(string[] args)
{
// All of the builder methods are fluent in that they return the
// builder to allow them to be chained. However, for documentation
// purposes, we are going to split them apart to explain the details.
var builder = new NitrideBuilder(args);
// Filesystem access is provided by Zio, which allows for mutliple
// folders to be combined together into a single unified file
// system. At the moment, we set the "root" directory which will
// contains all the paths, both input and output.
DirectoryInfo rootDir =
typeof(CopyFilesProgram).GetDirectory()!.FindGitRoot()!.GetDirectory("examples/CopyFiles");
builder.WithRootDirectory(rootDir);
// Like Serilog, we use a number of extension methods on the builder
// to inject functionality such as plugins and extensions. In this
// case, we only need the Nitride.IO module so we use the `UseIO`
// to inject the requisite modules and configure it.
builder.UseIO();
// We use Autofac for the bulk of our registration handling. This
// was mainly because we are more comfortable with Autofac, but it
// also has a clean interface for handling some of the more esoteric
// problems we've encountered.
builder.ConfigureContainer(x => x.RegisterModule<CopyFilesModule>());
// Finally, we build the site generator object and run it.
return await builder.RunAsync();
}
}