Fixing an issue with output parameters that are of type IntPtr
[castle.git] / Components / Binder / Castle.Components.Binder / DataBindError.cs
blob13d6ebec0f6b43231d75f237c16c925ae1bc3aa0
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.Components.Binder
17 using System;
19 /// <summary>
20 /// Represents an error that occurred when trying to
21 /// databind a property of an instance.
22 /// </summary>
23 [Serializable]
24 public class DataBindError
26 private readonly string parent, property, errorMessage;
28 /// <summary>
29 /// Initializes a new instance of the <see cref="DataBindError"/> class.
30 /// </summary>
31 /// <param name="parent">The parent.</param>
32 /// <param name="property">The property.</param>
33 public DataBindError(String parent, String property) : this(parent, property, "")
37 /// <summary>
38 /// Initializes a new instance of the <see cref="DataBindError"/> class.
39 /// </summary>
40 /// <param name="parent">The parent.</param>
41 /// <param name="property">The property.</param>
42 /// <param name="exception">The exception.</param>
43 public DataBindError(String parent, String property, Exception exception) : this(parent, property, exception.Message)
47 /// <summary>
48 /// Initializes a new instance of the <see cref="DataBindError"/> class.
49 /// </summary>
50 /// <param name="parent">The parent.</param>
51 /// <param name="property">The property.</param>
52 /// <param name="errorMessage">The error message.</param>
53 public DataBindError(String parent, String property, String errorMessage)
55 this.parent = parent;
56 this.property = property;
57 this.errorMessage = errorMessage;
60 /// <summary>
61 /// Gets the key.
62 /// </summary>
63 /// <value>The key.</value>
64 public String Key
66 get { return parent + "." + Property; }
69 /// <summary>
70 /// Gets the parent.
71 /// </summary>
72 /// <value>The parent.</value>
73 public String Parent
75 get { return parent; }
78 /// <summary>
79 /// Gets the property.
80 /// </summary>
81 /// <value>The property.</value>
82 public String Property
84 get { return property; }
87 /// <summary>
88 /// Gets the error message.
89 /// </summary>
90 /// <value>The error message.</value>
91 public String ErrorMessage
93 get { return errorMessage; }
96 /// <summary>
97 /// Returns a <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>.
98 /// </summary>
99 /// <returns>
100 /// A <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>.
101 /// </returns>
102 public override String ToString()
104 if (errorMessage != null && errorMessage != String.Empty)
106 return errorMessage;
109 return "BindError." + Key;