예제 #1
0
        /// <summary>
        /// Initialisiert und startet die Simulation.
        /// </summary>
        /// <param name="settings">Simulationseinstellungen</param>
        public void Start(Setup settings)
        {
            // Check for right State
            if (State != SimulationState.Stopped)
            {
                throw new NotSupportedException("Simulation is not stopped");
            }

            Type t = typeof(SecureHost);

            AppDomainSetup setup = new AppDomainSetup();

            setup.ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
            Evidence evidence = new Evidence();

            try
            {
                _appDomain = AppDomain.CreateDomain("AntMe! Jail", evidence, setup);
                _host      = _appDomain.CreateInstanceAndUnwrap(t.Assembly.FullName, t.FullName) as SecureHost;

                _host.Setup(extensionPaths, settings);

                State = SimulationState.Running;
            }
            catch
            {
                State = SimulationState.Failed;
                Stop();
                throw;
            }

            _deserializer = new StateDeserializer();
        }
예제 #2
0
        public void Stop()
        {
            if (_appDomain != null)
            {
                _host = null;
                AppDomain.Unload(_appDomain);
                _appDomain = null;

                if (_deserializer != null)
                {
                    _deserializer.Dispose();
                    _deserializer = null;
                }
            }
        }