Example #1
0
        /// <summary>
        /// Refreshes all experiments... needed when Components Library has been rescanned.
        /// </summary>
        /// <param name="experiment">The experiment.</param>
        /// <param name="library">The library.</param>
        /// <returns>experiment</returns>
        public static Experiment ReloadExperiment(Experiment experiment, TraceLab.Core.Components.ComponentsLibrary library)
        {
            if (experiment != null)
            {
                //cache current experiment file path
                string currentPath = experiment.ExperimentInfo.FilePath;

                string tempFile = System.IO.Path.GetTempFileName();

                //reload experiment by saving and loading it
                SerializeExperimentToXml(experiment, tempFile);
                Experiment refreshedExperiment = ExperimentManager.Load(tempFile, library);

                //set m_experiment path to the actual path - from temporary path
                refreshedExperiment.ExperimentInfo.FilePath = currentPath;

                SetNewRootLocationToReferencedFiles(refreshedExperiment, false);

                return(refreshedExperiment);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// Goes through all the vertices in the experiment graph and extracts the components/types assemblies
        /// and other files/directories used.
        /// </summary>
        /// <param name="pVertices">Collection of vertices in the experiment graph.</param>
        public ExperimentPackagingResults PackExperiment(Experiment experiment)
        {
            foreach (ExperimentNode vertex in experiment.Vertices)
            {
                ExtractFilesFromNode(vertex);
            }

            ExperimentPackagingResults results = new ExperimentPackagingResults(experiment);

            results.TypeAssemblies      = new List <string>(this.m_typeAssemblies);
            results.ComponentAssemblies = new List <string>(this.m_componentAssemblies);
            results.Files       = new List <PackageFileInfo>(this.m_files);
            results.Directories = new List <PackageFileInfo>(this.m_directories);

            string tempPath = Path.Combine(Path.GetTempPath(), Path.GetFileName(experiment.ExperimentInfo.FilePath));

            ExperimentManager.SaveAs(experiment, tempPath, ReferencedFiles.IGNORE);

            return(results);
        }