using System; using System.Collections.Generic; using Portoa.Persistence; namespace VideoGameQuotes.Api { public abstract class CriterionHandler where T : Entity { public IEnumerable> HandleCriterion(IEnumerable values) { foreach (var value in values) { if (value is int) { yield return HandleInteger((int)value); } else { yield return HandleString((string)value); } } } protected virtual Func HandleInteger(int value) { throw new ApiException(string.Format("The value \"{0}\" is invalid", value)); } protected virtual Func HandleString(string value) { throw new ApiException(string.Format("The value \"{0}\" is invalid", value)); } } }