Beispiel #1
0
        private void LoadColumns(XPathNavigator xml)
        {
            Columns.Clear();
            var columnNodes = xml.Select("/qdbapi/table/fields/field");

            foreach (XPathNavigator columnNode in columnNodes)
            {
                var columnId = int.Parse(columnNode.GetAttribute("id", String.Empty));
                var type     =
                    (FieldType)Enum.Parse(typeof(FieldType), columnNode.GetAttribute("field_type", String.Empty), true);
                var  label   = columnNode.SelectSingleNode("label").Value;
                bool hidden  = false;
                var  hidNode = columnNode.SelectSingleNode("appears_by_default");
                if (hidNode != null && hidNode.Value == "0")
                {
                    hidden = true;
                }
                bool     virt   = columnNode.GetAttribute("mode", String.Empty) == "virtual";
                bool     lookup = columnNode.GetAttribute("mode", String.Empty) == "lookup";
                IQColumn col    = ColumnFactory.CreateInstace(columnId, label, type, virt, lookup, hidden);
                foreach (XPathNavigator choicenode in columnNode.Select("choices/choice"))
                {
                    object value;
                    switch (type)
                    {
                    case FieldType.rating:
                        value = Int32.Parse(choicenode.Value);
                        break;

                    default:
                        value = choicenode.Value;
                        break;
                    }
                    ((IQColumn_int)col).AddChoice(value);
                }
                Dictionary <string, int> colComposites = ((IQColumn_int)col).GetComposites();
                foreach (XPathNavigator compositenode in columnNode.Select("compositeFields/compositeField"))
                {
                    colComposites.Add(compositenode.GetAttribute("key", String.Empty), Int32.Parse(compositenode.GetAttribute("id", String.Empty)));
                }
                Columns.Add(col);
            }
            var keyFidNode = xml.SelectSingleNode("/qdbapi/table/original/key_fid");

            if (keyFidNode != null)
            {
                KeyFID = keyFidNode.ValueAsInt;
            }
            else
            {
                KeyFID = Columns.Find(c => c.ColumnType == FieldType.recordid).ColumnId;
            }
            KeyCIdx = Columns.FindIndex(c => c.ColumnId == KeyFID);
        }
        private void LoadColumns(XPathNavigator xml)
        {
            Columns.Clear();
            var columnNodes = xml.Select("/qdbapi/table/fields/field");

            foreach (XPathNavigator columnNode in columnNodes)
            {
                var columnId = int.Parse(columnNode.GetAttribute("id", String.Empty));
                var type     =
                    (FieldType)Enum.Parse(typeof(FieldType), columnNode.GetAttribute("field_type", String.Empty), true);
                var label = columnNode.SelectSingleNode("label").Value;

                var col = ColumnFactory.CreateInstace(columnId, label, type);
                Columns.Add(col);
            }
        }