Esempio n. 1
0
        /// <summary>
        /// Does search in array of flights based on search values
        /// </summary>
        /// <param name="searchValues">Array of fields and their values</param>
        /// <returns>Array of flights found</returns>
        public Flight[] Find(string[] searchValues)
        {
            var flights        = new Flight[_flights.Length];
            var indexOfFlights = 0;

            try
            {
                if (!string.IsNullOrWhiteSpace(searchValues[fieldNameIndex]))
                {
                    foreach (Flight flight in _flights)
                    {
                        if (flight != null)
                        {
                            var flightPropertyVal            = flight[searchValues[fieldNameIndex]];
                            ConditionalTypes conditionalType = (ConditionalTypes)Enum.Parse(typeof(ConditionalTypes), searchValues[fieldConditionIndex]);

                            if (Search(conditionalType, searchValues[fieldValueIndex], flightPropertyVal))
                            {
                                flights[indexOfFlights] = flight;
                                indexOfFlights++;
                            }
                        }
                    }
                }
            }
            catch { }

            return(flights.Where(arg => arg != null).ToArray());
        }
        /// <summary>
        /// Does search in array of airline object based on search values
        /// </summary>
        /// <param name="FieldsValues">Array of fields and their values</param>
        /// <returns>Array of airline objects found</returns>
        public virtual bool Find(string[] FieldsValues)
        {
            //var objects = new IAirlineManager[CurrentAirlineObjects.Length];
            //Array.Clear(CurrentAirlineObjects, 0, CurrentAirlineObjects.Count);
            var FieldsValuesSearch = GetAirlineObjectInfo(FieldsValues);

            try
            {
                if (FieldsValuesSearch.Length > 0 && !string.IsNullOrWhiteSpace(FieldsValuesSearch[0][fieldNameIndex]) && Properties.Contains(FieldsValuesSearch[0][fieldNameIndex]))
                {
                    foreach (AirlineObject airlineObject in AirlineObjects)
                    {
                        if (airlineObject != null)
                        {
                            var airlineObjectPropertyVal     = airlineObject[FieldsValuesSearch[0][fieldNameIndex]];
                            ConditionalTypes conditionalType = (ConditionalTypes)Enum.Parse(typeof(ConditionalTypes), FieldsValuesSearch[0][fieldConditionIndex]);

                            if (Search(conditionalType, FieldsValuesSearch[0][fieldValueIndex], airlineObjectPropertyVal))
                            {
                                CurrentAirlineObjects.Add(airlineObject);
                            }
                        }
                    }
                }
            }
            catch { }

            return(CurrentAirlineObjects.Count(arg => arg != null) > 0);
        }
Esempio n. 3
0
        /// <summary>
        /// Does search in flight itself based on field name and it's value
        /// </summary>
        /// <param name="conditionalType">type of comparsion</param>
        /// <param name="searchValue">value for search</param>
        /// <param name="compareValue">original value</param>
        /// <returns>Positive if found</returns>
        private bool Search(ConditionalTypes conditionalType, object searchValue, object compareValue)
        {
            switch (Type.GetTypeCode(compareValue.GetType()))
            {
            case TypeCode.Int32:
            {
                switch (conditionalType)
                {
                case ConditionalTypes.eq:
                    return((int)searchValue == (int)compareValue);

                case ConditionalTypes.gt:
                    return((int)searchValue > (int)compareValue);

                case ConditionalTypes.lt:
                    return((int)searchValue < (int)compareValue);
                }
            }
            break;

            case TypeCode.String:
            {
                switch (conditionalType)
                {
                case ConditionalTypes.eq:
                    return(string.Compare((string)searchValue, (string)compareValue, false) == 0);

                case ConditionalTypes.gt:
                    return(string.Compare((string)searchValue, (string)compareValue, false) < 0);

                case ConditionalTypes.lt:
                    return(string.Compare((string)searchValue, (string)compareValue, false) > 0);
                }
            }
            break;

            case TypeCode.DateTime:
            {
                switch (conditionalType)
                {
                case ConditionalTypes.eq:
                    return(DateTime.Compare(Convert.ToDateTime(searchValue), (DateTime)compareValue) == 0);

                case ConditionalTypes.gt:
                    return(DateTime.Compare(Convert.ToDateTime(searchValue), (DateTime)compareValue) > 0);

                case ConditionalTypes.lt:
                    return(DateTime.Compare(Convert.ToDateTime(searchValue), (DateTime)compareValue) < 0);
                }
            }
            break;
            }
            return(false);
        }
Esempio n. 4
0
 public static Boolean IsSingleConditionConstruct(this ConditionalTypes type)
 {
     return(type.IsConditionConstruct() && type != ConditionalTypes.ObjectLoop && type != ConditionalTypes.LoopEx);
 }
Esempio n. 5
0
 /// <summary>
 /// Whether it's not an else.
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public static Boolean IsConditionConstruct(this ConditionalTypes type)
 {
     return(type <= ConditionalTypes.MultiConditional);
 }
Esempio n. 6
0
 public static Boolean IsFlowable(this ConditionalTypes type, Boolean noMulti)
 {
     return(type == ConditionalTypes.Loop || type == ConditionalTypes.LoopEx || type == ConditionalTypes.ObjectLoop ||
            (!noMulti && type == ConditionalTypes.MultiConditional));
 }
Esempio n. 7
0
 public static Boolean IsConditionalStatement(this ConditionalTypes type)
 {
     return(type < ConditionalTypes.Converse);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="fieldName"></param>
 /// <param name="fieldValue"></param>
 public DateFilterQuery(string fieldName, ConditionalTypes condition, DateTime fieldValue)
 {
     ParameterName = fieldName;
     FieldValue    = fieldValue;
     Condition     = condition;
 }
Esempio n. 9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="fieldName"></param>
 /// <param name="conditionalType"></param>
 /// <param name="fieldValue"></param>
 public FilterQuery(string fieldName, ConditionalTypes conditionalType, object fieldValue)
 {
     ParameterName = fieldName;
     FieldValue    = fieldValue;
     Condition     = conditionalType;
 }
Esempio n. 10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="fieldName"></param>
 /// <param name="fieldValue"></param>
 public FilterQuery(string fieldName, object fieldValue)
 {
     ParameterName = fieldName;
     FieldValue    = fieldValue;
     Condition     = ConditionalTypes.Equals;
 }