Exemple #1
0
        private Mashup(string fileName, Stream fromStream, out MashupFileWarningList warningList)
        {
            this.dirtyEvent.Add(new DirtyListener(this.SetDirtyFlag));
            this.fileName = fileName;
            D.Assert(fileName == null || Path.GetFullPath(fileName).ToLower().Equals(fileName.ToLower()));
            bool               flag               = false;
            XmlTextReader      reader             = new XmlTextReader(fromStream);
            MashupParseContext mashupParseContext = new MashupParseContext(reader);

            using (mashupParseContext)
            {
                while (mashupParseContext.reader.Read() && !flag)
                {
                    if (mashupParseContext.reader.NodeType == XmlNodeType.Element && mashupParseContext.reader.Name == "MapGrinderMashupFile")
                    {
                        flag = true;
                        this.ReadXML(mashupParseContext);
                    }
                }
                mashupParseContext.Dispose();
            }
            warningList = null;
            if (mashupParseContext.warnings.Count > 0)
            {
                warningList = mashupParseContext.warnings;
            }
            if (!flag)
            {
                throw new InvalidMashupFile(mashupParseContext, string.Format("{0} doesn't appear to be a valid mashup file.", fileName));
            }
            this.ClearDirty();
        }
Exemple #2
0
 public static Mashup OpenMashupInteractive(string fileName, out MashupFileWarningList warningList)
 {
     if (File.Exists(Mashup.GetAutoSaveName(fileName)))
     {
         RecoverAutoSavedFileDialog recoverAutoSavedFileDialog = new RecoverAutoSavedFileDialog();
         recoverAutoSavedFileDialog.Initialize(Mashup.GetAutoSaveName(fileName));
         DialogResult dialogResult = recoverAutoSavedFileDialog.ShowDialog();
         if (dialogResult == DialogResult.Yes)
         {
             Mashup mashup = new Mashup(Mashup.GetAutoSaveName(fileName), out warningList);
             mashup.fileName = Path.Combine(Path.GetDirectoryName(fileName), "Copy of " + Path.GetFileName(fileName));
             mashup.SetDirty();
             mashup.AutoSaveBackup();
             File.Delete(Mashup.GetAutoSaveName(fileName));
             return(mashup);
         }
         if (dialogResult == DialogResult.Ignore)
         {
             File.Delete(Mashup.GetAutoSaveName(fileName));
         }
         else
         {
             if (dialogResult == DialogResult.Cancel)
             {
                 warningList = null;
                 return(null);
             }
             D.Assert(false, "Invalid enum");
         }
     }
     return(new Mashup(fileName, out warningList));
 }
Exemple #3
0
 public Mashup(string fileName, out MashupFileWarningList warningList) : this(fileName,
                                                                              File.Open(fileName, FileMode.Open, FileAccess.Read),
                                                                              out warningList)
 {
 }