Пример #1
0
        /// <summary>
        /// Deserializes the experiment.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="experimentFilename">The experiment filename - needed so that experiment can set all relative config paths in relation to experiment location.</param>
        /// <returns></returns>
        internal static Experiment DeserializeExperiment(XmlReader reader, TraceLab.Core.Components.IComponentsLibrary library, string experimentFilename)
        {
            Experiment loadedFlow = null;

            if (reader != null)
            {
                IXPathNavigable doc = new XPathDocument(reader);

                var serializer = TraceLab.Core.Serialization.XmlSerializerFactory.GetSerializer(typeof(PackageSystem.PackageReference), Type.EmptyTypes);

                var references = new ObservableCollection <IPackageReference>();
                // Get the references:
                var nav           = doc.CreateNavigator();
                var referenceIter = nav.Select("/graph/References/PackageReference");
                if (referenceIter != null)
                {
                    while (referenceIter.MoveNext())
                    {
                        var reference = (IPackageReference)serializer.Deserialize(referenceIter.Current.ReadSubtree());
                        references.Add(reference);
                    }
                }

                var graphFactory = new ExperimentFactoryReader(library, references, System.IO.Path.GetDirectoryName(experimentFilename));

                loadedFlow = QuickGraph.Serialization.SerializationExtensions.DeserializeFromXml <ExperimentNode, ExperimentNodeConnection, Experiment>(doc,
                                                                                                                                                        "/graph", "/graph/node", "/graph/edge",
                                                                                                                                                        graphFactory.GraphFactory,
                                                                                                                                                        graphFactory.NodeFactory,
                                                                                                                                                        graphFactory.EdgeFactory
                                                                                                                                                        );

                loadedFlow.References = references;

                //Update the loaded graph and sets its start and end node
                loadedFlow.ReloadStartAndEndNode();

                loadedFlow.ExperimentInfo.FilePath = experimentFilename;
            }

            return(loadedFlow);
        }
Пример #2
0
 /// <summary>
 /// Deserializes the experiment. The relative config paths are not set.
 /// It is valid in case of graphs that belong to composite components metadefinitions
 /// </summary>
 /// <param name="reader">The reader.</param>
 /// <returns></returns>
 public static Experiment DeserializeExperiment(XmlReader reader, TraceLab.Core.Components.IComponentsLibrary library)
 {
     //as default the experiment location is empty - it is valid in case of graphs that belong to composite components metadefinitions
     //before they are added to the experiment
     return(DeserializeExperiment(reader, library, null));
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExperimentSerializer"/> class.
 /// </summary>
 /// <param name="library">The library.</param>
 /// <param name="workspaceTypeDirectories">The workspace type directories.</param>
 /// <param name="dataRoot">The data root.</param>
 /// <param name="settings">The settings.</param>
 public BenchmarkSerializer(TraceLab.Core.Components.IComponentsLibrary library, string dataRoot)
 {
     m_library  = library;
     m_dataRoot = dataRoot;
 }