|
static void | ReadValues (BinaryReader reader, Encoding encoding, IDictionary< string, object > values) |
|
static object | ReadValue (BinaryReader reader, Encoding encoding) |
|
static Type | ReadType (BinaryReader reader) |
|
static object | ReadObject (BinaryReader reader, Encoding encoding) |
|
static Array | ReadArray (BinaryReader reader, Encoding encoding) |
|
static void | GetObjectValues (Type objType, object obj, SerializeData graph) |
|
static void | SerializeGraph (BinaryWriter writer, Encoding encoding, SerializeData graph) |
|
static byte | GetTypeCode (Type type) |
|
static void | SerializeValue (BinaryWriter writer, Encoding encoding, Type type, object value) |
|
Definition at line 25 of file BinarySerializer.cs.
Deveel.Data.Serialization.BinarySerializer.BinarySerializer |
( |
| ) |
|
|
inline |
object Deveel.Data.Serialization.BinarySerializer.CustomDeserialize |
( |
BinaryReader |
reader, |
|
|
Type |
graphType |
|
) |
| |
|
inlineprivate |
Definition at line 106 of file BinarySerializer.cs.
109 throw new NotSupportedException(
String.Format(
"The type '{0}' has not the special serialization constructor",
112 var values =
new Dictionary<string, object>();
115 var graph =
new ObjectData(graphType, values);
116 return ctor.Invoke(
new object[] {graph});
static void ReadValues(BinaryReader reader, Encoding encoding, IDictionary< string, object > values)
A long string in the system.
ConstructorInfo GetSpecialConstructor(Type type)
object Deveel.Data.Serialization.BinarySerializer.Deserialize |
( |
Stream |
stream, |
|
|
Type |
graphType |
|
) |
| |
|
inline |
Definition at line 32 of file BinarySerializer.cs.
34 throw new ArgumentNullException(
"stream");
36 throw new ArgumentException(
"The input stream cannot be read.",
"stream");
38 var reader =
new BinaryReader(stream,
Encoding);
object Deserialize(Stream stream, Type graphType)
object Deveel.Data.Serialization.BinarySerializer.Deserialize |
( |
BinaryReader |
reader, |
|
|
Type |
graphType |
|
) |
| |
|
inline |
Definition at line 42 of file BinarySerializer.cs.
44 throw new ArgumentNullException(
"reader");
45 if (graphType == null)
46 throw new ArgumentNullException(
"graphType");
49 throw new ArgumentException(
String.Format(
"The type '{0}' is not marked as serializable.", graphType));
51 if (typeof (ISerializable).IsAssignableFrom(graphType))
A long string in the system.
object CustomDeserialize(BinaryReader reader, Type graphType)
object DeserializeType(BinaryReader reader, Type graphType)
object Deveel.Data.Serialization.BinarySerializer.DeserializeType |
( |
BinaryReader |
reader, |
|
|
Type |
graphType |
|
) |
| |
|
inlineprivate |
Definition at line 57 of file BinarySerializer.cs.
60 throw new NotSupportedException(
String.Format(
"The type '{0}' does not specify any default empty constructor.", graphType));
62 var fields = graphType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
64 var properties = graphType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
67 var members =
new List<MemberInfo>();
68 members.AddRange(fields.Cast<MemberInfo>());
69 members.AddRange(properties.Cast<MemberInfo>());
71 var values =
new Dictionary<string, object>();
74 var obj = ctor.Invoke(
new object[0]);
76 foreach (var member
in members) {
77 var memberName = member.Name;
80 if (values.TryGetValue(memberName, out value)) {
83 if (member is PropertyInfo) {
84 var
property = (PropertyInfo) member;
85 property.SetValue(obj, value, null);
86 }
else if (member is FieldInfo) {
87 var field = (FieldInfo) member;
88 field.SetValue(obj, value);
static void ReadValues(BinaryReader reader, Encoding encoding, IDictionary< string, object > values)
A long string in the system.
ConstructorInfo GetDefaultConstructor(Type type)
ConstructorInfo Deveel.Data.Serialization.BinarySerializer.GetDefaultConstructor |
( |
Type |
type | ) |
|
|
inlineprivate |
Definition at line 96 of file BinarySerializer.cs.
97 var ctors = type.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
98 foreach (var ctor
in ctors) {
99 if (ctor.GetParameters().Length == 0)
static void Deveel.Data.Serialization.BinarySerializer.GetObjectValues |
( |
Type |
objType, |
|
|
object |
obj, |
|
|
SerializeData |
graph |
|
) |
| |
|
inlinestaticprivate |
Definition at line 233 of file BinarySerializer.cs.
234 var fields = objType.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
236 var properties = objType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
239 var members =
new List<MemberInfo>();
240 members.AddRange(fields.Cast<MemberInfo>());
241 members.AddRange(properties.Cast<MemberInfo>());
243 foreach (var member
in members) {
244 var memberName = member.Name;
248 if (member is FieldInfo) {
249 value = ((FieldInfo) member).GetValue(obj);
250 memberType = ((FieldInfo) member).FieldType;
251 }
else if (member is PropertyInfo) {
252 value = ((PropertyInfo) member).GetValue(obj, null);
253 memberType = ((PropertyInfo) member).PropertyType;
255 throw new NotSupportedException();
258 graph.SetValue(memberName, memberType, value);
A user-defined TYPE that holds complex objects in a database column.
ConstructorInfo Deveel.Data.Serialization.BinarySerializer.GetSpecialConstructor |
( |
Type |
type | ) |
|
|
inlineprivate |
Definition at line 189 of file BinarySerializer.cs.
190 var ctors = type.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
191 foreach (var ctor
in ctors) {
192 var paramTypes = ctor.GetParameters().Select(x => x.ParameterType).ToArray();
193 if (paramTypes.Length == 1 && paramTypes[0] == typeof(ObjectData))
static byte Deveel.Data.Serialization.BinarySerializer.GetTypeCode |
( |
Type |
type | ) |
|
|
inlinestaticprivate |
Definition at line 290 of file BinarySerializer.cs.
294 if (type.IsPrimitive) {
295 if (type == typeof(
bool))
297 if (type == typeof(byte))
299 if (type == typeof(
short))
301 if (type == typeof(
int))
303 if (type == typeof(
long))
305 if (type == typeof(
float))
307 if (type == typeof(
double))
311 if (type == typeof (
string))
static Array Deveel.Data.Serialization.BinarySerializer.ReadArray |
( |
BinaryReader |
reader, |
|
|
Encoding |
encoding |
|
) |
| |
|
inlinestaticprivate |
Definition at line 178 of file BinarySerializer.cs.
180 var arrayLength = reader.ReadInt32();
181 var array =
Array.CreateInstance(objType, arrayLength);
182 for (
int i = 0; i < arrayLength; i++) {
183 array.SetValue(
ReadValue(reader, encoding), i);
static Type ReadType(BinaryReader reader)
static object ReadValue(BinaryReader reader, Encoding encoding)
static object Deveel.Data.Serialization.BinarySerializer.ReadObject |
( |
BinaryReader |
reader, |
|
|
Encoding |
encoding |
|
) |
| |
|
inlinestaticprivate |
Definition at line 169 of file BinarySerializer.cs.
175 return serializer.Deserialize(reader, objType);
static Type ReadType(BinaryReader reader)
static Type Deveel.Data.Serialization.BinarySerializer.ReadType |
( |
BinaryReader |
reader | ) |
|
|
inlinestaticprivate |
Definition at line 164 of file BinarySerializer.cs.
165 var typeString = reader.ReadString();
166 return Type.GetType(typeString,
true);
A user-defined TYPE that holds complex objects in a database column.
static object Deveel.Data.Serialization.BinarySerializer.ReadValue |
( |
BinaryReader |
reader, |
|
|
Encoding |
encoding |
|
) |
| |
|
inlinestaticprivate |
Definition at line 133 of file BinarySerializer.cs.
134 var typeCode = reader.ReadByte();
135 var nullCheck = reader.ReadBoolean();
141 return reader.ReadBoolean();
143 return reader.ReadByte();
145 return reader.ReadInt16();
147 return reader.ReadInt32();
149 return reader.ReadInt64();
151 return reader.ReadSingle();
153 return reader.ReadDouble();
155 return reader.ReadString();
161 throw new NotSupportedException(
"Invalid type code in serialization graph");
static Array ReadArray(BinaryReader reader, Encoding encoding)
static object ReadObject(BinaryReader reader, Encoding encoding)
static void Deveel.Data.Serialization.BinarySerializer.ReadValues |
( |
BinaryReader |
reader, |
|
|
Encoding |
encoding, |
|
|
IDictionary< string, object > |
values |
|
) |
| |
|
inlinestaticprivate |
Definition at line 119 of file BinarySerializer.cs.
120 int count = reader.ReadInt32();
122 for (
int i = 0; i < count; i++) {
123 var keyLen = reader.ReadInt32();
124 var keyChars = reader.ReadChars(keyLen);
125 var key =
new string(keyChars);
static object ReadValue(BinaryReader reader, Encoding encoding)
void Deveel.Data.Serialization.BinarySerializer.Serialize |
( |
Stream |
stream, |
|
|
object |
obj |
|
) |
| |
|
inline |
Definition at line 200 of file BinarySerializer.cs.
202 throw new ArgumentNullException(
"stream");
204 if (!stream.CanWrite)
205 throw new ArgumentException(
"The serialization stream is not writeable.");
207 var writer =
new BinaryWriter(stream,
Encoding);
void Serialize(Stream stream, object obj)
void Deveel.Data.Serialization.BinarySerializer.Serialize |
( |
BinaryWriter |
writer, |
|
|
object |
obj |
|
) |
| |
|
inline |
Definition at line 211 of file BinarySerializer.cs.
213 throw new ArgumentNullException(
"writer");
215 throw new ArgumentNullException(
"obj");
217 var objType = obj.GetType();
220 throw new ArgumentException(
String.Format(
"The type '{0} is not serializable", objType.FullName));
222 var graph =
new SerializeData(objType);
224 if (typeof (ISerializable).IsAssignableFrom(objType)) {
225 ((ISerializable) obj).GetData(graph);
A long string in the system.
static void GetObjectValues(Type objType, object obj, SerializeData graph)
static void SerializeGraph(BinaryWriter writer, Encoding encoding, SerializeData graph)
static void Deveel.Data.Serialization.BinarySerializer.SerializeGraph |
( |
BinaryWriter |
writer, |
|
|
Encoding |
encoding, |
|
|
SerializeData |
graph |
|
) |
| |
|
inlinestaticprivate |
Definition at line 262 of file BinarySerializer.cs.
263 var values = graph.Values.ToDictionary(x => x.Key, x => x.Value);
264 var count = values.Count;
268 foreach (var pair
in values) {
270 var keyLength = key.Length;
272 writer.Write(keyLength);
273 writer.Write(key.ToCharArray());
275 SerializeValue(writer, encoding, pair.Value.Key, pair.Value.Value);
static void SerializeValue(BinaryWriter writer, Encoding encoding, Type type, object value)
static void Deveel.Data.Serialization.BinarySerializer.SerializeValue |
( |
BinaryWriter |
writer, |
|
|
Encoding |
encoding, |
|
|
Type |
type, |
|
|
object |
value |
|
) |
| |
|
inlinestaticprivate |
Definition at line 320 of file BinarySerializer.cs.
322 if (typeCode == null)
323 throw new NotSupportedException(
String.Format(
"The type '{0}' is not supported.", type));
325 var nullCheck = value == null;
327 writer.Write(typeCode.Value);
328 writer.Write(nullCheck);
334 var typeString = type.GetElementType().FullName;
335 writer.Write(typeString);
337 var array = (
Array) value;
338 var arrayLength = array.Length;
339 var arrayType = type.GetElementType();
341 writer.Write(arrayLength);
343 for (
int i = 0; i < arrayLength; i++) {
344 var element = array.GetValue(i);
348 var realType = value.GetType();
349 writer.Write(realType.FullName);
352 serializer.Serialize(writer, value);
354 writer.Write((
bool) value);
356 writer.Write((byte) value);
358 writer.Write((
short) value);
360 writer.Write((
int) value);
362 writer.Write((
long) value);
364 writer.Write((
float) value);
366 writer.Write((
double) value);
368 writer.Write((
string) value);
A long string in the system.
static void SerializeValue(BinaryWriter writer, Encoding encoding, Type type, object value)
static byte GetTypeCode(Type type)
const byte Deveel.Data.Serialization.BinarySerializer.ArrayType = 20 |
|
private |
const byte Deveel.Data.Serialization.BinarySerializer.BooleanType = 1 |
|
private |
const byte Deveel.Data.Serialization.BinarySerializer.ByteType = 2 |
|
private |
const byte Deveel.Data.Serialization.BinarySerializer.DoubleType = 7 |
|
private |
const byte Deveel.Data.Serialization.BinarySerializer.Int16Type = 3 |
|
private |
const byte Deveel.Data.Serialization.BinarySerializer.Int32Type = 4 |
|
private |
const byte Deveel.Data.Serialization.BinarySerializer.Int64Type = 5 |
|
private |
const byte Deveel.Data.Serialization.BinarySerializer.ObjectType = 15 |
|
private |
const byte Deveel.Data.Serialization.BinarySerializer.SingleType = 6 |
|
private |
const byte Deveel.Data.Serialization.BinarySerializer.StringType = 8 |
|
private |
Encoding Deveel.Data.Serialization.BinarySerializer.Encoding |
|
getset |
The documentation for this class was generated from the following file:
- /var/calculate/remote/distfiles/egit-src/deveeldb.git/src/deveeldb/Deveel.Data.Serialization/BinarySerializer.cs