1
- // Copyright (C) 2013 Xtensive LLC.
2
- // All rights reserved .
3
- // For conditions of distribution and use, see license .
1
+ // Copyright (C) 2013-2021 Xtensive LLC.
2
+ // This code is distributed under MIT license terms .
3
+ // See the License.txt file in the project root for more information .
4
4
// Created by: Denis Krjuchkov
5
5
// Created: 2013.09.06
6
6
@@ -16,39 +16,47 @@ namespace Xtensive.Orm.Validation
16
16
public abstract class PropertyValidator : Attribute , IPropertyValidator
17
17
{
18
18
private bool isImmediate ;
19
+ private bool validateOnlyIfModified ;
19
20
private bool skipOnTransactionCommiting ;
20
21
21
22
/// <summary>
22
23
/// Gets or sets value indicating if current validator is immediate.
23
24
/// </summary>
24
25
public bool IsImmediate
25
26
{
26
- get { return isImmediate ; }
27
- set
28
- {
29
- if ( Domain != null )
27
+ get => isImmediate ;
28
+ set {
29
+ if ( Domain != null ) {
30
30
throw Exceptions . AlreadyInitialized ( null ) ;
31
-
31
+ }
32
32
isImmediate = value ;
33
33
}
34
34
}
35
35
36
36
/// <summary>
37
37
/// Gets or sets value indicating wheteher validation should continue only if field value has changed.
38
38
/// </summary>
39
- public bool ValidateOnlyIfModified { get ; set ; }
39
+ public bool ValidateOnlyIfModified
40
+ {
41
+ get => validateOnlyIfModified ;
42
+ set {
43
+ if ( Domain != null ) {
44
+ throw Exceptions . AlreadyInitialized ( null ) ;
45
+ }
46
+ validateOnlyIfModified = value ;
47
+ }
48
+ }
40
49
41
50
/// <summary>
42
51
/// Gets or sets value indicating if current validator should be skipped on a transaction commit.
43
52
/// </summary>
44
53
public bool SkipOnTransactionCommit
45
54
{
46
- get { return skipOnTransactionCommiting ; }
47
- set
48
- {
49
- if ( Domain != null )
55
+ get => skipOnTransactionCommiting ;
56
+ set {
57
+ if ( Domain != null ) {
50
58
throw Exceptions . AlreadyInitialized ( null ) ;
51
-
59
+ }
52
60
skipOnTransactionCommiting = value ;
53
61
}
54
62
}
@@ -86,8 +94,9 @@ public ConstrainMode Mode
86
94
/// <param name="field">A persitent field this validator is bound to.</param>
87
95
public virtual void Configure ( Domain domain , TypeInfo type , FieldInfo field )
88
96
{
89
- if ( Domain != null )
97
+ if ( Domain != null ) {
90
98
throw Exceptions . AlreadyInitialized ( null ) ;
99
+ }
91
100
92
101
Domain = domain ;
93
102
Type = type ;
@@ -150,7 +159,7 @@ protected void ThrowConfigurationError(string message, Exception innerException
150
159
Strings . ExValidatorXConfigurationFailedOnTypeYFieldZWithMessageA ,
151
160
GetType ( ) . Name , Type , Field , message ) ;
152
161
153
- var exception = innerException == null
162
+ var exception = innerException == null
154
163
? new DomainBuilderException ( exceptionMessage )
155
164
: new DomainBuilderException ( message , innerException ) ;
156
165
0 commit comments