Пример #1
0
        public static FieldValue ReadFrom(ArcXmlReader reader)
        {
            try
            {
                FieldValue fieldValue = new FieldValue();

                if (reader.HasAttributes)
                {
                    while (reader.MoveToNextAttribute())
                    {
                        string value = reader.ReadContentAsString();

                        if (value.Length > 0)
                        {
                            switch (reader.Name)
                            {
                            case "valuestring": fieldValue.ValueString = value; break;
                            }
                        }
                    }

                    reader.MoveToElement();
                }

                if (!reader.IsEmptyElement)
                {
                    reader.Read();

                    while (!(reader.NodeType == XmlNodeType.EndElement && reader.Name == XmlName))
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            switch (reader.Name)
                            {
                            case "POINT": fieldValue.Point = (IPoint)GeometrySerializer.ReadFrom(reader); break;
                            }
                        }

                        reader.Read();
                    }
                }

                return(fieldValue);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }
Пример #2
0
        public static Project ReadFrom(ArcXmlReader reader)
        {
            try
            {
                Project project = new Project();

                if (!reader.IsEmptyElement)
                {
                    reader.Read();

                    while (!(reader.NodeType == XmlNodeType.EndElement && reader.Name == XmlName))
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            switch (reader.Name)
                            {
                            case "ENVELOPE": project.Envelopes.Add(EnvelopeSerializer.ReadFrom(reader)); break;

                            case "MULTIPOINT":
                                IMultiPoint multiPoint = (IMultiPoint)GeometrySerializer.ReadFrom(reader);
                                IGeometry   shape      = multiPoint.Count == 1 ? (IGeometry)multiPoint[0] : (IGeometry)multiPoint;
                                project.Shapes.Add(shape);
                                break;

                            case "POLYLINE":
                            case "POLYGON":
                                project.Shapes.Add(GeometrySerializer.ReadFrom(reader));
                                break;
                            }
                        }

                        reader.Read();
                    }
                }

                return(project);
            }
            catch (Exception ex)
            {
                if (ex is ArcXmlException)
                {
                    throw ex;
                }
                else
                {
                    throw new ArcXmlException(String.Format("Could not read {0} element.", XmlName), ex);
                }
            }
        }