internal static void NestContext(XElement stylesProperty, string baseDirectory, IDictionary <string, SortedDictionary <string, byte[]> > classData, Dictionary <string, string> guidToClassMapping) { var stylesDir = baseDirectory; // Just use main folder. // Path.Combine(baseDirectory, SharedConstants.Styles); if (!Directory.Exists(stylesDir)) { Directory.CreateDirectory(stylesDir); } BaseDomainServices.NestStylesPropertyElement(classData, guidToClassMapping, stylesProperty, Path.Combine(stylesDir, StyleFilename)); }
internal static void NestContext(string generalBaseDir, IDictionary <string, XElement> wellUsedElements, IDictionary <string, SortedDictionary <string, byte[]> > classData, Dictionary <string, string> guidToClassMapping) { var langProjElement = wellUsedElements[SharedConstants.LangProject]; // LP AnnotationDefs (OA-CmPossibilityList). AnnotationDefs.list] FileWriterService.WriteNestedListFileIfItExists(classData, guidToClassMapping, langProjElement, SharedConstants.AnnotationDefs, Path.Combine(generalBaseDir, SharedConstants.AnnotationDefsListFilename)); // LP Styles (OC-StStyle) is used by everyone, but Scripture, so they go here. BaseDomainServices.NestStylesPropertyElement( classData, guidToClassMapping, langProjElement.Element(SharedConstants.Styles), Path.Combine(generalBaseDir, SharedConstants.FLExStylesFilename)); // LP Filters (OC) can go into one filters file here. (FLExFilters.filter: new ext) var owningPropElement = langProjElement.Element(SharedConstants.Filters); if (owningPropElement != null && owningPropElement.HasElements) { var root = new XElement(SharedConstants.Filters); foreach (var filterObjSurElement in owningPropElement.Elements().ToList()) { var filterGuid = filterObjSurElement.Attribute(SharedConstants.GuidStr).Value.ToLowerInvariant(); var className = guidToClassMapping[filterGuid]; var filterElement = Utilities.CreateFromBytes(classData[className][filterGuid]); CmObjectNestingService.NestObject(false, filterElement, classData, guidToClassMapping); root.Add(filterElement); } FileWriterService.WriteNestedFile(Path.Combine(generalBaseDir, SharedConstants.FLExFiltersFilename), root); owningPropElement.RemoveNodes(); } // LP Annotations (OC). Who still uses them? If all else fails, or they are used by several BCs, then store them in one file here. // [FLExAnnotations.annotation: new ext] // OJO! Sig is "CmAnnotation", which is abtract class, so handle like in Discourse-land. owningPropElement = langProjElement.Element(SharedConstants.Annotations); if (owningPropElement != null && owningPropElement.HasElements) { var root = new XElement(SharedConstants.Annotations); foreach (var annotationObjSurElement in owningPropElement.Elements().ToList()) { var annotationGuid = annotationObjSurElement.Attribute(SharedConstants.GuidStr).Value.ToLowerInvariant(); var className = guidToClassMapping[annotationGuid]; var annotationElement = Utilities.CreateFromBytes(classData[className][annotationGuid]); CmObjectNestingService.NestObject(false, annotationElement, classData, guidToClassMapping); BaseDomainServices.ReplaceElementNameWithAndAddClassAttribute(SharedConstants.CmAnnotation, annotationElement); root.Add(annotationElement); } FileWriterService.WriteNestedFile(Path.Combine(generalBaseDir, SharedConstants.FLExAnnotationsFilename), root); owningPropElement.RemoveNodes(); } // Some CmPicture instances may not be owned. var rootElement = new XElement(SharedConstants.Pictures); var unownedPictures = classData[SharedConstants.CmPicture].Values.Where(listElement => XmlUtils.GetAttributes(listElement, new HashSet <string> { SharedConstants.OwnerGuid })[SharedConstants.OwnerGuid] == null).ToList(); foreach (var unownedPictureBytes in unownedPictures) { var element = Utilities.CreateFromBytes(unownedPictureBytes); CmObjectNestingService.NestObject( false, element, classData, guidToClassMapping); rootElement.Add(element); } FileWriterService.WriteNestedFile(Path.Combine(generalBaseDir, SharedConstants.FLExUnownedPicturesFilename), rootElement); // No VirtualOrdering instances are owned. if (MetadataCache.MdCache.ModelVersion > MetadataCache.StartingModelVersion) { rootElement = new XElement(SharedConstants.VirtualOrderings); foreach (var element in classData[SharedConstants.VirtualOrdering].Values.ToArray().Select(virtualOrderingBytes => Utilities.CreateFromBytes(virtualOrderingBytes))) { CmObjectNestingService.NestObject( false, element, classData, guidToClassMapping); rootElement.Add(element); } FileWriterService.WriteNestedFile(Path.Combine(generalBaseDir, SharedConstants.FLExVirtualOrderingFilename), rootElement); } // Yippee!! Write LP here. :-) [LanguageProject.langproj; new ext] CmObjectNestingService.NestObject(false, langProjElement, classData, guidToClassMapping); FileWriterService.WriteNestedFile(Path.Combine(generalBaseDir, SharedConstants.LanguageProjectFilename), new XElement(SharedConstants.LanguageProject, langProjElement)); }