/// <summary> /// Exports a single data-class. /// </summary> /// <param name="cmdLine"></param> private void ExportOneClass(ExportCommandLine cmdLine) { IXmlDataImex imex = ImexUtils.FindImexForDataClass(cmdLine.DataClass); int itemsPerFile = cmdLine.ItemsPerFile > 0 ? cmdLine.ItemsPerFile : ImexUtils.GetDefaultItemsPerFile(imex.GetType()); string directory; string baseFileName; // if the path has no extension, assume it specifies a directory if (string.IsNullOrEmpty(Path.GetExtension(cmdLine.Path))) { // use the name of the dataclass as a base filename directory = cmdLine.Path; baseFileName = cmdLine.DataClass; } else { // use the specified file name as the base filename directory = Path.GetDirectoryName(cmdLine.Path); baseFileName = Path.GetFileNameWithoutExtension(cmdLine.Path); } ImexUtils.Export(imex, directory, baseFileName, itemsPerFile); }
/// <summary> /// Exports all data-classes for which an Imex extension exists. /// </summary> /// <param name="cmdLine"></param> private void ExportAllClasses(ExportCommandLine cmdLine) { string path = cmdLine.Path; // assume the supplied path is a directory, and create it if it doesn't exist if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } foreach (IXmlDataImex imex in new XmlDataImexExtensionPoint().CreateExtensions()) { ImexDataClassAttribute a = AttributeUtils.GetAttribute <ImexDataClassAttribute>(imex.GetType()); if (a != null) { ImexUtils.Export(imex, Path.Combine(path, a.DataClass), a.DataClass, a.ItemsPerFile); } } }