Ejemplo n.º 1
0
        public static void Run()
        {
            var estimList = new EstimationList();
            estimList.ListName = "TestEstims";

            estimList.AddEstimation(new EstimationOfElement("Metr2", "Metr2", "MetrExamples.D", 33));
            estimList.AddEstimation(new EstimationOfElement("Metr2", "Metr2", "MetrExamples.B", 11));
            estimList.AddEstimation(new EstimationOfElement("Metr2", "Metr2", "MetrExamples.A", 12));

            // Serialize
            Type[] estimationTypes = { typeof(EstimationOfElement) };
            XmlSerializer serializer = new XmlSerializer(typeof(EstimationList), estimationTypes);
            FileStream fs = new FileStream("EstimationList.xml", FileMode.Create);
            serializer.Serialize(fs, estimList);
            fs.Close();
            estimList = null;

            // Deserialize
            fs = new FileStream("EstimationList.xml", FileMode.Open);
            estimList = (EstimationList)serializer.Deserialize(fs);
            serializer.Serialize(Console.Out, estimList);
        }
Ejemplo n.º 2
0
        private void LoadVotesFromFile()
        {
            form_votes = MetrXML.GoodSerializer.loadFromFileEstimationList(votesFileBox.Text);

            if (form_votes == null)
            {
                form_votes = new EstimationList();
                form_votes.SerializeTo(votesFileBox.Text);
            }

            //{
            //    FileStream fs = null;
            //    try
            //    {
            //        fs = new FileStream(votesFileBox.Text.ToString(), FileMode.Open);
            //        form_votes = (EstimationList)serializer.Deserialize(fs);
            //        fs.Close();
            //    }
            //    catch
            //    {
            //        var path = votesFileBox.Text.ToString();
            //        try
            //        {
            //            if (fs != null) fs.Close();
            //            Directory.CreateDirectory(Directory.GetParent(path).ToString());
            //            File.Delete(path);
            //        }
            //        catch
            //        {
            //        }
            //        File.Create(path).Close();

            //        form_votes = new EstimationList();
            //        saveToFile();
            //    }

            //}
            if (symbolView.Nodes.Count > 0) RefreshSelected(symbolView.SelectedNode);
        }
Ejemplo n.º 3
0
        private void LoadVotesFromFile()
        {
            {
                FileStream fs = null;
                try
                {
                    fs = new FileStream(votesFileBox.Text.ToString(), FileMode.Open);
                    form_votes = (EstimationList)serializer.Deserialize(fs);
                    fs.Close();
                }
                catch
                {
                    var path = votesFileBox.Text.ToString();
                    try
                    {
                        if (fs != null) fs.Close();
                        Directory.CreateDirectory(Directory.GetParent(path).ToString());
                        File.Delete(path);
                    }
                    catch
                    {
                    }
                    File.Create(path).Close();

                    form_votes = new EstimationList();
                    saveToFile();
                }

            }
            if (symbolView.Nodes.Count > 0) RefreshSelected(symbolView.SelectedNode);
        }