Пример #1
0
        public static void Write(IGISAttributes attributes, JsonTextWriter jwriter, string[] nonSerializedFields)
        {
            if (attributes == null)
            {
                return;
            }
            if (jwriter == null)
            {
                throw new ArgumentNullException("jwriter", "A valid JSON writer object is required.");
            }

            jwriter.WriteStartObject();

            IEnumerable <string> names = attributes.GetKeys();

            foreach (string name in names)
            {
                if (nonSerializedFields != null && Contains(nonSerializedFields, name))
                {
                    continue;
                }
                jwriter.WriteMember(name);
                jwriter.WriteString(attributes.GetValue(name).ToString());
            }

            jwriter.WriteEndObject();
        }
Пример #2
0
        public static void ReadGISAttributes(IGISAttributes attributes, JsonTextReader jreader)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException("attributes", "A valid attributes reference is required.");
            }
            if (jreader == null)
            {
                throw new ArgumentNullException("jreader", "A valid JSON reader object is required.");
            }

            if (jreader.MoveToContent() && jreader.TokenClass == JsonTokenClass.Object)
            {
                jreader.ReadToken(JsonTokenClass.Object);

                while (jreader.TokenClass == JsonTokenClass.Member)
                {
                    string key   = jreader.ReadMember();
                    string value = jreader.ReadString();

                    attributes.SetValue(key, value);
                }

                jreader.ReadToken(JsonTokenClass.EndObject);
            }
        }
Пример #3
0
        public static void Write(IGISAttributes attributes, TextWriter writer)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException("attributes");
            }
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            Write(attributes, XmlWriter.Create(writer));
        }
Пример #4
0
        public static void Write(IGISAttributes attributes, TextWriter writer, string[] nonSerializedFields)
        {
            if (attributes == null)
            {
                return;
            }
            if (writer == null)
            {
                throw new ArgumentNullException("writer", "A valid text writer object is required.");
            }

            JsonTextWriter jwriter = new JsonTextWriter(writer);

            Write(attributes, jwriter, nonSerializedFields);
        }
Пример #5
0
        public static void ReadGISAttributes(IGISAttributes attributes, TextReader reader)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException("attributes", "A valid attributes reference is required.");
            }
            if (reader == null)
            {
                throw new ArgumentNullException("reader", "A valid reader object is required.");
            }

            JsonTextReader jreader = new JsonTextReader(reader);

            ReadGISAttributes(attributes, jreader);
        }
Пример #6
0
        public static void Write(IGISAttributes attributes, XmlWriter xwriter)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException("attributes");
            }
            if (xwriter == null)
            {
                throw new ArgumentNullException("xwriter");
            }

            xwriter.WriteStartElement("Attributes");

            IEnumerable <string> names = attributes.GetKeys();

            foreach (string name in names)
            {
                xwriter.WriteStartElement("item");
                //write the key
                xwriter.WriteElementString("key", name);
                //write the qualified type name of the value
                //write the value
                object value = attributes.GetValue(name);
                if (value == null)
                {
                    xwriter.WriteElementString("type", null);
                    xwriter.WriteElementString("value", null);
                }
                else
                {
                    TypeConverter typeConverter = TypeDescriptor.GetConverter(value.GetType());
                    xwriter.WriteElementString("type", value.GetType().AssemblyQualifiedName);
                    xwriter.WriteElementString("value", typeConverter.ConvertToString(value));
                }
                xwriter.WriteEndElement();
            }

            xwriter.WriteEndElement();
        }
Пример #7
0
 public GISFeature(IGISAttributes attributes)
 {
     _attributes = attributes;
 }
Пример #8
0
 public GISLineStringFeature(IGISAttributes attributes)
     : base(attributes)
 {
 }
 public GeometryCollectionFeature(IGISAttributes attributes)
     : base(attributes)
 {
 }
Пример #10
0
 public GISLineStringFeature(IGISAttributes attributes) : base(attributes)
 {
 }
Пример #11
0
        public static void ReadGISAttributes(IGISAttributes attributes, JsonTextReader jreader)
        {
            if (attributes == null)
                throw new ArgumentNullException("attributes", "A valid attributes reference is required.");
            if (jreader == null)
                throw new ArgumentNullException("jreader", "A valid JSON reader object is required.");

            if (jreader.MoveToContent() && jreader.TokenClass == JsonTokenClass.Object)
            {
                jreader.ReadToken(JsonTokenClass.Object);

                while (jreader.TokenClass == JsonTokenClass.Member)
                {
                    string key = jreader.ReadMember();
                    string value = jreader.ReadString();

                    attributes.SetValue(key, value);
                }

                jreader.ReadToken(JsonTokenClass.EndObject);
            }
        }
