Exemple #1
0
 public void SaveProjectFile(Stream stream)
 {
     using (XmlTextWriter writer = new XmlTextWriter(stream, Encoding.Unicode))
     {
         writer.Formatting = Formatting.Indented;
         writer.WriteStartDocument();
         writer.WriteComment("Wabbitcode Config File");
         writer.WriteStartElement("WabbitcodeProject");
         writer.WriteAttributeString("Version", ProjectFileVersion);
         writer.WriteAttributeString("Directory", ProjectDirectory);
         writer.WriteAttributeString("Name", ProjectName);
         RecurseWriteFolders(writer, MainFolder);
         BuildSystem.CreateXML(writer);
         writer.WriteEndElement();
         writer.Flush();
     }
 }
 private void BuildXmlFile()
 {
     using (XmlTextWriter writer = new XmlTextWriter(ProjectFile, Encoding.Unicode)
     {
         Formatting = Formatting.Indented
     })
     {
         writer.WriteStartDocument();
         writer.WriteComment("Wabbitcode Config File");
         writer.WriteStartElement("WabbitcodeProject");
         writer.WriteAttributeString("Version", ProjectFileVersion);
         writer.WriteAttributeString("Name", ProjectName);
         RecurseWriteFolders(writer, _mainFolder);
         _debuggingStructure.WriteXml(writer);
         BuildSystem.WriteXML(writer);
         writer.WriteEndElement();
         writer.Flush();
     }
 }
Exemple #3
0
        public Project(Stream stream, string projectFile)
        {
            using (var reader = new XmlTextReader(stream))
            {
                stream = null;
                reader.WhitespaceHandling = WhitespaceHandling.None;
                reader.MoveToContent();
                while (!reader.Name.Equals("WabbitcodeProject"))
                {
                    if (!reader.MoveToNextElement())
                    {
                        throw new InvalidDataException("Invalid XML Format");
                    }
                }

                string formatVersion = reader.GetAttribute("Version");
                if (formatVersion != ProjectFileVersion)
                {
                    throw new Exception("Invalid Version");
                }
                ProjectFile      = projectFile;
                ProjectDirectory = reader.GetAttribute("Directory");
                if (ProjectDirectory == null)
                {
                    ProjectDirectory = Path.GetDirectoryName(projectFile);
                }
                ProjectName = reader.GetAttribute("Name");
                reader.MoveToNextElement();
                if (reader.Name != "Folder")
                {
                    throw new ArgumentException("Invalid XML Format");
                }
                IProjectFolder mainFolder = new ProjectFolder(this, reader.GetAttribute("Name"));
                RecurseReadFolders(reader, ref mainFolder);
                MainFolder  = mainFolder;
                BuildSystem = new BuildSystem(this, false);
                IncludeDirs = new List <string>();
                BuildSystem.ReadXML(reader);
            }
            ParserService = new ParserService();
        }
 public InternalProject()
 {
     ParserService = new ParserService();
     BuildSystem   = new BuildSystem(this, false);
 }
        public void OpenProject(FilePath projectFile)
        {
            FileStream stream = null;

            try
            {
                stream = new FileStream(projectFile, FileMode.Open);
                using (XmlTextReader reader = new XmlTextReader(stream)
                {
                    WhitespaceHandling = WhitespaceHandling.None
                })
                {
                    stream = null;
                    reader.MoveToContent();
                    while (!reader.Name.Equals("WabbitcodeProject"))
                    {
                        if (!reader.MoveToNextElement())
                        {
                            throw new ArgumentException("Invalid XML Format");
                        }
                    }

                    string formatVersion = reader.GetAttribute("Version");
                    if (formatVersion != ProjectFileVersion)
                    {
                        throw new InvalidProjectVersionException();
                    }

                    ProjectName = reader.GetAttribute("Name");
                    reader.MoveToNextElement();
                    if (reader.Name != "Folder")
                    {
                        throw new ArgumentException("Invalid XML Format");
                    }
                    _mainFolder = new ProjectFolder(null, reader.GetAttribute("Name"));
                    RecurseReadFolders(reader, ref _mainFolder);
                    reader.MoveToNextElement();

                    _debuggingStructure = DebuggingStructureList.FromXml(reader);
                    var displayManager = VariableDisplayManager.Instance;
                    foreach (var debugEnum in _debuggingStructure.DebugEnums)
                    {
                        var enumController = new EnumVariableDisplayController(new ExpressionEvaluator(), debugEnum);
                        displayManager.RegisterVariableDisplayController(enumController);
                    }
                    foreach (var structure in _debuggingStructure.DebugStructs)
                    {
                        displayManager.RegisterVariableDisplayController(new CompositeVariableDisplayController(structure));
                    }

                    BuildSystem.ReadXML(reader);
                }
            }
            finally
            {
                if (stream != null)
                {
                    stream.Dispose();
                }
            }

            SetupWatcher();
        }