コード例 #1
0
        private void Load()
        {
            using (FileStream fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read))
            {
                CleanInsertDeletes(fileStream);

                using (XmlReader reader = XmlReader.Create(fileStream))
                {
                    reader.MoveToContent();
                    while (reader.Read())
                    {
                        switch (reader.NodeType)
                        {
                        case XmlNodeType.Element:
                            if (reader.Name == "Axis.Axis.Axis" ||
                                reader.Name == "Axis.Axis.AxisSegment" ||
                                reader.Name == "Axis.Axis.Sector")
                            {
                                XElement el = XElement.ReadFrom(reader)
                                              as XElement;
                                if (el != null)
                                {
                                    MyRoot myRoot = parseMyRoot(el);
                                    EmitItem(myRoot.Item);
                                }
                            }
                            break;
                        }
                    }
                    reader.Close();
                }
                fileStream.Close();
            }
            dataHandler.Finished();
        }
コード例 #2
0
        public void CleanInsertDeletes(FileStream fileStream)
        {
            HashSet <Guid> insertset = new HashSet <Guid>();
            HashSet <Guid> deleteset = new HashSet <Guid>();

            using (XmlReader reader = XmlReader.Create(fileStream))
            {
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        if (reader.Name == "Axis.Axis.Axis" ||
                            reader.Name == "Axis.Axis.AxisSegment" ||
                            reader.Name == "Axis.Axis.Sector")
                        {
                            XElement el = XElement.ReadFrom(reader)
                                          as XElement;
                            if (el != null)
                            {
                                MyRoot myRoot = parseMyRoot(el);
                                object item   = myRoot.Item;
                                if (item is AxisAxisAxisAxisAxis)
                                {
                                    AxisAxisAxisAxisAxis axis = (AxisAxisAxisAxisAxis)item;
                                    if (axis.OPERATIONSpecified)
                                    {
                                        switch (axis.OPERATION)
                                        {
                                        case OperationType.INSERT:
                                            insertset.Add(AchsenImportUtils.GuidFromImportString(axis.TID));
                                            break;

                                        case OperationType.DELETE:
                                            deleteset.Add(AchsenImportUtils.GuidFromImportString(axis.TID));
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        insertset.Add(AchsenImportUtils.GuidFromImportString(axis.TID));
                                    }
                                }
                                else if (item is AxisAxisAxisAxisAxisSegment)
                                {
                                    AxisAxisAxisAxisAxisSegment axisSegment = (AxisAxisAxisAxisAxisSegment)item;
                                    if (axisSegment.OPERATIONSpecified)
                                    {
                                        switch (axisSegment.OPERATION)
                                        {
                                        case OperationType.INSERT:
                                            insertset.Add(AchsenImportUtils.GuidFromImportString(axisSegment.TID));
                                            break;

                                        case OperationType.DELETE:
                                            deleteset.Add(AchsenImportUtils.GuidFromImportString(axisSegment.TID));
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        insertset.Add(AchsenImportUtils.GuidFromImportString(axisSegment.TID));
                                    }
                                }
                                else if (item is AxisAxisAxisAxisSector)
                                {
                                    AxisAxisAxisAxisSector axisSector = (AxisAxisAxisAxisSector)item;

                                    if (axisSector.OPERATIONSpecified)
                                    {
                                        switch (axisSector.OPERATION)
                                        {
                                        case OperationType.INSERT:
                                            insertset.Add(AchsenImportUtils.GuidFromImportString(axisSector.TID));
                                            break;

                                        case OperationType.DELETE:
                                            deleteset.Add(AchsenImportUtils.GuidFromImportString(axisSector.TID));
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        insertset.Add(AchsenImportUtils.GuidFromImportString(axisSector.TID));
                                    }
                                }
                            }
                        }
                        break;
                    }
                }
            }
            foreach (Guid deleteId in deleteset)
            {
                if (insertset.Contains(deleteId))
                {
                    this.deletesToIgnore.Add(deleteId);
                }
            }
            fileStream.Seek(0, SeekOrigin.Begin);
        }