예제 #1
0
        private AircraftListJsonBuilderFilter JsonToCoordPair(GetAircraftListFilter jsonFilter, AircraftListJsonBuilderFilter result, Action<AircraftListJsonBuilderFilter, Pair<Coordinate>> assignPair)
        {
            if(jsonFilter.North != null && jsonFilter.South != null && jsonFilter.West != null && jsonFilter.East != null) {
                if(result == null) {
                    result = new AircraftListJsonBuilderFilter();
                }

                result.PositionWithin = new Pair<Coordinate>(
                    new Coordinate(jsonFilter.North.Value, jsonFilter.West.Value),
                    new Coordinate(jsonFilter.South.Value, jsonFilter.East.Value)
                );
            }

            return result;
        }
예제 #2
0
        private AircraftListJsonBuilderFilter JsonToIntRangeFilter(GetAircraftListFilter jsonFilter, AircraftListJsonBuilderFilter result, Action<AircraftListJsonBuilderFilter, FilterRange<int>> assignFilter)
        {
            switch(jsonFilter.Condition) {
                case FilterCondition.Missing:
                case FilterCondition.Between:
                    DoAssignFilter(ref result, assignFilter, new FilterRange<int>() {
                        Condition =         FilterCondition.Between,
                        LowerValue =        (int?)jsonFilter.From,
                        UpperValue =        (int?)jsonFilter.To,
                        ReverseCondition =  jsonFilter.Not,
                    });
                    break;
            }

            return result;
        }
예제 #3
0
        private AircraftListJsonBuilderFilter JsonToStringFilter(GetAircraftListFilter jsonFilter, AircraftListJsonBuilderFilter result, Action<AircraftListJsonBuilderFilter, FilterString> assignFilter)
        {
            switch(jsonFilter.Condition) {
                case FilterCondition.Contains:
                case FilterCondition.EndsWith:
                case FilterCondition.Equals:
                case FilterCondition.StartsWith:
                    DoAssignFilter(ref result, assignFilter, new FilterString() {
                        Condition =         jsonFilter.Condition,
                        Value =             jsonFilter.Value ?? "",
                        ReverseCondition =  jsonFilter.Not,
                    });
                    break;
            }

            return result;
        }
예제 #4
0
        private AircraftListJsonBuilderFilter JsonToBoolFilter(GetAircraftListFilter jsonFilter, AircraftListJsonBuilderFilter result, Action<AircraftListJsonBuilderFilter, FilterBool> assignFilter)
        {
            switch(jsonFilter.Condition) {
                case FilterCondition.Missing:
                case FilterCondition.Equals:
                    if(jsonFilter.Is != null) {
                        DoAssignFilter(ref result, assignFilter, new FilterBool() {
                            Condition =         FilterCondition.Equals,
                            Value =             jsonFilter.Is.Value,
                            ReverseCondition =  jsonFilter.Not,
                        });
                    }
                    break;
            }

            return result;
        }
예제 #5
0
        private AircraftListJsonBuilderFilter JsonToEnumFilter<T>(GetAircraftListFilter jsonFilter, AircraftListJsonBuilderFilter result, Action<AircraftListJsonBuilderFilter, FilterEnum<T>> assignFilter)
            where T: struct, IComparable
        {
            switch(jsonFilter.Condition) {
                case FilterCondition.Missing:
                case FilterCondition.Equals:
                    if(!String.IsNullOrEmpty(jsonFilter.Value) && Enum.TryParse<T>(jsonFilter.Value, out T enumValue)) {
                        if(Enum.IsDefined(typeof(T), enumValue)) {
                            DoAssignFilter(ref result, assignFilter, new FilterEnum<T>() {
                                Condition =         FilterCondition.Equals,
                                Value =             enumValue,
                                ReverseCondition =  jsonFilter.Not,
                            });
                        }
                    }
                    break;
            }

            return result;
        }