private static void SetDeploymentProperties(PSDeploymentObject deploymentObject, DeploymentPropertiesExtended properties) { if (properties != null) { deploymentObject.Mode = properties.Mode.Value; deploymentObject.ProvisioningState = properties.ProvisioningState; deploymentObject.TemplateLink = properties.TemplateLink; deploymentObject.Timestamp = properties.Timestamp == null ? default(DateTime) : properties.Timestamp.Value; deploymentObject.CorrelationId = properties.CorrelationId; if (properties.DebugSetting != null && !string.IsNullOrEmpty(properties.DebugSetting.DetailLevel)) { deploymentObject.DeploymentDebugLogLevel = properties.DebugSetting.DetailLevel; } if (properties.Outputs != null) { Dictionary <string, DeploymentVariable> outputs = JsonConvert.DeserializeObject <Dictionary <string, DeploymentVariable> >(properties.Outputs.ToString()); deploymentObject.Outputs = outputs; } if (properties.Parameters != null) { Dictionary <string, DeploymentVariable> parameters = JsonConvert.DeserializeObject <Dictionary <string, DeploymentVariable> >(properties.Parameters.ToString()); deploymentObject.Parameters = parameters; } if (properties.TemplateLink != null) { deploymentObject.TemplateLinkString = ConstructTemplateLinkView(properties.TemplateLink); } } }
private static void SetDeploymentProperties(PSDeploymentObject deploymentObject, DeploymentPropertiesExtended properties) { if (properties != null) { deploymentObject.Mode = properties.Mode.Value; deploymentObject.ProvisioningState = properties.ProvisioningState; deploymentObject.TemplateLink = properties.TemplateLink; deploymentObject.Timestamp = properties.Timestamp == null ? default(DateTime) : properties.Timestamp.Value; deploymentObject.CorrelationId = properties.CorrelationId; if (properties.DebugSetting != null && !string.IsNullOrEmpty(properties.DebugSetting.DetailLevel)) { deploymentObject.DeploymentDebugLogLevel = properties.DebugSetting.DetailLevel; } if (properties.Outputs != null) { Dictionary <string, DeploymentVariable> outputs = JsonConvert.DeserializeObject <Dictionary <string, DeploymentVariable> >(properties.Outputs.ToString()); // Continue deserialize if the type of Value in DeploymentVariable is array outputs?.Values.ForEach(dv => { if ("Array".Equals(dv?.Type)) { dv.Value = JsonConvert.DeserializeObject <object[]>(dv.Value.ToString()); } }); deploymentObject.Outputs = outputs; } if (properties.Parameters != null) { Dictionary <string, DeploymentVariable> parameters = JsonConvert.DeserializeObject <Dictionary <string, DeploymentVariable> >(properties.Parameters.ToString()); // Continue deserialize if the type of Value in DeploymentVariable is array parameters?.Values.ForEach(dv => { if ("Array".Equals(dv?.Type)) { dv.Value = JsonConvert.DeserializeObject <object[]>(dv.Value.ToString()); } }); deploymentObject.Parameters = parameters; } if (properties.TemplateLink != null) { deploymentObject.TemplateLinkString = ConstructTemplateLinkView(properties.TemplateLink); } } }