示例#1
0
        public IReadOnlyFieldList RemoveAll <T>(Func <T, bool> criteria)
            where T : PrimitiveField
        {
            var fields = new FieldList();

            for (int i = 0; i < _fields.Count; i++)
            {
                T field = _fields[i].Cast <T>();
                if (!criteria(field))
                {
                    continue;
                }

                fields.Add(_fields.Remove(i));
                i = 0;
            }

            return(fields);
        }
示例#2
0
        /// <summary>
        /// Iterates through a list of fields and returns a flattened list of fields.
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentException"></exception>
        public static IReadOnlyFieldList SelectMany(this IReadOnlyFieldList source)
        {
            var fields = new FieldList(false);

            for (int i = 0; i < source.Count; i++)
            {
                switch (source[i])
                {
                case StructField field:
                    fields.Add(field);
                    for (int j = 0; j < field.Fields.Count; j++)
                    {
                        fields.Add(field.Fields[j]);
                    }
                    break;

                case ListField field:
                    fields.AddRange(field);
                    break;

                case MapField field:
                    fields.AddRange(field);
                    break;

                case DecimalField field:
                    fields.AddRange(field);
                    break;

                case DateTimeField field:
                    fields.AddRange(field);
                    break;

                case PrimitiveField field:
                    fields.AddRange(field);
                    break;

                default:
                    throw new ArgumentException();
                }
            }

            return(fields);
        }