Example #1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var token = JToken.Load(reader);

            if (token.Type == JTokenType.Integer)
            {
                return(GoCDJobRunInstanceCountConstants.RunOnInstances(token.Value <int>()));
            }

            if (token.Type == JTokenType.String)
            {
                if (token.Value <string>().ToString().Equals("all", StringComparison.OrdinalIgnoreCase))
                {
                    return(GoCDJobRunInstanceCountConstants.RunOnAllAgents);
                }
            }

            return(GoCDJobRunInstanceCountConstants.RunOnOneInstance);
        }
Example #2
0
 internal void WhenIAskForRunOnInstances(int instances)
 {
     this.goCDJobRunInstanceCount = GoCDJobRunInstanceCountConstants.RunOnInstances(instances);
 }