using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace FLocal.Common.actions { class IncrementFieldValue : AbstractFieldValue { public static readonly Func INCREMENTOR = s => (int.Parse(s)+1).ToString(); public static readonly Func DECREMENTOR = s => (int.Parse(s)-1).ToString(); public static Func GREATEST(int val) { return s => { if(s == null || s == "") { return val.ToString(); } else { return Math.Max(int.Parse(s), val).ToString(); } }; } private readonly Func processor; public IncrementFieldValue(Func processor) { this.processor = processor; } public IncrementFieldValue() : this(INCREMENTOR) { } public override string getStringRepresentation() { throw new NotSupportedException(); } public override string getStringRepresentation(string oldInfo) { return this.processor(oldInfo); } } }