예제 #1
0
        public Predicate <T> BuildFilter <T>(FactDate when, Func <FactDate, T, FactLocation> location)
        {
            Predicate <T> locationFilter = FilterUtils.TrueFilter <T>();

            string country(FactLocation x) => x.Country;

            if (Scotland)
            {
                locationFilter = FilterUtils.LocationFilter <T>(when, location, country, Countries.SCOTLAND);
            }
            else if (England)
            {
                locationFilter = FilterUtils.LocationFilter <T>(when, location, country, Countries.ENGLAND);
            }
            else if (Wales)
            {
                locationFilter = FilterUtils.LocationFilter <T>(when, location, country, Countries.WALES);
            }
            else if (UK)
            {
                locationFilter = FilterUtils.OrFilter <T>(FilterUtils.LocationFilter <T>(when, location, country, Countries.SCOTLAND),
                                                          FilterUtils.LocationFilter <T>(when, location, country, Countries.ENGLAND),
                                                          FilterUtils.LocationFilter <T>(when, location, country, Countries.WALES));
            }
            else if (Canada)
            {
                locationFilter = FilterUtils.LocationFilter <T>(when, location, country, Countries.CANADA);
            }
            else if (USA)
            {
                locationFilter = FilterUtils.LocationFilter <T>(when, location, country, Countries.UNITED_STATES);
            }
            return(locationFilter);
        }