Exemple #1
0
        /// <summary>
        /// Loads the experiment.
        /// </summary>
        public static void RunExperiment(Experiment experiment)
        {
            IScript script = null;
            switch (experiment.Engine)
            {
                case ScriptingEngines.Python:
                    script = new PythonScript();
                    break;

                case ScriptingEngines.CSharp:
                    script = new CSharpScript();
                    break;

                default:
                    throw new NotImplementedException("The scripting language " + experiment.Engine + "has not yet been implemented.");
            }

            var path = Path.Combine(experiment.Name, experiment.Script);
            script.Load(path);
            script.Compile();
            script.Start();
        }
Exemple #2
0
        /// <summary>
        /// Loads the specified name.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns>Experiment.</returns>
        public static Experiment Load(string name)
        {
            var path = System.IO.Path.Combine(name, ExperimentFilename);
            var xml = XDocument.Load(path);
            if (xml.Root.Name != ExperimentElementName)
                throw new ResearchException("This is not a valid experiment.");

            if (int.Parse(xml.Root.Attribute("schemaVersion").Value) != CurrentSchemaVersion)
                UpgradeSchema(xml);

            var experiment = new Experiment
            {
                Name = xml.Root.Attribute("name").Value,
                Researcher = xml.Root.Attribute("researcher").Value,
                Script = xml.Root.Attribute("script").Value,
                SchemaVersion = int.Parse(xml.Root.Attribute("schemaVersion").Value),
                Engine = (ScriptingEngines) Enum.Parse(typeof(ScriptingEngines), xml.Root.Attribute("engine").Value)
            };
            return experiment;
        }