Before starting, some information about Snow.
Snow does its magic by replacing the entry point of your program with one of its own, that finds, registers and injects components before executing your code.
This means that the entry point (normally the Main method) is the only part of a program that will have Snow-related code. Everything else is handled transparently using attributes.
Let's start with a new console project.
First, create a new .NET console project, either in Visual Studio or through the command line. Then, follow these steps:
Locate the entry point, and make the class extend the ISnowRunnable interface:
public class Program : ISnowRunnable { public static void Main(string[] args) { Console.WriteLine("Hello, World"); } }
Implement the Run method required by the interface, and move into it the contents of the Main method:
public class Program : ISnowRunnable { public static void Main(string[] args) { } public void Run(string[] args) { Console.WriteLine("Hello, World"); } }
Tell Snow to execute the program:
public class Program : ISnowRunnable { public static void Main(string[] args) { SnowRunner.Run(new Program(), args); } public void Run(string[] args) { Console.WriteLine("Hello, World"); } }
If you run the program at this point, the behavior should remain the same. Snow is now executing your program, even though it has nothing to do yet.
This applies to ASP.NET Core web projects, in all their variants.
Web projects require a bit more of setup, for these purposes:
This modifications are explained somewhere else not yet implemented.
Your project is now properly configured to use Snow. The next step is to create some components and give it something to do.