예제 #1
0
    private static void Main(string[] args)
    {
        var initStep = new HedgemenInitStep
        {
            Backend      = new HedgemenBackend(),
            KazeInitStep = new KazeInitStep
            {
                Registry = new KazeRegistry()
            },
            Logger = new DefaultLogger()
        };

        try
        {
            Hedgemen.InitializeHedgemen(initStep);
            Hedgemen.Backend.Run();
            IFile hedgemenLogOutputFile = new File("hedgemen.log");
            hedgemenLogOutputFile.WriteString(Hedgemen.Logger.ToString());
            Hedgemen.Finish();
        }

        catch (Exception e)
        {
            // this might cause issues where the IFile.WriteString method is the method causing the exception to
            // be thrown, but I'm lazy
            IFile hedgemenLogOutputFile = new File("hedgemen.log");
            hedgemenLogOutputFile.WriteString(Hedgemen.Logger.ToString());
            throw;
        }
    }
예제 #2
0
    public static void InitializeHedgemen(HedgemenInitStep init)
    {
        if (_initialized)
        {
            throw new InvalidOperationException($"{typeof(Hedgemen)} is already initialized!");
        }

        bool initStateProperlySet = init.IsProperlyInitialized();

        if (!initStateProperlySet)
        {
            throw new ArgumentException($"'{nameof(init)}' is not properly initialized!");
        }

        Backend               = init.Backend;
        Kaze                  = new Kaze(init.KazeInitStep);
        Logger                = init.Logger;
        _initialized          = true;
        _registeredAssemblies = new Dictionary <string, Assembly>();
    }