public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            IClusterRerouteCommand command = null;
            var o     = JObject.Load(reader);
            var child = o.Children <JProperty>().FirstOrDefault();

            if (child == null)
            {
                return(null);
            }
            var v = child.Children <JObject>().FirstOrDefault();

            if (v == null)
            {
                return(null);
            }
            switch (child.Name)
            {
            case "allocate":
                command = v.ToObject <AllocateClusterRerouteCommand>(ElasticContractResolver.Empty);
                break;

            case "move":
                command = v.ToObject <MoveClusterRerouteCommand>(ElasticContractResolver.Empty);
                break;

            case "cancel":
                command = v.ToObject <CancelClusterRerouteCommand>(ElasticContractResolver.Empty);
                break;
            }
            return(command);
        }
Exemple #2
0
 private void AddCommand(IClusterRerouteCommand rerouteCommand)
 {
     rerouteCommand.ThrowIfNull("rerouteCommand");
     if (this.Self.Commands == null)
     {
         this.Self.Commands = new List <IClusterRerouteCommand>();
     }
     this.Self.Commands.Add(rerouteCommand);
 }
Exemple #3
0
 private ClusterRerouteDescriptor AddCommand(IClusterRerouteCommand rerouteCommand) => Assign(rerouteCommand, (a, v) => a.Commands?.AddIfNotNull(v));
		private ClusterRerouteDescriptor AddCommand(IClusterRerouteCommand rerouteCommand) => Assign(a => a.Commands?.AddIfNotNull(rerouteCommand));