Get() public static method

public static Get ( System.Web.HttpApplication application ) : ErrorSignal
application System.Web.HttpApplication
return ErrorSignal
Example #1
0
        /// <summary>
        /// Initializes the module and prepares it to handle requests.
        /// </summary>

        protected override void OnInit(HttpApplication application)
        {
            if (application == null)
            {
                throw new ArgumentNullException("application");
            }

            application.Error += new EventHandler(OnError);
            ErrorSignal.Get(application).Raised += new ErrorSignalEventHandler(OnErrorSignaled);
        }
Example #2
0
        /// <summary>
        /// Initializes the module and prepares it to handle requests.
        /// </summary>

        protected override void OnInit(HttpApplication application)
        {
            if (application == null)
            {
                throw new ArgumentNullException("application");
            }

            //
            // Get the configuration section of this module.
            // If it's not there then there is nothing to initialize or do.
            // In this case, the module is as good as mute.
            //

            IDictionary config = (IDictionary)GetConfig();

            if (config == null)
            {
                return;
            }

            string userName        = GetSetting(config, "userName", string.Empty);
            string password        = GetSetting(config, "password", string.Empty);
            string statusFormat    = GetSetting(config, "statusFormat", "{Message}");
            int    maxStatusLength = int.Parse(GetSetting(config, "maxStatusLength", "140"), NumberStyles.None, CultureInfo.InvariantCulture);
            string ellipsis        = GetSetting(config, "ellipsis", /* ... */ "\x2026");
            string formFormat      = GetSetting(config, "formFormat", "status={0}");
            Uri    url             = new Uri(GetSetting(config, "url", "http://twitter.com/statuses/update.xml")
#if !NET_1_1 && !NET_1_0
                                             , UriKind.Absolute
#endif
                                             );

            _credentials     = new NetworkCredential(userName, password);
            _statusFormat    = statusFormat;
            _url             = url;
            _maxStatusLength = maxStatusLength;
            _ellipsis        = ellipsis;
            _formFormat      = formFormat;
            _requests        = ArrayList.Synchronized(new ArrayList(4));

            application.Error += new EventHandler(OnError);
            ErrorSignal.Get(application).Raised += new ErrorSignalEventHandler(OnErrorSignaled);
        }
Example #3
0
        /// <summary>
        /// Initializes the module and prepares it to handle requests.
        /// </summary>

        protected override void OnInit(HttpApplication application)
        {
            if (application == null)
            {
                throw new ArgumentNullException("application");
            }

            //
            // Get the configuration section of this module.
            // If it's not there then there is nothing to initialize or do.
            // In this case, the module is as good as mute.
            //

            IDictionary config = (IDictionary)GetConfig();

            if (config == null)
            {
                return;
            }

            //
            // Extract the settings.
            //

            string       mailRecipient        = GetSetting(config, "to");
            string       mailSender           = GetSetting(config, "from", mailRecipient);
            string       mailCopyRecipient    = GetSetting(config, "cc", string.Empty);
            string       mailSubjectFormat    = GetSetting(config, "subject", string.Empty);
            MailPriority mailPriority         = (MailPriority)Enum.Parse(typeof(MailPriority), GetSetting(config, "priority", MailPriority.Normal.ToString()), true);
            bool         reportAsynchronously = Convert.ToBoolean(GetSetting(config, "async", bool.TrueString));
            string       smtpServer           = GetSetting(config, "smtpServer", string.Empty);
            int          smtpPort             = Convert.ToUInt16(GetSetting(config, "smtpPort", "0"), CultureInfo.InvariantCulture);
            string       authUserName         = GetSetting(config, "userName", string.Empty);
            string       authPassword         = GetSetting(config, "password", string.Empty);
            bool         sendYsod             = Convert.ToBoolean(GetSetting(config, "noYsod", bool.FalseString));

#if !NET_1_0 && !NET_1_1
            bool useSsl = Convert.ToBoolean(GetSetting(config, "useSsl", bool.FalseString));
#endif
            //
            // Hook into the Error event of the application.
            //

            application.Error += new EventHandler(OnError);
            ErrorSignal.Get(application).Raised += new ErrorSignalEventHandler(OnErrorSignaled);

            //
            // Finally, commit the state of the module if we got this far.
            // Anything beyond this point should not cause an exception.
            //

            _mailRecipient        = mailRecipient;
            _mailSender           = mailSender;
            _mailCopyRecipient    = mailCopyRecipient;
            _mailSubjectFormat    = mailSubjectFormat;
            _mailPriority         = mailPriority;
            _reportAsynchronously = reportAsynchronously;
            _smtpServer           = smtpServer;
            _smtpPort             = smtpPort;
            _authUserName         = authUserName;
            _authPassword         = authPassword;
            _noYsod = sendYsod;
#if !NET_1_0 && !NET_1_1
            _useSsl = useSsl;
#endif
        }