- wcpiercepracticesenterpriselibrary.zip
- Binaries
- Microsoft.Practices.EnterpriseLibrary.Common.dll
- Microsoft.Practices.EnterpriseLibrary.Configuration.Design.dll
- Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.Design.dll
- Microsoft.Practices.EnterpriseLibrary.Logging.dll
- Microsoft.Practices.ObjectBuilder.dll
- XihSolutions.DotMSN.dll
- CodeProject.msbuild
- Logging.MsnMessenger.Configuration.Design
- Logging.MsnMessenger.Console
- Logging.MsnMessenger
- WCPierce.Practices.EnterpriseLibrary.sln
|
//===============================================================================
// Microsoft patterns & practices Enterprise Library
// Logging and Instrumentation Application Block
//===============================================================================
// Copyright � 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
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing.Design;
using Microsoft.Practices.EnterpriseLibrary.Configuration.Design;
using Microsoft.Practices.EnterpriseLibrary.Configuration.Design.Validation;
using Microsoft.Practices.EnterpriseLibrary.Logging.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.Design.Formatters;
using Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.Design.TraceListeners;
using WCPierce.Practices.EnterpriseLibrary.Logging.MsnMessenger.Configuration;
using WCPierce.Practices.EnterpriseLibrary.Logging.MsnMessenger.Configuration.Design.Properties;
namespace WCPierce.Practices.EnterpriseLibrary.Logging.MsnMessenger.Configuration.Design
{
/// <summary>
/// Represents a <see cref="FormattedDatabaseTraceListenerData"/> configuraiton element.
/// </summary>
public sealed class LoggingMsnMessengerNode : TraceListenerNode
{
string _sSenderAccount;
string _sSenderPassword;
string _sReceiverAccounts;
int _iConnectionRetryInterval;
int _iInvitationRetryInterval;
int _iMaxMessageQueue;
string _sFormatterName;
private FormatterNode _formatterNode;
/// <summary>
/// Initialize a new instance of the <see cref="LoggingDatabaseNode"/> class.
/// </summary>
public LoggingMsnMessengerNode()
: this(new FormattedMsnMessengerTraceListenerData())
{
}
/// <summary>
/// Initialize a new instance of the <see cref="LoggingDatabaseNode"/> class with a <see cref="FormattedDatabaseTraceListenerData"/> instance.
/// </summary>
/// <param name="traceListenerData">A <see cref="FormattedDatabaseTraceListenerData"/> instance</param>
public LoggingMsnMessengerNode(FormattedMsnMessengerTraceListenerData traceListenerData)
{
if (null == traceListenerData) throw new ArgumentNullException("traceListenerData");
Rename(traceListenerData.Name);
TraceOutputOptions = traceListenerData.TraceOutputOptions;
_sSenderAccount = traceListenerData.SenderAccount;
_sSenderPassword = traceListenerData.SenderPassword;
_sReceiverAccounts = traceListenerData.ReceiverAccounts;
_iConnectionRetryInterval = traceListenerData.ConnectionRetryInterval;
_iInvitationRetryInterval = traceListenerData.InvitationRetryInterval;
_iMaxMessageQueue = traceListenerData.MaxMessageQueue;
_sFormatterName = traceListenerData.Formatter;
}
/// <summary>
/// The account used to send Log messages
/// </summary>
[Required]
[SRDescription("SenderAccount", typeof(Resources))]
[SRCategory("CategoryGeneral", typeof(Resources))]
public string SenderAccount
{
get { return _sSenderAccount; }
set { _sSenderAccount = value; }
}
/// <summary>
/// The password for sSenderAccount
/// </summary>
[Required]
[SRDescription("SenderPassword", typeof(Resources))]
[SRCategory("CategoryGeneral", typeof(Resources))]
public string SenderPassword
{
get { return _sSenderPassword; }
set { _sSenderPassword = value; }
}
/// <summary>
/// A semi-colon (;) delimited list of accounts that will receive Log messages
/// </summary>
[Required]
[SRDescription("ReceiverAccounts", typeof(Resources))]
[SRCategory("CategoryGeneral", typeof(Resources))]
public string ReceiverAccounts
{
get { return _sReceiverAccounts; }
set { _sReceiverAccounts = value; }
}
/// <summary>
/// (Optional) The time in Minutes between Connection attempts. DefaultValue = 5 Minutes
/// </summary>
[SRDescription("ConnectionRetryInterval", typeof(Resources))]
[SRCategory("CategoryGeneral", typeof(Resources))]
public int ConnectionRetryInterval
{
get { return _iConnectionRetryInterval; }
set { _iConnectionRetryInterval = value; }
}
/// <summary>
/// (Optional) The time in Minutes between Invitation attempts. DefaultValue = 5 Minutes
/// </summary>
[SRDescription("InvitationRetryInterval", typeof(Resources))]
[SRCategory("CategoryGeneral", typeof(Resources))]
public int InvitationRetryInterval
{
get { return _iInvitationRetryInterval; }
set { _iInvitationRetryInterval = value; }
}
/// <summary>
/// (Optional) The maximum number of messages to queue for delivery. If this value is
/// exceeded, the oldest message is removed from the queue before adding the latest message.
/// DefaultValue = 5 Messages
/// </summary>
[SRDescription("MaxMessageQueue", typeof(Resources))]
[SRCategory("CategoryGeneral", typeof(Resources))]
public int MaxMessageQueue
{
get { return _iMaxMessageQueue; }
set { _iMaxMessageQueue = value; }
}
/// <summary>
/// Gets or sets the formatter to use.
/// </summary>
/// <value>
/// The formatter to use.
/// </value>
[Editor(typeof(ReferenceEditor), typeof(UITypeEditor))]
[ReferenceType(typeof(FormatterNode))]
[SRDescription("FormatDescription", typeof(Resources))]
[SRCategory("CategoryGeneral", typeof(Resources))]
public FormatterNode Formatter
{
get { return _formatterNode; }
set
{
_formatterNode = LinkNodeHelper.CreateReference<FormatterNode>(
_formatterNode,
value,
OnFormatterNodeRemoved,
OnFormatterNodeRenamed);
_sFormatterName = _formatterNode == null ? string.Empty : _formatterNode.Name;
}
}
/// <summary>
/// Gets the <see cref="FormattedDatabaseTraceListenerData"/> this node represents.
/// </summary>
/// <value>
/// The <see cref="FormattedDatabaseTraceListenerData"/> this node represents.
/// </value>
public override TraceListenerData TraceListenerData
{
get
{
return new FormattedMsnMessengerTraceListenerData(
Name,
_sSenderAccount,
_sSenderPassword,
_sReceiverAccounts,
_iConnectionRetryInterval,
_iInvitationRetryInterval,
_iMaxMessageQueue,
_sFormatterName);
}
}
/// <summary>
/// Sets the formatter to use for this listener.
/// </summary>
/// <param name="formatterNodeReference">
/// A <see cref="FormatterNode"/> reference or <see langword="null"/> if no formatter is defined.
/// </param>
protected override void SetFormatterReference(ConfigurationNode formatterNodeReference)
{
if (_sFormatterName == formatterNodeReference.Name) Formatter = (FormatterNode)formatterNodeReference;
}
private void OnFormatterNodeRemoved(object sender, ConfigurationNodeChangedEventArgs e)
{
_sFormatterName = null;
}
private void OnFormatterNodeRenamed(object sender, ConfigurationNodeChangedEventArgs e)
{
_sFormatterName = e.Node.Name;
}
}
}
|
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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.