예제 #1
0
        internal Schema(IList <PrimitiveField> fields, IList <IObserver <NotificationContext> > observers)
        {
            _observers = new List <IDisposable>();

            _fields = new FieldList();

            ConnectObservers(observers);

            _fields.AddRange(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);
        }