Example #1
0
        /// <summary>
        /// Initialize the appender based on the options set.
        /// </summary>
        /// <remarks>
        /// <para>
        /// This is part of the <see cref="IOptionHandler"/> delayed object
        /// activation scheme. The <see cref="ActivateOptions"/> method must
        /// be called on this object after the configuration properties have
        /// been set. Until <see cref="ActivateOptions"/> is called this
        /// object is in an undefined state and must not be used.
        /// </para>
        /// <para>
        /// If any of the configuration properties are modified then
        /// <see cref="ActivateOptions"/> must be called again.
        /// </para>
        /// <para>
        /// The appender will be ignored if no <see cref="RemoteAddress" /> was specified or
        /// an invalid remote or local TCP port number was specified.
        /// </para>
        /// </remarks>
        /// <exception cref="ArgumentNullException">The required property <see cref="RemoteAddress" /> was not specified.</exception>
        /// <exception cref="ArgumentOutOfRangeException">The TCP port number assigned to <see cref="LocalPort" /> or <see cref="RemotePort" /> is less than <see cref="IPEndPoint.MinPort" /> or greater than <see cref="IPEndPoint.MaxPort" />.</exception>
        public override void ActivateOptions()
        {
            base.ActivateOptions();

            if (RemoteAddress == null)
            {
                throw new ArgumentNullException("The required property 'Address' was not specified.");
            }
            else if (RemotePort < IPEndPoint.MinPort || RemotePort > IPEndPoint.MaxPort)
            {
                throw SystemInfo.CreateArgumentOutOfRangeException("this.RemotePort", RemotePort,
                                                                   "The RemotePort is less than " + IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
                                                                   " or greater than " + IPEndPoint.MaxPort.ToString(NumberFormatInfo.InvariantInfo) + ".");
            }
            else if (LocalPort != 0 && (LocalPort < IPEndPoint.MinPort || LocalPort > IPEndPoint.MaxPort))
            {
                throw SystemInfo.CreateArgumentOutOfRangeException("this.LocalPort", LocalPort,
                                                                   "The LocalPort is less than " + IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
                                                                   " or greater than " + IPEndPoint.MaxPort.ToString(NumberFormatInfo.InvariantInfo) + ".");
            }
            else
            {
                RemoteEndPoint = new IPEndPoint(RemoteAddress, RemotePort);
                InitializeClientConnection();
            }
        }
Example #2
0
        /// <exception cref="ArgumentOutOfRangeException">
        /// <para><paramref name="i"/> is less than zero.</para>
        /// <para>-or-</para>
        /// <para><paramref name="i"/> is equal to or greater than <see cref="PluginCollection.Count"/>.</para>
        /// </exception>
        private void ValidateIndex(int i, bool allowEqualEnd)
        {
            int max = (allowEqualEnd) ? (m_count) : (m_count - 1);

            if (i < 0 || i > max)
            {
                throw SystemInfo.CreateArgumentOutOfRangeException("i", (object)i, "Index was out of range. Must be non-negative and less than the size of the collection. [" + (object)i + "] Specified argument was out of the range of valid values.");
            }
        }
Example #3
0
        private void ValidateIndex(int i, bool allowEqualEnd)
        {
            int num = !allowEqualEnd ? (this.m_count - 1) : this.m_count;

            if ((i < 0) || (i > num))
            {
                throw SystemInfo.CreateArgumentOutOfRangeException("i", i, "Index was out of range. Must be non-negative and less than the size of the collection. [" + i + "] Specified argument was out of the range of valid values.");
            }
        }
