//=============================================================================== // Microsoft Exception Management Application Block for .NET // http://msdn.microsoft.com/library/en-us/dnbda/html/emab-rm.asp // // ExceptionManagerExceptions.cs // This file contains the CustomPublisherException class, which it created when // a publisher throws an exception to the ExceptionManager class. // // For more information see the Implementation of the CustomPublisherException // Class section of the Exception Management Application Block Implementation Overview. //=============================================================================== // Copyright (C) 2000-2001 Microsoft Corporation // All rights reserved. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT // LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR // FITNESS FOR A PARTICULAR PURPOSE. //=============================================================================== using System; using System.Runtime.Serialization; using System.Security.Permissions; namespace AyAEM.ExceptionManagement { /// /// Summary description for ExceptionManagerExceptions. /// [Serializable] public class CustomPublisherException : BaseApplicationException { #region Constructors /// /// Constructor with no params. /// public CustomPublisherException() : base() { } /// /// Constructor allowing the Message property to be set. /// /// String setting the message of the exception. public CustomPublisherException(string message) : base(message) { } /// /// Constructor allowing the Message and InnerException property to be set. /// /// String setting the message of the exception. /// Sets a reference to the InnerException. public CustomPublisherException(string message,Exception inner) : base(message, inner) { } /// /// Constructor allowing the message, assembly name, type name, and publisher format to be set. /// /// String setting the message of the exception. /// String setting the assembly name of the exception. /// String setting the type name of the exception. /// String setting the publisher format of the exception. public CustomPublisherException(string message, string assemblyName, string typeName, PublisherFormat publisherFormat) : base(message) { this.assemblyName = assemblyName; this.typeName = typeName; this.publisherFormat = publisherFormat; } /// /// Constructor allowing the Message and InnerException property to be set. /// /// String setting the message of the exception. /// String setting the assembly name of the exception. /// String setting the type name of the exception. /// String setting the publisher format of the exception. /// Sets a reference to the InnerException. public CustomPublisherException(string message, string assemblyName, string typeName, PublisherFormat publisherFormat, Exception inner) : base(message, inner) { this.assemblyName = assemblyName; this.typeName = typeName; this.publisherFormat = publisherFormat; } /// /// Constructor used for deserialization of the exception class. /// /// Represents the SerializationInfo of the exception. /// Represents the context information of the exception. protected CustomPublisherException(SerializationInfo info, StreamingContext context) : base(info, context) { assemblyName = info.GetString("assemblyName"); typeName = info.GetString("typeName"); publisherFormat = (PublisherFormat)info.GetValue("publisherFormat",typeof(PublisherFormat)); } #endregion // Member variable declarations private string assemblyName; private string typeName; private PublisherFormat publisherFormat; /// /// Override the GetObjectData method to serialize custom values. /// /// Represents the SerializationInfo of the exception. /// Represents the context information of the exception. [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] public override void GetObjectData( SerializationInfo info, StreamingContext context ) { info.AddValue("assemblyName", assemblyName, typeof(string)); info.AddValue("typeName", typeName, typeof(string)); info.AddValue("publisherFormat", publisherFormat, typeof(PublisherFormat)); base.GetObjectData(info,context); } #region Public Properties /// /// The exception format configured for the publisher that threw an exception. /// public PublisherFormat PublisherFormat { get { return publisherFormat; } } /// /// The Assembly name of the publisher that threw an exception. /// public string PublisherAssemblyName { get { return assemblyName; } } /// /// The Type name of the publisher that threw an exception. /// public string PublisherTypeName { get { return typeName; } } #endregion } }