1
1
using System ;
2
2
using System . Runtime . Serialization ;
3
+ using System . Security ;
3
4
4
5
namespace NHibernate
5
6
{
6
7
[ Serializable ]
7
8
public class DuplicateMappingException : MappingException
8
9
{
9
- private readonly string type ;
10
- private readonly string name ;
11
-
12
- /// <summary>
13
- /// The type of the duplicated object
14
- /// </summary>
15
- public string Type
16
- {
17
- get { return type ; }
18
- }
19
-
20
- /// <summary>
21
- /// The name of the duplicated object
22
- /// </summary>
23
- public string Name
24
- {
25
- get { return name ; }
26
- }
27
10
28
11
/// <summary>
29
12
/// Initializes a new instance of the <see cref="MappingException"/> class.
@@ -34,8 +17,8 @@ public string Name
34
17
public DuplicateMappingException ( string customMessage , string type , string name )
35
18
: base ( customMessage )
36
19
{
37
- this . type = type ;
38
- this . name = name ;
20
+ Type = type ;
21
+ Name = name ;
39
22
}
40
23
41
24
/// <summary>
@@ -44,7 +27,7 @@ public DuplicateMappingException(string customMessage, string type, string name)
44
27
/// <param name="name">The name of the duplicate object</param>
45
28
/// <param name="type">The type of the duplicate object</param>
46
29
public DuplicateMappingException ( string type , string name )
47
- : this ( string . Format ( "Duplicate {0 } mapping {1}" , type , name ) , type , name )
30
+ : this ( $ "Duplicate { type } mapping { name } " , type , name )
48
31
{
49
32
}
50
33
@@ -62,6 +45,35 @@ public DuplicateMappingException(string type, string name)
62
45
public DuplicateMappingException ( SerializationInfo info , StreamingContext context )
63
46
: base ( info , context )
64
47
{
48
+ foreach ( var entry in info )
49
+ {
50
+ if ( entry . Name == "Type" )
51
+ {
52
+ Type = entry . Value ? . ToString ( ) ;
53
+ }
54
+ else if ( entry . Name == "Name" )
55
+ {
56
+ Name = entry . Value ? . ToString ( ) ;
57
+ }
58
+ }
65
59
}
60
+
61
+ [ SecurityCritical ]
62
+ public override void GetObjectData ( SerializationInfo info , StreamingContext context )
63
+ {
64
+ base . GetObjectData ( info , context ) ;
65
+ info . AddValue ( "Type" , Type ) ;
66
+ info . AddValue ( "Name" , Name ) ;
67
+ }
68
+
69
+ /// <summary>
70
+ /// The type of the duplicated object
71
+ /// </summary>
72
+ public string Type { get ; }
73
+
74
+ /// <summary>
75
+ /// The name of the duplicated object
76
+ /// </summary>
77
+ public string Name { get ; }
66
78
}
67
- }
79
+ }
0 commit comments