1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
20 /// Represents an error that occurred when trying to
21 /// databind a property of an instance.
24 public class DataBindError
26 private readonly string parent
, property
, errorMessage
;
29 /// Initializes a new instance of the <see cref="DataBindError"/> class.
31 /// <param name="parent">The parent.</param>
32 /// <param name="property">The property.</param>
33 public DataBindError(String parent
, String property
) : this(parent
, property
, "")
38 /// Initializes a new instance of the <see cref="DataBindError"/> class.
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
)
48 /// Initializes a new instance of the <see cref="DataBindError"/> class.
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
)
56 this.property
= property
;
57 this.errorMessage
= errorMessage
;
63 /// <value>The key.</value>
66 get { return parent + "." + Property; }
72 /// <value>The parent.</value>
75 get { return parent; }
79 /// Gets the property.
81 /// <value>The property.</value>
82 public String Property
84 get { return property; }
88 /// Gets the error message.
90 /// <value>The error message.</value>
91 public String ErrorMessage
93 get { return errorMessage; }
97 /// Returns a <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>.
100 /// A <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>.
102 public override String
ToString()
104 if (errorMessage
!= null && errorMessage
!= String
.Empty
)
109 return "BindError." + Key
;