File: IniException.cs

package info (click to toggle)
nini 1.1.0%2Bdfsg.3-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 880 kB
  • sloc: cs: 7,649; xml: 2,945; makefile: 28; ansic: 7
file content (121 lines) | stat: -rw-r--r-- 3,357 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#region Copyright
//
// Nini Configuration Project.
// Copyright (C) 2006 Brent R. Matzelle.  All rights reserved.
//
// This software is published under the terms of the MIT X11 license, a copy of 
// which has been included with this distribution in the LICENSE.txt file.
// 
#endregion

using System;
using System.Security;
using System.Globalization;
using System.Security.Permissions;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;


namespace Nini.Ini
{
	/// <include file='IniException.xml' path='//Class[@name="IniException"]/docs/*' />
#if (NET_COMPACT_1_0)
#else
	[Serializable]
#endif
	public class IniException : SystemException /*, ISerializable */
	{
		#region Private variables
		IniReader iniReader = null;
		string message = "";
		#endregion

		#region Public properties
		/// <include file='IniException.xml' path='//Property[@name="LinePosition"]/docs/*' />
		public int LinePosition
		{
			get	{
				return (iniReader == null) ? 0 : iniReader.LinePosition;
			}
		}
		
		/// <include file='IniException.xml' path='//Property[@name="LineNumber"]/docs/*' />
		public int LineNumber
		{
			get {
				return (iniReader == null) ? 0 : iniReader.LineNumber;
			}
		}
		
		/// <include file='IniException.xml' path='//Property[@name="Message"]/docs/*' />
		public override string Message
		{
			get {
				if (iniReader == null) {
					return base.Message;
				}

				return String.Format (CultureInfo.InvariantCulture, "{0} - Line: {1}, Position: {2}.",
										message, this.LineNumber, this.LinePosition);
			}
		}
		#endregion

		#region Constructors
		/// <include file='IniException.xml' path='//Constructor[@name="Constructor"]/docs/*' />
		public IniException ()
			: base ()
		{
			this.message  = "An error has occurred";
		}
		
		/// <include file='IniException.xml' path='//Constructor[@name="ConstructorException"]/docs/*' />
		public IniException (string message, Exception exception)
			: base (message, exception)
		{
		}

		/// <include file='IniException.xml' path='//Constructor[@name="ConstructorMessage"]/docs/*' />
		public IniException (string message)
			: base (message)
		{
			this.message  = message;
		}
		
		/// <include file='IniException.xml' path='//Constructor[@name="ConstructorTextReader"]/docs/*' />
		internal IniException (IniReader reader, string message)
			: this (message)
		{
			iniReader = reader;
			this.message = message;
		}

#if (NET_COMPACT_1_0)
#else
		/// <include file='IniException.xml' path='//Constructor[@name="ConstructorSerialize"]/docs/*' />
		protected IniException (SerializationInfo info, StreamingContext context)
			: base (info, context)
		{
		}
#endif
		#endregion
		
		#region Public methods
#if (NET_COMPACT_1_0)
#else
		/// <include file='IniException.xml' path='//Method[@name="GetObjectData"]/docs/*' />
		[SecurityPermissionAttribute(SecurityAction.Demand,SerializationFormatter=true)]
		public override void GetObjectData (SerializationInfo info, 
											StreamingContext context)
		{
			base.GetObjectData (info, context);
			if (iniReader != null) {
				info.AddValue ("lineNumber", iniReader.LineNumber);

				info.AddValue ("linePosition", iniReader.LinePosition);
			}
		}
#endif
		#endregion
	}
}