/// <summary> /// Takes first OPC in opcDirectory and returns its root patch info. This /// is typically needed to retrieve rendering offsets to prevent rounding errors. /// </summary> public static PatchFileInfo GetFirstPatchFileInfo(string opcDirectory, PositionsType posType) { var paths = OpcFileUtils.OpcPathsFromFolder(opcDirectory); var rootPatchPath = OpcFileUtils.GetRootPatchPath(paths.First()); return(PatchFileInfo.FromFile(rootPatchPath)); }
/// <summary> /// Recursively traverses supplied subPatchMap dictionary and build up a PatchTree. /// </summary> /// <param name="subPatchMap">form of [patchName, List[subPatchName]]</param> private static PatchTree PatchTreeFromPatchName(string patchName, string patchesSubdir, Dictionary <string, IEnumerable <string> > subPatchMap) { IEnumerable <string> subPatches = null; var path = Path.Combine(patchesSubdir, patchName); //read patchfileinfo var info = new PatchFileInfo(); try { info = PatchFileInfo.FromFile(path); info.IsValid = true; } catch (Exception e) { Report.Warn("PatchHierarchyXML: Parsing of patch.xml of path {0} threw an exception {1}", path, e.Message.ToString()); info.IsValid = false; } //if name does not exist in subPatchMap a leaf is reached if (!subPatchMap.TryGetValue(patchName, out subPatches)) { return(new PatchTree(patchName, info)); } //if subnodes exist recurse return(new PatchTree(patchName, info, subPatches.Select(x => PatchTreeFromPatchName(x, patchesSubdir, subPatchMap)) .Where(x => x.Info.IsValid) .ToList())); }
//~Patch() //{ // patchCounter--; // Report.Line("--" + patchCounter); //} public static Patch FromFile(string patchXmlPath, int level, int maxLevel, PositionsType posType) { return(new Patch(PatchFileInfo.FromFile(patchXmlPath), patchXmlPath, level, maxLevel, posType)); }