/// <summary>
        /// Creates new m_experiment.
        /// </summary>
        /// <returns>Returns newly created m_experiment.</returns>
        public static Experiment New()
        {
            Experiment newExperiment = new Experiment(NewExperimentName, string.Empty);
            ExperimentStartNode start = new ExperimentStartNode();
            start.Data.X = 200;
            start.Data.Y = 100;
            newExperiment.AddVertex(start);
            
            ExperimentEndNode end = new ExperimentEndNode();
            end.Data.X = 200;
            end.Data.Y = 200;
            newExperiment.AddVertex(end);

            newExperiment.ReloadStartAndEndNode();
            newExperiment.ResetModifiedFlag();

            return newExperiment;
        }
Beispiel #2
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);
        }
Beispiel #3
0
        /// <summary>
        /// Creates new m_experiment.
        /// </summary>
        /// <returns>Returns newly created m_experiment.</returns>
        public static Experiment New()
        {
            Experiment          newExperiment = new Experiment(NewExperimentName, string.Empty);
            ExperimentStartNode start         = new ExperimentStartNode();

            start.Data.X = 200;
            start.Data.Y = 100;
            newExperiment.AddVertex(start);

            ExperimentEndNode end = new ExperimentEndNode();

            end.Data.X = 200;
            end.Data.Y = 200;
            newExperiment.AddVertex(end);

            newExperiment.ReloadStartAndEndNode();
            newExperiment.ResetModifiedFlag();

            return(newExperiment);
        }