Example #1
0
        public VoidResult Initialize(SaveAndLoad sal)
        {
            this.SaveAndLoad = sal;
            this.SaveAndLoad.Pyrite = this;

            var result = new VoidResult();

            ScenariosPool = new ScenariosPool();
            ScenariosPool.Pyrite = this;
            ScenariosPool.Initialize();
            Log.Write("ScenariosPool initialized");

            ModulesControl = new ModulesControl();
            ModulesControl.Pyrite = this;
            result.AddExceptions(ModulesControl.Initialize().Exceptions);
            Log.Write("ModulesControl initialized");
            ServerThreading = new PyriteCore.ServerThreading();
            ServerThreading.Pyrite = this;
            ServerThreading.ServerStarted += () => ScenariosPool.StartActiveScenarios();
            Log.Write("ScenariosPool items started");
            ServerThreading.Initialize();
            Log.Write("ServerThreading started");

            result.AddExceptions(SaveAndLoad.Load().Exceptions);
            result.AddExceptions(ServerThreading.BeginStart().Exceptions);

            return result;
        }
Example #2
0
        public VoidResult ReIntialize(Action<VoidResult> callback)
        {
            var result = new VoidResult();
            ModulesControl.Clear();
            ScenariosPool.Clear();

            result.AddExceptions(SaveAndLoad.Load().Exceptions);

            Stop(() =>
            {
                try
                {
                    ServerThreading.BeginStart();
                    Log.Write("ServerThreading started");
                    ServerThreading.ServerStarted += () => ScenariosPool.StartActiveScenarios();
                    Log.Write("ScenariosPool items started");
                    callback(result);
                }
                catch (Exception e)
                {
                    result.AddException(e);
                }
            });

            return result;
        }