private void ReadAllValues(BinaryReader reader, int count, out IFeatureAttributeCollection attrs) { /* * if (typeof(T) == typeof(double)) * { * var listDouble = (IList<double>)list; * for (var i = 0; i < count; i++) * { * listDouble.Add(reader.ReadDouble()); * } * } * else if (typeof(T) == typeof(float)) * { * var listFloat = (IList<float>)list; * for (var i = 0; i < count; i++) * { * listFloat.Add(reader.ReadSingle()); * } * } * else if (typeof(T) == typeof(string)) * { * var listString = (IList<string>)list; * for (var i = 0; i < count; i++) * { * listString.Add(reader.ReadString()); * } * } * else if (typeof(T) == typeof(bool)) * { * var listBoolean = (IList<bool>)list; * for (var i = 0; i < count; i++) * { * listBoolean.Add(reader.ReadBoolean()); * } * } * else if (typeof(T) == typeof(int)) * { * var listInt = (IList<int>)list; * for (var i = 0; i < count; i++) * { * listInt.Add(reader.ReadInt32()); * } * } * else if (typeof(T) == typeof(DateTime)) * { * var listDateTime = (IList<DateTime>)list; * for (var i = 0; i < count; i++) * { * listDateTime.Add(new DateTime(reader.ReadInt64())); * } * } * } */ attrs = null; }
private void WriteAllValues(BinaryWriter writer, IFeatureAttributeCollection list) { /* * if (typeof(T) == typeof(double)) * { * var listDouble = (IList<double>)list; * for (var i = 0; i < list.Count; i++) * { * writer.Write(listDouble[i]); * } * } * else if (typeof(T) == typeof(float)) * { * var listFloat = (IList<float>)list; * for (var i = 0; i < list.Count; i++) * { * writer.Write(listFloat[i]); * } * } * else if (typeof(T) == typeof(string)) * { * var listString = (IList<string>)list; * for (var i = 0; i < list.Count; i++) * { * writer.Write(listString[i]); * } * } * else if (typeof(T) == typeof(bool)) * { * var listBoolean = (IList<bool>)list; * for (var i = 0; i < list.Count; i++) * { * writer.Write(listBoolean[i]); * } * } * else if (typeof(T) == typeof(int)) * { * var listInt = (IList<int>)list; * for (var i = 0; i < list.Count; i++) * { * writer.Write(listInt[i]); * } * } * else if (typeof(T) == typeof(DateTime)) * { * var listDateTime = (IList<DateTime>)list; * for (var i = 0; i < list.Count; i++) * { * writer.Write(listDateTime[i].Ticks); * } */ }
public object NullSafeGet(IDataReader rs, string[] names, object owner) { var bytes = (byte[])rs.GetValue(rs.GetOrdinal(names[0])); IFeatureAttributeCollection attrs = null; using (var stream = new MemoryStream(bytes)) { using (var reader = new BinaryReader(stream)) { var count = reader.ReadInt32(); if (count > 0) { this.ReadAllValues(reader, count, out attrs); } } } return(attrs); }