/// <summary>
        /// Initializes various settings based on configuration.
        /// </summary>
        private void Initialize()
        {
            // Load the signing algorithm.
            try
            {
                this.algorithm = (DkimAlgorithmKind)Enum.Parse(
                    typeof(DkimAlgorithmKind),
                    Properties.Settings.Default.Algorithm,
                    true);
            }
            catch (Exception ex)
            {
                throw new ConfigurationErrorsException(
                          Resources.DkimSigningRoutingAgentFactory_BadAlgorithmConfig,
                          ex);
            }

            // Load the list of headers to sign in each message.
            var unparsedHeaders = Properties.Settings.Default.HeadersToSign;

            if (unparsedHeaders != null)
            {
                this.headersToSign = unparsedHeaders
                                     .Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            }

            try
            {
                XmlDocument xmlDoc = new XmlDocument();                    //* create an xml document object.
                xmlDoc.Load(this.GetType().Assembly.Location + ".config"); //* load the XML document from the specified file.
                XmlNodeList domainInfoList = xmlDoc.GetElementsByTagName("domainInfo");
                if (domainInfoList == null || domainInfoList.Count != 1)
                {
                    Logger.LogError("There is an error in your configuration file. domainInfo couldn't be initialized properly.");
                    return;
                }
                XmlNode domainInfo = domainInfoList.Item(0);

                domainSettings = new List <DomainElement>();

                foreach (XmlNode n in domainInfo.ChildNodes)
                {
                    DomainElement e = new DomainElement();
                    e.Domain         = n.Attributes["Domain"].Value;
                    e.Selector       = n.Attributes["Selector"].Value;
                    e.PrivateKeyFile = n.Attributes["PrivateKeyFile"].Value;
                    if (e.initElement(Path.GetDirectoryName(this.GetType().Assembly.Location)))
                    {
                        domainSettings.Add(e);
                    }
                }
                if (domainSettings.Count == 0)
                {
                    Logger.LogWarning("No domain configuration found. DKIM will do nothing.");
                }
            }
            catch (Exception e)
            {
                Logger.LogError("Couldn't load config: " + e.ToString());
            }
            Logger.LogInformation("Exchange DKIM started. Algorithm: " + algorithm.ToString() + " Number of domains: " + domainSettings.Count);
        }