Exemplo n.º 1
0
        // ReSharper disable LocalizableElement
        public static ViewSpec ReadXml(XmlReader reader)
        {
            var viewSpec = new ViewSpec
            {
                Name        = reader.GetAttribute("name"),
                RowSource   = reader.GetAttribute("rowsource"),
                SublistName = reader.GetAttribute("sublist"),
                UiMode      = reader.GetAttribute("uimode") ?? string.Empty
            };
            var columns = new List <ColumnSpec>();
            var filters = new List <FilterSpec>();

            if (reader.IsEmptyElement)
            {
                reader.ReadElementString("view");
                return(viewSpec);
            }
            reader.Read();
            while (true)
            {
                if (reader.IsStartElement("column"))
                {
                    columns.Add(ColumnSpec.ReadXml(reader));
                }
                else if (reader.IsStartElement("filter"))
                {
                    filters.Add(FilterSpec.ReadXml(reader));
                }
                else if (reader.NodeType == XmlNodeType.EndElement)
                {
                    reader.ReadEndElement();
                    break;
                }
                else
                {
                    reader.Skip();
                }
            }
            viewSpec.Columns = ImmutableList.ValueOf(columns);
            viewSpec.Filters = ImmutableList.ValueOf(filters);
            return(viewSpec);
        }
Exemplo n.º 2
0
        // ReSharper disable NonLocalizedString
        public static ViewSpec ReadXml(XmlReader reader)
        {
            var viewSpec = new ViewSpec
            {
                Name        = reader.GetAttribute("name"),
                RowSource   = reader.GetAttribute("rowsource"),
                SublistName = reader.GetAttribute("sublist")
            };
            var columns = new List <ColumnSpec>();
            var filters = new List <FilterSpec>();

            if (reader.IsEmptyElement)
            {
                reader.ReadElementString("view");
                return(viewSpec);
            }
            reader.Read();
            while (true)
            {
                if (reader.IsStartElement("column"))
                {
                    columns.Add(ColumnSpec.ReadXml(reader));
                }
                else if (reader.IsStartElement("filter"))
                {
                    filters.Add(FilterSpec.ReadXml(reader));
                }
                else if (reader.NodeType == XmlNodeType.EndElement)
                {
                    reader.ReadEndElement();
                    break;
                }
                else
                {
                    reader.Read();
                }
            }
            viewSpec.Columns = Array.AsReadOnly(columns.ToArray());
            viewSpec.Filters = Array.AsReadOnly(filters.ToArray());
            return(viewSpec);
        }
Exemplo n.º 3
0
        public static ViewSpec ReadXml(XmlReader reader)
        {
            var viewSpec = new ViewSpec();

            viewSpec.Name        = reader.GetAttribute("name");
            viewSpec.SublistName = reader.GetAttribute("sublist");
            var columns = new List <ColumnSpec>();
            var sorts   = new List <SortSpec>();

            if (reader.IsEmptyElement)
            {
                reader.ReadElementString("view");
                return(viewSpec);
            }
            reader.Read();
            while (true)
            {
                if (reader.IsStartElement("column"))
                {
                    columns.Add(ColumnSpec.ReadXml(reader));
                }
                else if (reader.IsStartElement("sort"))
                {
                    sorts.Add(SortSpec.ReadXml(reader));
                }
                else if (reader.NodeType == XmlNodeType.EndElement)
                {
                    reader.ReadEndElement();
                    break;
                }
                else
                {
                    reader.Read();
                }
            }
            viewSpec.Sorts   = new ReadOnlyCollection <SortSpec>(sorts.ToArray());
            viewSpec.Columns = new ReadOnlyCollection <ColumnSpec>(columns.ToArray());
            return(viewSpec);
        }