@@ -108,7 +108,7 @@ public class ProductConfig : Config
108108 /// process of setting the default deployment for the platforms.
109109 /// </summary>
110110 [ JsonIgnore ]
111- private bool _deploymentDefined ;
111+ private bool _deploymentDefinedWhenLoaded ;
112112
113113 /// <summary>
114114 /// Used to store information about what platform configs have been
@@ -143,8 +143,10 @@ protected ProductConfig() : base("eos_product_config.json") { }
143143
144144 protected override void OnReadCompleted ( )
145145 {
146- // This tracks whether there is a single deployment defined.
147- _deploymentDefined = Environments . IsDeploymentDefined ;
146+ // This tracks whether there is a single deployment defined. The
147+ // out parameter is discarded because it is not needed at this
148+ // juncture.
149+ _deploymentDefinedWhenLoaded = Environments . TryGetFirstDefinedNamedDeployment ( out _ ) ;
148150 }
149151
150152 // This compile conditional is here because the OnWriteCompleted method
@@ -157,26 +159,26 @@ protected override void BeforeWrite()
157159 // If there is one deployment, and one sandbox, then make sure they
158160 // are linked to each other if the sandbox is not empty.
159161 // But only do this if they have been newly added
160- if ( ! _deploymentDefined && Environments . Deployments . Count == 1 && Environments . Sandboxes . Count == 1 && ! Environments . Sandboxes [ 0 ] . Value . IsEmpty )
162+ if ( ! _deploymentDefinedWhenLoaded && Environments . Deployments . Count == 1 && Environments . Sandboxes . Count == 1 && ! Environments . Sandboxes [ 0 ] . Value . IsEmpty )
161163 {
162164 Environments . Deployments [ 0 ] . Value . SandboxId = Environments . Sandboxes [ 0 ] . Value ;
163165 }
164166 }
165167
166168 protected override void OnWriteCompleted ( )
167169 {
170+ bool definedDeploymentExists =
171+ Environments . TryGetFirstDefinedNamedDeployment ( out Named < Deployment > deploymentToSetPlatformsTo ) ;
172+
168173 // If when the config was last read there was a deployment defined,
169174 // or there is not now one defined - then there is no need to try
170175 // and set the deployment values for each platform config.
171- if ( _deploymentDefined || ! Environments . IsDeploymentDefined )
176+ if ( _deploymentDefinedWhenLoaded ||
177+ ! definedDeploymentExists )
172178 {
173179 return ;
174180 }
175181
176- // Select the first defined deployment as the deployment to set
177- // platform configs to use.
178- Named < Deployment > deploymentToSetPlatformsTo = Environments . Deployments [ 0 ] ;
179-
180182 List < PlatformManager . Platform > platformConfigsUpdated = new ( ) ;
181183
182184 // For each platform for which configuration can be done
0 commit comments