vgquotes/Src/VideoGameQuotes.Api/CriterionHandler.cs
tmont 14ca315213 * dto madness
* api madness
* browse page is beginning to not be empty
* NetVotes -> Score
2011-02-16 02:48:11 +00:00

25 lines
765 B
C#

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