Click here to Skip to main content
15,891,907 members
Articles / Desktop Programming / WPF

Writing Your Own RTF Converter

Rate me:
Please Sign up or sign in to vote.
4.95/5 (234 votes)
1 Aug 2013CPOL14 min read 2.5M   40.4K   632  
An article on how to write a custom RTF parser and converter.
// -- FILE ------------------------------------------------------------------
// name       : StringsBase.cs
// project    : System Framelet
// created    : Jani Giannoudis - 2009.02.19
// language   : c#
// environment: .NET 3.5
// copyright  : (c) 2004-2013 by Jani Giannoudis, Switzerland
// --------------------------------------------------------------------------
using System;
using System.Resources;

namespace Itenso.Sys
{

	// ------------------------------------------------------------------------
	/// <summary>
	/// Provides some helper functionality to keep resource handling in a
	/// namespace as simple and uniform as possible.
	/// </summary>
	/// <remarks>
	/// intended to be used by a singleton class per namespace, which should
	/// commonly be named <c>Strings</c>. This singleton instance should
	/// provide access to resources via strongly typed properties, thus
	/// avoiding coding errors with misspelled resource identifiers.
	/// </remarks>
	public abstract class StringsBase
	{

		// ----------------------------------------------------------------------
		/// <summary>
		/// Formats the given format-string with the invariant culture and the
		/// given arguments.
		/// </summary>
		/// <param name="format">the string to format</param>
		/// <param name="args">the arguments to fill in</param>
		/// <returns>the formatted string</returns>
		protected static string Format( string format, params object[] args )
		{
			return StringTool.FormatSafeInvariant( format, args );
		} // Format

		// ----------------------------------------------------------------------
		/// <summary>
		/// Creates a <c>ResourceManager</c> instance for the given type, loading its resources
		/// from the type's full name, suffixed with '<c>.resx</c>'.
		/// </summary>
		/// <param name="singletonType">the type of the singleton</param>
		/// <returns>a <c>ResourceManager</c> for loading the given type's resources</returns>
		protected static ResourceManager NewInst( Type singletonType )
		{
			if ( singletonType == null )
			{
				throw new ArgumentNullException( "singletonType" );
			}
			if ( String.IsNullOrEmpty( singletonType.FullName ) )
			{
				throw new ArgumentException( "singletonType" );
			}
			return new ResourceManager( singletonType.FullName, singletonType.Assembly );
		} // NewInst

	} // class StringsBase

} // namespace Itenso.Sys
// -- EOF -------------------------------------------------------------------

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Switzerland Switzerland
👨 Senior .NET Software Engineer

🚀 My Open Source Projects
- Time Period Library 👉 GitHub
- Payroll Engine 👉 GitHub

Feedback and contributions are welcome.



Comments and Discussions