Example #4
0
 /// <summary>
 /// Creates a new repository selector.
 /// </summary>
 /// <param name="defaultRepositoryType">The type of the repositories to create, must implement <see cref="T:log4net.Repository.ILoggerRepository" /></param>
 /// <remarks>
 /// <para>
 /// Create an new repository selector.
 /// The default type for repositories must be specified,
 /// an appropriate value would be <see cref="T:log4net.Repository.Hierarchy.Hierarchy" />.
 /// </para>
 /// </remarks>
 /// <exception cref="T:System.ArgumentNullException"><paramref name="defaultRepositoryType" /> is <see langword="null" />.</exception>
 /// <exception cref="T:System.ArgumentOutOfRangeException"><paramref name="defaultRepositoryType" /> does not implement <see cref="T:log4net.Repository.ILoggerRepository" />.</exception>
 public DefaultRepositorySelector(Type defaultRepositoryType)
 {
     if ((object)defaultRepositoryType == null)
     {
         throw new ArgumentNullException("defaultRepositoryType");
     }
     if (!CompatibilityExtensions.IsAssignableFrom(typeof(ILoggerRepository), defaultRepositoryType))
     {
         throw SystemInfo.CreateArgumentOutOfRangeException("defaultRepositoryType", defaultRepositoryType, "Parameter: defaultRepositoryType, Value: [" + defaultRepositoryType + "] out of range. Argument must implement the ILoggerRepository interface");
     }
     m_defaultRepositoryType = defaultRepositoryType;
     LogLog.Debug(declaringType, "defaultRepositoryType [" + m_defaultRepositoryType + "]");
 }
Example #5
0
 public override void ActivateOptions()
 {
     base.ActivateOptions();
     if (this.RemoteAddress == null)
     {
         throw new ArgumentNullException("The required property 'Address' was not specified.");
     }
     if (this.RemotePort < 0 || this.RemotePort > (int)ushort.MaxValue)
     {
         throw SystemInfo.CreateArgumentOutOfRangeException("this.RemotePort", (object)this.RemotePort, "The RemotePort is less than " + 0.ToString((IFormatProvider)NumberFormatInfo.InvariantInfo) + " or greater than " + ((int)ushort.MaxValue).ToString((IFormatProvider)NumberFormatInfo.InvariantInfo) + ".");
     }
     this.RemoteEndPoint = new IPEndPoint(IPAddress.Parse(this.RemoteAddress), this.RemotePort);
     this.InitializeClientConnection();
 }
Example #6
0
        public CyclicBuffer(int maxSize)
        {
            if (maxSize < 1)
            {
                throw SystemInfo.CreateArgumentOutOfRangeException("maxSize", (object)maxSize, "Parameter: maxSize, Value: [" + maxSize + "] out of range. Non zero positive integer required");
            }

            m_maxSize = maxSize;
            m_events  = new LoggingEvent[maxSize];

            m_first    = 0;
            m_last     = 0;
            m_numElems = 0;
        }
Example #7
0
 /// <summary>
 /// Create a new Level and add it to the map
 /// </summary>
 /// <param name="name">the string to display for the Level</param>
 /// <param name="value">the level value to give to the Level</param>
 /// <param name="displayName">the display name to give to the Level</param>
 /// <remarks>
 /// <para>
 /// Create a new Level and add it to the map
 /// </para>
 /// </remarks>
 public void Add(string name, int value, string displayName)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     if (name.Length == 0)
     {
         throw SystemInfo.CreateArgumentOutOfRangeException("name", name, "Parameter: name, Value: [" + name + "] out of range. Level name must not be empty");
     }
     if (displayName == null || displayName.Length == 0)
     {
         displayName = name;
     }
     Add(new Level(value, name, displayName));
 }
Example #8
0
        public override void ActivateOptions()
        {
            base.ActivateOptions();

            if (RemotePort < IPEndPoint.MinPort || RemotePort > IPEndPoint.MaxPort)
            {
                throw SystemInfo.CreateArgumentOutOfRangeException("value", RemotePort,
                                                                   string.Format("The value specified is less than {0} or greater than {1}.",
                                                                                 IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo), IPEndPoint.MaxPort.ToString(NumberFormatInfo.InvariantInfo)));
            }

            if (RemoteAddress == null)
            {
                throw new ArgumentException("Remote address of the location must be specified.");
            }
        }
