annotate Source/TypeBuilder/PropertyChangedAttribute.cs @ 9:1e85f66cf767 default tip

update bltoolkit
author nickolay
date Thu, 05 Apr 2018 20:53:26 +0300
parents f990fcb411a9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
1 using System;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
2 using BLToolkit.Common;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
3 using BLToolkit.TypeBuilder.Builders;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
4
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
5 namespace BLToolkit.TypeBuilder
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
6 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
7 /// <summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
8 /// This attribute allows to control generation of PropertyChanged notification at class level
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
9 /// </summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
10 [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class)]
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
11 public sealed class PropertyChangedAttribute : AbstractTypeBuilderAttribute
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
12 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
13 /// <summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
14 /// Specifies default generation options should be used for PropertyChanged notification
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
15 /// </summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
16 public PropertyChangedAttribute()
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
17 :this(Common.Configuration.NotifyOnEqualSet)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
18 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
19 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
20
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
21 /// <summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
22 /// This constructor allows control of PropertyChanged code generation
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
23 /// </summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
24 /// <param name="notifyOnEqualSet">See <see cref="NotifyOnEqualSet"/></param>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
25 public PropertyChangedAttribute(bool notifyOnEqualSet)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
26 :this(notifyOnEqualSet, true)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
27 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
28 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
29
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
30 /// <summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
31 /// This constructor allows control of PropertyChanged code generation
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
32 /// </summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
33 /// <param name="notifyOnEqualSet">See <see cref="NotifyOnEqualSet"/></param>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
34 /// <param name="useReferenceEquals">See <see cref="UseReferenceEquals"/></param>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
35 public PropertyChangedAttribute(bool notifyOnEqualSet, bool useReferenceEquals)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
36 :this(notifyOnEqualSet, useReferenceEquals, true)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
37 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
38 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
39
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
40 /// <summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
41 /// This constructor allows control of PropertyChanged code generation
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
42 /// </summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
43 /// <param name="notifyOnEqualSet">See <see cref="NotifyOnEqualSet"/></param>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
44 /// <param name="useReferenceEquals">See <see cref="UseReferenceEquals"/></param>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
45 /// <param name="skipSetterOnNoChange">See <see cref="SkipSetterOnNoChange"/></param>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
46 public PropertyChangedAttribute(bool notifyOnEqualSet, bool useReferenceEquals, bool skipSetterOnNoChange)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
47 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
48 _notifyOnEqualSet = notifyOnEqualSet;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
49 _useReferenceEquals = useReferenceEquals;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
50 _skipSetterOnNoChange = skipSetterOnNoChange;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
51 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
52
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
53 private bool _notifyOnEqualSet;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
54 /// <summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
55 /// Controls whether OnPropertyChanged notifications are sent when current value is same as new one.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
56 ///
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
57 /// Default value controlled via <see cref="Configuration.NotifyOnEqualSet"/> and by default is set to false
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
58 /// </summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
59 public bool NotifyOnEqualSet
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
60 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
61 get { return _notifyOnEqualSet; }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
62 set { _notifyOnEqualSet = value; }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
63 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
64
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
65 private bool _useReferenceEquals;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
66 /// <summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
67 /// Specifies if <see cref="Object.ReferenceEquals">Object.ReferenceEquals</see> should be used for equality comparison of current and new value
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
68 /// for reference types. If value type implements op_Inequality, UseReferenceEquals is ignored.
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
69 /// </summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
70 public bool UseReferenceEquals
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
71 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
72 get { return _useReferenceEquals; }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
73 set { _useReferenceEquals = value; }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
74 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
75
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
76 private bool _skipSetterOnNoChange;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
77 /// <summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
78 /// Specifies whether call to setter is made when current value is same as new one
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
79 /// </summary>
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
80 public bool SkipSetterOnNoChange
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
81 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
82 get { return _skipSetterOnNoChange; }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
83 set { _skipSetterOnNoChange = value; }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
84 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
85
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
86 public override IAbstractTypeBuilder TypeBuilder
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
87 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
88 get { return new PropertyChangedBuilder(_notifyOnEqualSet, _useReferenceEquals, _skipSetterOnNoChange); }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
89 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
90 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
91 }