Esempio n. 1
0
        public static BheProject FromFile(string fileName)
        {
            string directory = Path.GetDirectoryName(fileName);

            var project = new BheProject();

            project.FileName      = fileName;
            project.DirectoryName = directory;

            project.ProjectText = File.ReadAllText(Path.Combine(directory, "Project.txt"), Encoding.Default);
            project.Summary     = BheSummary.FromFile(Path.Combine(directory, "Summary.txt"));
            project.Sections.AddRange(BheSection.ListFromFile(Path.Combine(directory, "Sections.csv")));

            foreach (string pattern in project.Summary.Patterns)
            {
                string path = Path.Combine(directory, "pat_" + pattern + ".csv");
                project.Patterns.Add(BhePatternItem.ListFromFile(path));
            }

            project.Comments.Add(string.Empty);

            foreach (string comment in project.Summary.Comments.Skip(1))
            {
                string path = Path.Combine(directory, "com_" + comment + ".txt");
                project.Comments.Add(File.ReadAllText(path, Encoding.Default));
            }

            return(project);
        }
Esempio n. 2
0
        public static Project FromFile(string fileName)
        {
            if (!File.Exists(fileName))
            {
                throw new FileNotFoundException(null, fileName);
            }

            var bhe     = BheProject.FromFile(fileName);
            var project = new Project();

            project.FileName      = bhe.FileName;
            project.DirectoryName = bhe.DirectoryName;
            project.ProjectText   = bhe.ProjectText;
            project.ProjectName   = bhe.Summary.ProjectName;
            project.IconPath      = bhe.Summary.IconPath;
            project.BinFilePath   = bhe.Summary.BinFilePath;

            for (int sectionIndex = 0; sectionIndex < bhe.Sections.Count; sectionIndex++)
            {
                var bheSection = bhe.Sections[sectionIndex];
                var section    = new Section();

                section.Project    = project;
                section.Id         = bheSection.Id;
                section.Name       = bheSection.Name;
                section.BaseOffset = bheSection.BaseOffset;

                var bhePatterns = bhe.Patterns[bheSection.PatternId - 1];

                foreach (BhePatternItem bheItem in bhePatterns)
                {
                    var item = new PatternItem();

                    item.Section    = section;
                    item.Offset     = bheItem.Offset;
                    item.Name       = bheItem.Name;
                    item.DataType   = bheItem.DataType;
                    item.DataLength = bheItem.DataLength;
                    item.Comment    = bhe.Comments[bheItem.CommentId - 1];

                    section.Patterns.Add(item);
                }

                project.Sections.Add(section);
            }

            project.Summary = bhe.Summary;

            return(project);
        }