Example #9
0
        public DefaultRepositorySelector(Type defaultRepositoryType)
        {
            if (defaultRepositoryType == null)
            {
                throw new ArgumentNullException("defaultRepositoryType");
            }

            // Check that the type is a repository
            if (!(typeof(ILoggerRepository).IsAssignableFrom(defaultRepositoryType)))
            {
                throw SystemInfo.CreateArgumentOutOfRangeException("defaultRepositoryType", defaultRepositoryType, "Parameter: defaultRepositoryType, Value: [" + defaultRepositoryType + "] out of range. Argument must implement the ILoggerRepository interface");
            }

            m_defaultRepositoryType = defaultRepositoryType;

            LogLog.Debug(declaringType, "defaultRepositoryType [" + m_defaultRepositoryType + "]");
        }
        public override void ActivateOptions()
        {
            base.ActivateOptions();

            if (RemoteAddress == null)
            {
                throw new Exception("Remote address of the location must be specified.");
            }

            if (RemotePort < IPEndPoint.MinPort || RemotePort > IPEndPoint.MaxPort)
            {
                throw SystemInfo.CreateArgumentOutOfRangeException("value", RemotePort,
                                                                   string.Format("The value specified is less than {0} or greater than {1}.",
                                                                                 IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo), IPEndPoint.MaxPort.ToString(NumberFormatInfo.InvariantInfo)));
            }

            Client = new TcpClient();
            try { Client.Connect(RemoteAddress, RemotePort); }
            catch (Exception ex) { ErrorHandler.Error("Could not initialize the TcpClient.", ex, ErrorCode.GenericFailure); }
        }
Example #11
0
 public override void ActivateOptions()
 {
     base.ActivateOptions();
     if (this.RemoteAddress == null)
     {
         throw new ArgumentNullException("The required property 'Address' was not specified.");
     }
     if ((this.RemotePort < 0) || (this.RemotePort > 0xffff))
     {
         string[] textArray1 = new string[] { "The RemotePort is less than ", 0.ToString(NumberFormatInfo.InvariantInfo), " or greater than ", 0xffff.ToString(NumberFormatInfo.InvariantInfo), "." };
         throw SystemInfo.CreateArgumentOutOfRangeException("this.RemotePort", this.RemotePort, string.Concat(textArray1));
     }
     if ((this.LocalPort == 0) || ((this.LocalPort >= 0) && (this.LocalPort <= 0xffff)))
     {
         this.RemoteEndPoint = new IPEndPoint(this.RemoteAddress, this.RemotePort);
         this.InitializeClientConnection();
     }
     else
     {
         string[] textArray2 = new string[] { "The LocalPort is less than ", 0.ToString(NumberFormatInfo.InvariantInfo), " or greater than ", 0xffff.ToString(NumberFormatInfo.InvariantInfo), "." };
         throw SystemInfo.CreateArgumentOutOfRangeException("this.LocalPort", this.LocalPort, string.Concat(textArray2));
     }
 }
Example #12
0
 public override void ActivateOptions()
 {
     base.ActivateOptions();
     if (this.LocalPort == -1)
     {
         return;
     }
     if (this.LocalPort == 0)
     {
         throw SystemInfo.CreateArgumentOutOfRangeException("this.LocalPort", this.LocalPort, "The LocalPort is zero.");
     }
     if (this.LocalPort != 0 && (this.LocalPort < 0 || this.LocalPort > 65535))
     {
         object   localPort = this.LocalPort;
         string[] str       = new string[] { "The LocalPort is less than ", null, null, null, null };
         str[1] = 0.ToString(NumberFormatInfo.InvariantInfo);
         str[2] = " or greater than ";
         str[3] = 65535.ToString(NumberFormatInfo.InvariantInfo);
         str[4] = ".";
         throw SystemInfo.CreateArgumentOutOfRangeException("this.LocalPort", localPort, string.Concat(str));
     }
     this._heartbeat = this.Encoding.GetBytes("\n\r");
     this.InitializeClientConnection();
 }