public object ReadFile(string file, IProgressMonitor monitor)
        {
            XmlTextReader reader = new XmlTextReader (new StreamReader (file));
            reader.MoveToContent ();

            string version = reader.GetAttribute ("version");
            if (version == null) version = reader.GetAttribute ("fileversion");

            DataSerializer serializer = new DataSerializer (Runtime.ProjectService.DataContext, file);
            ICombineReader combineReader = null;

            if (version == "1.0" || version == "1") {
                combineReader = new CombineReaderV1 (serializer, monitor);
                monitor.ReportWarning (string.Format (GettextCatalog.GetString ("The file '{0}' is using an old combine file format. It will be automatically converted to the current format."), file));
            }
            else if (version == "2.0")
                combineReader = new CombineReaderV2 (serializer, monitor);

            try {
                if (combineReader != null)
                    return combineReader.ReadCombine (reader);
                else
                    throw new UnknownProjectVersionException (file, version);
            } finally {
                reader.Close ();
            }
        }
        public object ReadFile(string fileName, IProgressMonitor monitor)
        {
            XmlTextReader reader = new XmlTextReader (new StreamReader (fileName));
            reader.MoveToContent ();

            string version = reader.GetAttribute ("version");
            if (version == null) version = reader.GetAttribute ("fileversion");

            DataSerializer serializer = new DataSerializer (Runtime.ProjectService.DataContext, fileName);
            IProjectReader projectReader = null;

            if (version == "1.0" || version == "1") {
                string tempFile = Path.GetTempFileName();

                ConvertXml.Convert(fileName,
                                   Runtime.Properties.DataDirectory + Path.DirectorySeparatorChar +
                                   "ConversionStyleSheets" + Path.DirectorySeparatorChar +
                                   "ConvertPrjx10to11.xsl",
                                   tempFile);
                reader.Close ();
                StreamReader sr = new StreamReader (tempFile);
                string fdata = sr.ReadToEnd ();
                sr.Close ();
                File.Delete (tempFile);
                reader = new XmlTextReader (new StringReader (fdata));
                projectReader = new ProjectReaderV1 (serializer);
            }
            else if (version == "1.1") {
                projectReader = new ProjectReaderV1 (serializer);
            }
            else if (version == "2.0") {
                projectReader = new ProjectReaderV2 (serializer);
            }

            if (version != "2.0")
                monitor.ReportWarning (string.Format (GettextCatalog.GetString ("The file '{0}' is using an old project file format. It will be automatically converted to the current format."), fileName));

            try {
                monitor.BeginTask (string.Format (GettextCatalog.GetString ("Loading project: {0}"), fileName), 1);
                if (projectReader != null)
                    return projectReader.ReadProject (reader);
                else
                    throw new UnknownProjectVersionException (fileName, version);
            } catch (Exception ex) {
                monitor.ReportError (string.Format (GettextCatalog.GetString ("Could not load project: {0}"), fileName), ex);
                throw;
            } finally {
                monitor.EndTask ();
                reader.Close ();
            }
        }
 public CombineWriterV2(DataSerializer serializer, IProgressMonitor monitor)
 {
     this.serializer = serializer;
     this.monitor = monitor;
 }
 public CombineReaderV2(DataSerializer serializer, IProgressMonitor monitor)
 {
     this.serializer = serializer;
     combine.FileName = serializer.SerializationContext.BaseFile;
     this.monitor = monitor;
 }
        public void WriteFile(string file, object node, IProgressMonitor monitor)
        {
            Combine combine = node as Combine;
            if (combine == null)
                throw new InvalidOperationException ("The provided object is not a Combine");

            StreamWriter sw = new StreamWriter (file);
            try {
                monitor.BeginTask (string.Format (GettextCatalog.GetString("Saving combine: {0}"), file), 1);
                XmlTextWriter tw = new XmlTextWriter (sw);
                tw.Formatting = Formatting.Indented;
                DataSerializer serializer = new DataSerializer (Runtime.ProjectService.DataContext, file);
                CombineWriterV2 combineWriter = new CombineWriterV2 (serializer, monitor);
                combineWriter.WriteCombine (tw, combine);
            } catch (Exception ex) {
                monitor.ReportError (string.Format (GettextCatalog.GetString ("Could not save combine: {0}"), file), ex);
            } finally {
                monitor.EndTask ();
                sw.Close ();
            }
        }
 public ProjectReaderV2(DataSerializer serializer)
 {
     this.serializer = serializer;
 }
 public ProjectReaderV1(DataSerializer serializer)
 {
     this.serializer = serializer;
     this.file = serializer.SerializationContext.BaseFile;
 }
 public XmlDataSerializer(DataContext ctx)
 {
     serializer = new DataSerializer (ctx);
 }