コード例 #1
0
        public static IObjectList <T> ImportFromXML <T>(System.Xml.XmlReader reader, Siaqodb siaqodb)
        {
            ObjectTable obTable = new ObjectTable();

            reader.Read();
            reader.ReadStartElement("SiaqodbObjects");
            SqoTypeInfo            ti         = siaqodb.GetSqoTypeInfo <T>();
            bool                   colFinish  = false;
            ObjectRow              currentRow = null;
            int                    index      = 0;
            Dictionary <int, Type> members    = new Dictionary <int, Type>();

            while (reader.Read())
            {
                if (reader.IsStartElement() && reader.Name == "objects")
                {
                    colFinish = true;
                }

                if (reader.IsStartElement() && !colFinish)
                {
                    reader.MoveToFirstAttribute();
                    //string type = reader.Value;
                    Type t = Type.GetType(reader.Value);
                    reader.MoveToElement();

                    reader.ReadStartElement();
                    string columnName = reader.ReadContentAsString();
                    if (columnName == "OID")
                    {
                        throw new SiaqodbException("OID is set only internally, cannot be imported");
                    }
                    obTable.Columns.Add(columnName, index);
                    if (t.IsGenericType())
                    {
                        Type genericTypeDef = t.GetGenericTypeDefinition();
                        if (genericTypeDef == typeof(Nullable <>))
                        {
                            t = t.GetGenericArguments()[0];
                        }
                    }
                    members.Add(index, t);
                    index++;
                }
                if (reader.IsStartElement() && reader.Name == "object")
                {
                    currentRow = obTable.NewRow();
                    obTable.Rows.Add(currentRow);
                    index = 0;
                }
                if (reader.IsStartElement() && reader.Name == "memberValue")
                {
                    ReadMemberValue(currentRow, reader, index, members);
                    index++;
                    while (reader.Name == "memberValue")
                    {
                        ReadMemberValue(currentRow, reader, index, members);
                        index++;
                    }
                }
            }
            return(ObjectTableHelper.CreateObjectsFromTable <T>(obTable, ti));
        }
コード例 #2
0
ファイル: ObjectRow.cs プロジェクト: morecraf/Siaqodb
 public ObjectRow(ObjectTable table)
 {
     this.table = table;
     this.cells = new object[table.Columns.Count];
 }