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 .
44// Created by: Denis Krjuchkov
55// Created: 2013.09.06
66
@@ -16,39 +16,47 @@ namespace Xtensive.Orm.Validation
1616 public abstract class PropertyValidator : Attribute , IPropertyValidator
1717 {
1818 private bool isImmediate ;
19+ private bool validateOnlyIfModified ;
1920 private bool skipOnTransactionCommiting ;
2021
2122 /// <summary>
2223 /// Gets or sets value indicating if current validator is immediate.
2324 /// </summary>
2425 public bool IsImmediate
2526 {
26- get { return isImmediate ; }
27- set
28- {
29- if ( Domain != null )
27+ get => isImmediate ;
28+ set {
29+ if ( Domain != null ) {
3030 throw Exceptions . AlreadyInitialized ( null ) ;
31-
31+ }
3232 isImmediate = value ;
3333 }
3434 }
3535
3636 /// <summary>
3737 /// Gets or sets value indicating wheteher validation should continue only if field value has changed.
3838 /// </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+ }
4049
4150 /// <summary>
4251 /// Gets or sets value indicating if current validator should be skipped on a transaction commit.
4352 /// </summary>
4453 public bool SkipOnTransactionCommit
4554 {
46- get { return skipOnTransactionCommiting ; }
47- set
48- {
49- if ( Domain != null )
55+ get => skipOnTransactionCommiting ;
56+ set {
57+ if ( Domain != null ) {
5058 throw Exceptions . AlreadyInitialized ( null ) ;
51-
59+ }
5260 skipOnTransactionCommiting = value ;
5361 }
5462 }
@@ -86,8 +94,9 @@ public ConstrainMode Mode
8694 /// <param name="field">A persitent field this validator is bound to.</param>
8795 public virtual void Configure ( Domain domain , TypeInfo type , FieldInfo field )
8896 {
89- if ( Domain != null )
97+ if ( Domain != null ) {
9098 throw Exceptions . AlreadyInitialized ( null ) ;
99+ }
91100
92101 Domain = domain ;
93102 Type = type ;
@@ -150,7 +159,7 @@ protected void ThrowConfigurationError(string message, Exception innerException
150159 Strings . ExValidatorXConfigurationFailedOnTypeYFieldZWithMessageA ,
151160 GetType ( ) . Name , Type , Field , message ) ;
152161
153- var exception = innerException == null
162+ var exception = innerException == null
154163 ? new DomainBuilderException ( exceptionMessage )
155164 : new DomainBuilderException ( message , innerException ) ;
156165
0 commit comments