protected override RollingUpgradePolicyDescription PopulateInstanceUsingJObject(JObject jObject, RollingUpgradePolicyDescription targetObject, JsonSerializer serializer) { // This is required property in json. RollingUpgradeMode jRollingUpgradeMode = jObject["RollingUpgradeMode"].ToObject <RollingUpgradeMode>(); switch (jRollingUpgradeMode) { case RollingUpgradeMode.Monitored: return(jObject.ToObject <MonitoredRollingUpgradePolicyDescription>(serializer)); case RollingUpgradeMode.UnmonitoredAuto: return(PopulateInstanceUsingJObjectInner(jObject, jRollingUpgradeMode, serializer)); case RollingUpgradeMode.UnmonitoredManual: return(PopulateInstanceUsingJObjectInner(jObject, jRollingUpgradeMode, serializer)); default: throw new FabricSerializationException(string.Format("RollingUpgradePolicyDescriptionJsonConverter: PopulateInstanceUsingJObject(): Invalid RollingUpgradeMode: {0}.", jRollingUpgradeMode)); } }
private RollingUpgradePolicyDescription PopulateInstanceUsingJObjectInner(JObject jObject, RollingUpgradeMode jRollingUpgradeMode, JsonSerializer serializer) { RollingUpgradePolicyDescription targetObject = new RollingUpgradePolicyDescription(); targetObject.UpgradeMode = jRollingUpgradeMode; targetObject.ForceRestart = jObject["ForceRestart"].ToObject <bool>(); //UpgradeReplicaSetCheckTimeoutInSeconds int upgradeReplicaSetCheckTimeoutInSeconds = jObject["UpgradeReplicaSetCheckTimeoutInSeconds"].ToObject <int>(); targetObject.UpgradeReplicaSetCheckTimeout = TimeSpan.FromSeconds(upgradeReplicaSetCheckTimeoutInSeconds); return(targetObject); }