AODL.Document.Export.ExportHandler.GetFirstExporter C# (CSharp) Method

GetFirstExporter() public method

Gets the first exporter that match the parameter criteria.
public GetFirstExporter ( DocumentTypes documentType, string savePath ) : IExporter
documentType DocumentTypes Type of the document.
savePath string The save path.
return IExporter
		public IExporter GetFirstExporter(DocumentTypes documentType, string savePath)
		{
			string targetExtension			= GetExtension(savePath);

			foreach(IExporter iExporter in this.LoadExporter())
			{
				foreach(DocumentSupportInfo documentSupportInfo in iExporter.DocumentSupportInfos)
					if (documentSupportInfo.Extension.ToLower().Equals(targetExtension.ToLower()))
						if (documentSupportInfo.DocumentType == documentType)
							return iExporter;
			}

			throw new AODLException("No exporter available for type "+documentType.ToString()+" and extension "+targetExtension);
		}

Usage Example

Example #1
1
		/// <summary>
		/// Save the TextDocument as OpenDocument textdocument.
		/// </summary>
		/// <param name="filename">The filename. With or without full path. Without will save the file to application path!</param>
		public void SaveTo(string filename)
		{
			try
			{
				//Build document first
				foreach(string font in this.FontList)
					this.AddFont(font);
				this.CreateContentBody();

				//Call the ExportHandler for the first matching IExporter
				ExportHandler exportHandler		= new ExportHandler();
				IExporter iExporter				= exportHandler.GetFirstExporter(
					DocumentTypes.TextDocument, filename);
				iExporter.Export(this, filename);
			}
			catch(Exception)
			{
				throw;
			}
		}
All Usage Examples Of AODL.Document.Export.ExportHandler::GetFirstExporter