Skip to content

Instantly share code, notes, and snippets.

@mrtank
Created August 19, 2020 11:47
Show Gist options
  • Save mrtank/79628643b1511ddf444103e5a9febbd2 to your computer and use it in GitHub Desktop.
Save mrtank/79628643b1511ddf444103e5a9febbd2 to your computer and use it in GitHub Desktop.
class BindableBase {}
class ValidationRule<T>// where T : BindableBase
{}
class RuleCollection<VM> where VM : BindableBase
{
public RuleCollection<VM> AddRule<T>(VM _, Expression<Func<VM, object>> expression, params ValidationRule<T>[] rules)
{ return this; }
}
public class ValidationService
{
private BindableBase bindableBase;
private RuleCollection<BindableBase> ruleCollection;
internal RuleCollection<VM> For<VM>(VM bindableBase) where VM : BindableBase
{
this.bindableBase = bindableBase;
var a = new RuleCollection<VM>();
ruleCollection = (RuleCollection<BindableBase>)a;
return a;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment