3
3
4
4
#nullable disable
5
5
6
- using System ;
7
6
using System . Collections . Generic ;
8
7
using System . ComponentModel ;
8
+ using System . Runtime . CompilerServices ;
9
9
using Azure . Core ;
10
10
using Azure . ResourceManager . Network . Models ;
11
11
using Azure . ResourceManager . Resources . Models ;
@@ -14,17 +14,20 @@ namespace Azure.ResourceManager.Network
14
14
{
15
15
public partial class LoadBalancingRuleData : NetworkResourceData
16
16
{
17
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
18
+ private void EnsureProperties ( )
19
+ {
20
+ Properties ??= new LoadBalancingRuleProperties ( default , default ) ;
21
+ }
22
+
17
23
/// <summary> Gets or sets Id. </summary>
18
24
[ EditorBrowsable ( EditorBrowsableState . Never ) ]
19
25
public ResourceIdentifier FrontendIPConfigurationId
20
26
{
21
27
get => Properties ? . FrontendIPConfigurationId ;
22
28
set
23
29
{
24
- if ( Properties is null )
25
- {
26
- Properties = new LoadBalancingRuleProperties ( ) ;
27
- }
30
+ EnsureProperties ( ) ;
28
31
Properties . FrontendIPConfigurationId = value ;
29
32
}
30
33
}
@@ -36,17 +39,21 @@ public ResourceIdentifier BackendAddressPoolId
36
39
get => Properties ? . BackendAddressPoolId ;
37
40
set
38
41
{
39
- if ( Properties is null )
40
- {
41
- Properties = new LoadBalancingRuleProperties ( ) ;
42
- }
42
+ EnsureProperties ( ) ;
43
43
Properties . BackendAddressPoolId = value ;
44
44
}
45
45
}
46
46
47
47
/// <summary> An array of references to pool of DIPs. </summary>
48
48
[ EditorBrowsable ( EditorBrowsableState . Never ) ]
49
- public IList < WritableSubResource > BackendAddressPools => Properties ? . BackendAddressPools ;
49
+ public IList < WritableSubResource > BackendAddressPools
50
+ {
51
+ get
52
+ {
53
+ EnsureProperties ( ) ;
54
+ return Properties . BackendAddressPools ;
55
+ }
56
+ }
50
57
51
58
/// <summary> Gets or sets Id. </summary>
52
59
[ EditorBrowsable ( EditorBrowsableState . Never ) ]
@@ -55,10 +62,7 @@ public ResourceIdentifier ProbeId
55
62
get => Properties ? . ProbeId ;
56
63
set
57
64
{
58
- if ( Properties is null )
59
- {
60
- Properties = new LoadBalancingRuleProperties ( ) ;
61
- }
65
+ EnsureProperties ( ) ;
62
66
Properties . ProbeId = value ;
63
67
}
64
68
}
@@ -70,10 +74,7 @@ public LoadBalancingTransportProtocol? Protocol
70
74
get => Properties ? . Protocol ;
71
75
set
72
76
{
73
- if ( Properties is null )
74
- {
75
- Properties = new LoadBalancingRuleProperties ( ) ;
76
- }
77
+ EnsureProperties ( ) ;
77
78
Properties . Protocol = value ?? default ;
78
79
}
79
80
}
@@ -85,10 +86,7 @@ public LoadDistribution? LoadDistribution
85
86
get => Properties ? . LoadDistribution ;
86
87
set
87
88
{
88
- if ( Properties is null )
89
- {
90
- Properties = new LoadBalancingRuleProperties ( ) ;
91
- }
89
+ EnsureProperties ( ) ;
92
90
Properties . LoadDistribution = value ;
93
91
}
94
92
}
@@ -100,10 +98,7 @@ public int? FrontendPort
100
98
get => Properties ? . FrontendPort ;
101
99
set
102
100
{
103
- if ( Properties is null )
104
- {
105
- Properties = new LoadBalancingRuleProperties ( ) ;
106
- }
101
+ EnsureProperties ( ) ;
107
102
Properties . FrontendPort = value ?? default ;
108
103
}
109
104
}
@@ -115,10 +110,7 @@ public int? BackendPort
115
110
get => Properties ? . BackendPort ;
116
111
set
117
112
{
118
- if ( Properties is null )
119
- {
120
- Properties = new LoadBalancingRuleProperties ( ) ;
121
- }
113
+ EnsureProperties ( ) ;
122
114
Properties . BackendPort = value ;
123
115
}
124
116
}
@@ -130,10 +122,7 @@ public int? IdleTimeoutInMinutes
130
122
get => Properties ? . IdleTimeoutInMinutes ;
131
123
set
132
124
{
133
- if ( Properties is null )
134
- {
135
- Properties = new LoadBalancingRuleProperties ( ) ;
136
- }
125
+ EnsureProperties ( ) ;
137
126
Properties . IdleTimeoutInMinutes = value ;
138
127
}
139
128
}
@@ -145,10 +134,7 @@ public bool? EnableFloatingIP
145
134
get => Properties ? . EnableFloatingIP ;
146
135
set
147
136
{
148
- if ( Properties is null )
149
- {
150
- Properties = new LoadBalancingRuleProperties ( ) ;
151
- }
137
+ EnsureProperties ( ) ;
152
138
Properties . EnableFloatingIP = value ;
153
139
}
154
140
}
@@ -160,10 +146,7 @@ public bool? EnableTcpReset
160
146
get => Properties ? . EnableTcpReset ;
161
147
set
162
148
{
163
- if ( Properties is null )
164
- {
165
- Properties = new LoadBalancingRuleProperties ( ) ;
166
- }
149
+ EnsureProperties ( ) ;
167
150
Properties . EnableTcpReset = value ;
168
151
}
169
152
}
@@ -175,10 +158,7 @@ public bool? DisableOutboundSnat
175
158
get => Properties ? . DisableOutboundSnat ;
176
159
set
177
160
{
178
- if ( Properties is null )
179
- {
180
- Properties = new LoadBalancingRuleProperties ( ) ;
181
- }
161
+ EnsureProperties ( ) ;
182
162
Properties . DisableOutboundSnat = value ;
183
163
}
184
164
}
0 commit comments