예제 #1
0
        public void Set(Schema schema, string columnId, string value)
        {
            int        id    = schema.IndexOf(columnId);
            FieldDescr field = schema.Fields[id];

            Columns[id] = field.ParseValue(value);
        }
예제 #2
0
        public Schema(string name, string schemaXml)
        {
            Name = name;
            using (XmlReader reader = XmlReader.Create(schemaXml, new XmlReaderSettings()
            {
                DtdProcessing = DtdProcessing.Parse,
            }))
            {
                var doc = new XmlDocument();
                doc.Load(reader);

                XmlNode root = doc.LastChild;
                Debug.Assert(root.Name == "root");

                int     index = 0;
                XmlNode field = root.FirstChild;

                var fields = new List <FieldDescr>();
                while ((field = field?.NextSibling) != null)
                {
                    fields.Add(new FieldDescr(index, field));
                    ++index;
                }

                // @note Some performance optimizations here.
                Fields    = fields.ToArray();
                Unordered = new Dictionary <string, FieldDescr>(Fields.Length);

                for (int i = 0; i < Fields.Length; ++i)
                {
                    FieldDescr descr = Fields[i];
                    Unordered.Add(descr.Name, descr);
                }
            }
        }
예제 #3
0
        public DataRow(Schema schema)
        {
            int length = schema.Fields.Length;

            Columns = new object[length];

            for (int i = 0; i < length; ++i)
            {
                FieldDescr field = schema.Fields[i];
                Columns[i] = field.DefaultValue;
            }
        }