Click or drag to resize

ConfigFileParser Class

A helper class to read a Configuration File and parse its sections into the proper collections
Inheritance Hierarchy
SystemObject
  SMTPRouter.Windows.ConfigurationConfigFileParser

Namespace:  SMTPRouter.Windows.Configuration
Assembly:  SMTPRouter.Windows (in SMTPRouter.Windows.dll) Version: 1.0.0.3 (1.0.0.3)
Syntax
public sealed class ConfigFileParser

The ConfigFileParser type exposes the following members.

Constructors
  NameDescription
Public methodConfigFileParser
Initializes a new instance of the ConfigFileParser
Public methodConfigFileParser(Configuration)
Initializes a new instance of the ConfigFileParser
Top
Properties
  NameDescription
Public propertyConfig
The Configuration element
Public propertyMessageLifespan
The time a message is considered valid to retry. By default it is 15 minutes.
Public propertyMessagePurgeLifespan
The time a message is considered not purgeable. By default it is 90 days.
Public propertyQueuePath
A string to store the queue path
Public propertyRoutingRules
Public propertySmtpConnections
Public propertySmtpHost
A SmtpConfiguration representing the Server SMTP Configuration
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks
The configuration file must respect a schema in order to be parsed properly by this class.
Examples
The example below demonstrates a valid App.Config file:
<configSections>
  <section name="SmtpRouterConfiguration"
            type="SMTPRouter.Windows.Configuration.NameValueSection, SMTPRouter.Windows"/>
  <section name="SmtpConfiguration"
            type="SMTPRouter.Windows.Configuration.SmtpConnectionsSection, SMTPRouter.Windows"/>
  <section name="RoutingRulesConfiguration"
            type="SMTPRouter.Windows.Configuration.RoutingRulesSection, SMTPRouter.Windows"/>
</configSections>

<!-- Configuration for the Current SMTP Server -->
<SmtpRouterConfiguration>
  <add name="Host" value="localhost"/>
  <add name="Port" value="25"/>
  <add name="MessageLifespanMinutes" value="15"/>
  <add name="MessagePurgeLifespanDays" value="90"/>
</SmtpRouterConfiguration>

<!-- Destination SMTPs -->
<SmtpConfiguration>
  <SmtpConnections>
    <add key="gmail"
          description="Gmail SMTP Server"
          host="smtp.gmail.com"
          port="587"
          requiresAuthentication="true"
          user="user"
          password="pwd"/>
    <add key="hotmail"
          description="Hotmail SMTP Server"
          host="smtp.live.com"
          port="587"
          requiresAuthentication="true"
          user="user"
          password="pwd"/>
  </SmtpConnections>
</SmtpConfiguration>

<RoutingRulesConfiguration>
  <RoutingRules>
    <add executionSequence="10"
         type="SMTPRouter.Models.MailFromDomainRoutingRule, SMTPRouter"
         params="Domain=gmail.com"
         smtpkey="gmail" />
    <add executionSequence="20"
         type="SMTPRouter.Models.MailFromDomainRoutingRule, SMTPRouter"
         params="Domain=hotmail.com;"
         smtpkey="hotmail" />
    <add executionSequence="30"
         type="SMTPRouter.Models.MailFromRegexMatchRoutingRule, SMTPRouter"
         params="RegexExpression=\A[Uu](\d{5})\z"
         smtpkey="hotmail" />
  </RoutingRules>
</RoutingRulesConfiguration>
See Also