Пример #12
0
        public static void Write(IGISAttributes attributes, TextWriter writer, string[] nonSerializedFields)
        {
            if (attributes == null)
                return;
            if (writer == null)
                throw new ArgumentNullException("writer", "A valid text writer object is required.");

            JsonTextWriter jwriter = new JsonTextWriter(writer);
            Write(attributes, jwriter, nonSerializedFields);
        }
Пример #13
0
        public static void Write(IGISAttributes attributes, JsonTextWriter jwriter, string[] nonSerializedFields)
        {
            if (attributes == null)
                return;
            if (jwriter == null)
                throw new ArgumentNullException("jwriter", "A valid JSON writer object is required.");

            jwriter.WriteStartObject();

            IEnumerable<string> names = attributes.GetKeys();
            foreach (string name in names)
            {
                if (nonSerializedFields != null && Contains(nonSerializedFields, name))
                    continue;
                jwriter.WriteMember(name);
                jwriter.WriteString(attributes.GetValue(name).ToString());
            }

            jwriter.WriteEndObject();
        }
Пример #14
0
 public GISFeature(IGISAttributes attributes)
 {
     _attributes = attributes;
 }
Пример #15
0
 public static void Write(IGISAttributes attributes, JsonTextWriter jwriter)
 {
     Write(attributes, jwriter, null);
 }
Пример #16
0
 public GISPointFeature(IGISAttributes attributes)
     : base(attributes)
 {
 }
Пример #17
0
 public GISPolygonFeature(IGISAttributes attributes)
     : base(attributes)
 {
 }
 public GeometryCollectionFeature(IGISAttributes attributes) : base(attributes)
 {
 }
Пример #19
0
 public static void Write(IGISAttributes attributes, TextWriter writer)
 {
     Write(attributes, writer, null);
 }
Пример #20
0
 public static void Write(IGISAttributes attributes, JsonTextWriter jwriter)
 {
     Write(attributes, jwriter, null);
 }
Пример #21
0
 public GISPolygonFeature(IGISAttributes attributes) : base(attributes)
 {
 }
Пример #22
0
 public static void Write(IGISAttributes attributes, TextWriter writer)
 {
     Write(attributes, writer, null);
 }
Пример #23
0
        // Creates a SqlCommand for inserting a DataRow
        public static SqlCommand CreateInsertCommand(string tableName, string shapeFieldName, IEnumerator <DataColumn> columns, IGISAttributes feature)
        {
            if (string.IsNullOrEmpty(tableName))
            {
                throw new ArgumentNullException("tableName");
            }
            if (columns == null)
            {
                throw new ArgumentNullException("columns");
            }
            if (feature == null)
            {
                throw new ArgumentNullException("feature");
            }

            string     sql     = BuildInsertSQL(tableName, columns, shapeFieldName);
            SqlCommand command = new SqlCommand(sql);

            command.CommandType = System.Data.CommandType.Text;

            columns.Reset();
            while (columns.MoveNext())
            {
                DataColumn column = columns.Current;
                if (!column.AutoIncrement)
                {
                    string parameterName = "@" + column.ColumnName;
                    if (column.DataType == typeof(SqlGeography))
                    {
                        SqlGeography geog = feature.GetValue(column.ColumnName) as SqlGeography;
                        InsertGeographyParameter(command, parameterName, column.ColumnName, geog);
                    }
                    else if (column.DataType == typeof(SqlGeometry))
                    {
                        SqlGeometry geom = feature.GetValue(column.ColumnName) as SqlGeometry;
                        InsertGeometryParameter(command, parameterName, column.ColumnName, geom);
                    }
                    else
                    {
                        object val = feature.GetValue(column.ColumnName);
                        InsertParameter(command, parameterName, column.ColumnName, val, GetSqlDbType(column.DataType));
                    }
                }
            }

            return(command);
        }
Пример #24
0
        public static void ReadGISAttributes(IGISAttributes attributes, TextReader reader)
        {
            if (attributes == null)
                throw new ArgumentNullException("attributes", "A valid attributes reference is required.");
            if (reader == null)
                throw new ArgumentNullException("reader", "A valid reader object is required.");

            JsonTextReader jreader = new JsonTextReader(reader);
            ReadGISAttributes(attributes, jreader);
        }
Пример #25
0
 public GISPointFeature(IGISAttributes attributes) : base(attributes)
 {
 }