root/trunk/AprSharp/dev/src/AprArgumentOutOfRangeException.cs

Revision 59, 4.1 kB (checked in by DenisG, 4 years ago)

[AprSharp] Cosmetic. License region.

  • Property svn:eol-style set to native
Line 
1 //  AprSharp, a wrapper library around the Apache Portable Runtime Library
2 #region Copyright (C) 2004 SOFTEC sa.
3 //
4 //  This library is free software; you can redistribute it and/or
5 //  modify it under the terms of the GNU Lesser General Public
6 //  License as published by the Free Software Foundation; either
7 //  version 2.1 of the License, or (at your option) any later version.
8 //
9 //  This library is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 //  Lesser General Public License for more details.
13 //
14 //  You should have received a copy of the GNU Lesser General Public
15 //  License along with this library; if not, write to the Free Software
16 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 //
18 //  Sources, support options and lastest version of the complete library
19 //  is available from:
20 //              http://www.softec.st/AprSharp
21 //             
22 //
23 //  Initial authors :
24 //              Denis Gervalle
25 //              Olivier Desaive
26 #endregion
27 //
28 using System;
29 using System.Runtime.Serialization;
30
31 namespace Softec.AprSharp
32 {
33     [Serializable]
34     public class AprArgumentOutOfRangeException : AprArgumentException
35     {
36         const int Result = unchecked ((int)0xA0651502);
37
38         private object mActualValue;
39        
40         public AprArgumentOutOfRangeException()
41                : base ( "Argument is out of range." )
42         {
43             HResult = Result;
44             mActualValue = null;
45         }
46
47         public AprArgumentOutOfRangeException(string paramName)
48                : base ( "Argument is out of range.", paramName )
49         {
50             HResult = Result;
51             mActualValue = null;
52         }
53
54         public AprArgumentOutOfRangeException(string paramName, string message)
55                : base ( message, paramName )
56         {
57             HResult = Result;
58             mActualValue = null;
59         }
60
61         public AprArgumentOutOfRangeException(string paramName,
62                                               object actualValue,
63                                               string message)
64                : base ( message, paramName )
65         {
66             mActualValue = actualValue;
67             HResult = Result;
68         }
69
70         public AprArgumentOutOfRangeException(string paramName, int apr_status)
71                : base ( apr_status, paramName )
72         {
73             mActualValue = null;
74         }
75
76         public AprArgumentOutOfRangeException(string paramName,
77                                               object actualValue,
78                                               int apr_status)
79                : base ( apr_status, paramName )
80         {
81             mActualValue = actualValue;
82         }
83
84         public AprArgumentOutOfRangeException(string paramName,
85                                               int actualValue,
86                                               int minval, int maxval)
87                : base ( "Expect an integer value between " + minval
88                                                  + " and " + maxval + ".",
89                         paramName )
90         {
91             mActualValue = (object)actualValue;
92         }
93
94         public AprArgumentOutOfRangeException(SerializationInfo info, StreamingContext context)
95                : base (info, context)
96         {
97             mActualValue = info.GetString("ActualValue");
98         }
99        
100         public virtual object ActualValue
101         {
102             get
103             {
104                 return mActualValue;
105             }
106         }
107        
108         public override string Message
109         {
110             get
111             {
112                 string baseMessage = base.Message;
113                 if(mActualValue == null)
114                     return baseMessage;
115                
116                 return( baseMessage + Environment.NewLine + mActualValue );
117             }
118         }
119
120         public override void GetObjectData(SerializationInfo info, StreamingContext context)
121         {
122             base.GetObjectData(info,context);
123             info.AddValue("ActualValue", mActualValue);
124         }                 
125     }
126 }
Note: See TracBrowser for help on using the browser.