MimeKit.ParserOptions.RegisterMimeType C# (CSharp) Method

RegisterMimeType() public method

Registers the MimeEntity subclass for the specified mime-type.
Your custom MimeEntity class should not subclass MimeEntity directly, but rather it should subclass Multipart, MimePart, MessagePart, or one of their derivatives.
/// is null. /// -or- /// is null. /// /// is not a subclass of , /// , or . /// -or- /// does not have a constructor that takes /// only a argument. ///
public RegisterMimeType ( string mimeType, Type type ) : void
mimeType string The MIME type.
type System.Type A custom subclass of .
return void
		public void RegisterMimeType (string mimeType, Type type)
		{
			if (mimeType == null)
				throw new ArgumentNullException ("mimeType");

			if (type == null)
				throw new ArgumentNullException ("type");

			mimeType = mimeType.ToLowerInvariant ();

#if PORTABLE || COREFX
			var info = type.GetTypeInfo ();
#else
			var info = type;
#endif

			if (!info.IsSubclassOf (typeof (MessagePart)) &&
				!info.IsSubclassOf (typeof (Multipart)) &&
				!info.IsSubclassOf (typeof (MimePart)))
				throw new ArgumentException ("The specified type must be a subclass of MessagePart, Multipart, or MimePart.", "type");

#if PORTABLE
			var ctor = GetConstructor (info, ConstructorArgTypes);
#else
			var ctor = type.GetConstructor (ConstructorArgTypes);
#endif

			if (ctor == null)
				throw new ArgumentException ("The specified type must have a constructor that takes a MimeEntityConstructorArgs argument.", "type");

			mimeTypes[mimeType] = ctor;
		}