Пример #1
0
        public static int count(this ICell cell, string field)
        {
            try
            {
                if (!cell.ContainsField(field))
                {
                    return(0);
                }

                object      field_obj  = cell.GetField <object>(field);
                IEnumerable enumerable = field_obj as IEnumerable;

                if (enumerable != null)
                {
                    int cnt        = 0;
                    var enumerator = enumerable.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        ++cnt;
                    }

                    return(cnt);
                }
                else
                {
                    return(1);
                }
            }
            catch { return(0); }
        }
Пример #2
0
        public static bool less_than_or_equal(this ICell cell, string field, int value)
        {
            if (!cell.ContainsField(field))
            {
                return(false);
            }

            return(cell.GetField <List <long> >(field).Any(_ => _ <= value));
        }
Пример #3
0
        public static bool less_than(this ICell cell, string field, double value)
        {
            if (!cell.ContainsField(field))
            {
                return(false);
            }

            return(cell.GetField <List <double> >(field).Any(_ => _ < value));
        }
Пример #4
0
        public static bool greater_than_or_equal(this ICell cell, string field, double value)
        {
            if (!cell.ContainsField(field))
            {
                return(false);
            }

            return(cell.GetField <List <double> >(field).Any(_ => _ >= value));
        }
Пример #5
0
        public static bool greater_than(this ICell cell, string field, int value)
        {
            if (!cell.ContainsField(field))
            {
                return(false);
            }

            return(cell.GetField <List <long> >(field).Any(_ => _ > value));
        }
Пример #6
0
        public static bool has(this ICell cell, string field, string value)
        {
            try
            {
                if (!cell.ContainsField(field))
                {
                    return(false);
                }

                object field_obj = cell.GetField <object>(field);

                if (field_obj is string)
                {
                    return(field_obj as string == value);
                }

                IEnumerable enumerable = field_obj as IEnumerable;

                if (enumerable != null)
                {
                    foreach (object element in enumerable)
                    {
                        if (element.ToString() == value)
                        {
                            return(true);
                        }
                    }

                    return(false);
                }
                else
                {
                    return(field_obj.ToString() == value);
                }
            }
            catch { }
            return(false);
        }
Пример #7
0
        public static int cell_has(IntPtr cell, string field)
        {
            ICell c = (ICell)GCHandle.FromIntPtr(cell).Target;

            return(c.ContainsField(field) ? 1 : 0);
        }
Пример #8
0
 public static bool has(this ICell cell, string field)
 {
     return(cell.ContainsField(field));
 }