using System;
using System.Collections;
using System.IO;
using System.Runtime.InteropServices;
namespace System.Runtime.Serialization
{
/// Provides base functionality for the common language runtime serialization formatters.
// Token: 0x02000478 RID: 1144
[CLSCompliant(false)]
[ComVisible(true)]
[Serializable]
public abstract class Formatter : IFormatter
{
/// When overridden in a derived class, gets or sets the used with the current formatter.
/// The used with the current formatter.
// Token: 0x17000894 RID: 2196
// (get) Token: 0x06002BA7 RID: 11175
// (set) Token: 0x06002BA8 RID: 11176
public abstract SerializationBinder Binder { get; set; }
/// When overridden in a derived class, gets or sets the used for the current serialization.
/// The used for the current serialization.
// Token: 0x17000895 RID: 2197
// (get) Token: 0x06002BA9 RID: 11177
// (set) Token: 0x06002BAA RID: 11178
public abstract StreamingContext Context { get; set; }
/// When overridden in a derived class, gets or sets the used with the current formatter.
/// The used with the current formatter.
// Token: 0x17000896 RID: 2198
// (get) Token: 0x06002BAB RID: 11179
// (set) Token: 0x06002BAC RID: 11180
public abstract ISurrogateSelector SurrogateSelector { get; set; }
/// When overridden in a derived class, deserializes the stream attached to the formatter when it was created, creating a graph of objects identical to the graph originally serialized into that stream.
/// The top object of the deserialized graph of objects.
/// The stream to deserialize.
// Token: 0x06002BAD RID: 11181
public abstract object Deserialize(Stream serializationStream);
/// Returns the next object to serialize, from the formatter's internal work queue.
/// The next object to serialize.
/// The ID assigned to the current object during serialization.
/// The next object retrieved from the work queue did not have an assigned ID.
// Token: 0x06002BAE RID: 11182 RVA: 0x00090350 File Offset: 0x0008E550
protected virtual object GetNext(out long objID)
{
if (this.m_objectQueue.Count == 0)
{
objID = 0L;
return null;
}
object obj = this.m_objectQueue.Dequeue();
bool flag;
objID = this.m_idGenerator.HasId(obj, out flag);
return obj;
}
/// Schedules an object for later serialization.
/// The object ID assigned to the object.
/// The object to schedule for serialization.
// Token: 0x06002BAF RID: 11183 RVA: 0x00090390 File Offset: 0x0008E590
protected virtual long Schedule(object obj)
{
if (obj == null)
{
return 0L;
}
bool flag;
long id = this.m_idGenerator.GetId(obj, out flag);
if (flag)
{
this.m_objectQueue.Enqueue(obj);
}
return id;
}
/// When overridden in a derived class, serializes the graph of objects with the specified root to the stream already attached to the formatter.
/// The stream to which the objects are serialized.
/// The object at the root of the graph to serialize.
// Token: 0x06002BB0 RID: 11184
public abstract void Serialize(Stream serializationStream, object graph);
/// When overridden in a derived class, writes an array to the stream already attached to the formatter.
/// The array to write.
/// The name of the array.
/// The type of elements that the array holds.
// Token: 0x06002BB1 RID: 11185
protected abstract void WriteArray(object obj, string name, Type memberType);
/// When overridden in a derived class, writes a Boolean value to the stream already attached to the formatter.
/// The value to write.
/// The name of the member.
// Token: 0x06002BB2 RID: 11186
protected abstract void WriteBoolean(bool val, string name);
/// When overridden in a derived class, writes an 8-bit unsigned integer to the stream already attached to the formatter.
/// The value to write.
/// The name of the member.
// Token: 0x06002BB3 RID: 11187
protected abstract void WriteByte(byte val, string name);
/// When overridden in a derived class, writes a Unicode character to the stream already attached to the formatter.
/// The value to write.
/// The name of the member.
// Token: 0x06002BB4 RID: 11188
protected abstract void WriteChar(char val, string name);
/// When overridden in a derived class, writes a value to the stream already attached to the formatter.
/// The value to write.
/// The name of the member.
// Token: 0x06002BB5 RID: 11189
protected abstract void WriteDateTime(DateTime val, string name);
/// When overridden in a derived class, writes a value to the stream already attached to the formatter.
/// The value to write.
/// The name of the member.
// Token: 0x06002BB6 RID: 11190
protected abstract void WriteDecimal(decimal val, string name);
/// When overridden in a derived class, writes a double-precision floating-point number to the stream already attached to the formatter.
/// The value to write.
/// The name of the member.
// Token: 0x06002BB7 RID: 11191
protected abstract void WriteDouble(double val, string name);
/// When overridden in a derived class, writes a 16-bit signed integer to the stream already attached to the formatter.
/// The value to write.
/// The name of the member.
// Token: 0x06002BB8 RID: 11192
protected abstract void WriteInt16(short val, string name);
/// When overridden in a derived class, writes a 32-bit signed integer to the stream.
/// The value to write.
/// The name of the member.
// Token: 0x06002BB9 RID: 11193
protected abstract void WriteInt32(int val, string name);
/// When overridden in a derived class, writes a 64-bit signed integer to the stream.
/// The value to write.
/// The name of the member.
// Token: 0x06002BBA RID: 11194
protected abstract void WriteInt64(long val, string name);
/// Inspects the type of data received, and calls the appropriate Write method to perform the write to the stream already attached to the formatter.
/// The name of the member to serialize.
/// The object to write to the stream attached to the formatter.
// Token: 0x06002BBB RID: 11195 RVA: 0x000903C8 File Offset: 0x0008E5C8
protected virtual void WriteMember(string memberName, object data)
{
if (data == null)
{
this.WriteObjectRef(data, memberName, typeof(object));
}
Type type = data.GetType();
if (type.IsArray)
{
this.WriteArray(data, memberName, type);
}
else if (type == typeof(bool))
{
this.WriteBoolean((bool)data, memberName);
}
else if (type == typeof(byte))
{
this.WriteByte((byte)data, memberName);
}
else if (type == typeof(char))
{
this.WriteChar((char)data, memberName);
}
else if (type == typeof(DateTime))
{
this.WriteDateTime((DateTime)data, memberName);
}
else if (type == typeof(decimal))
{
this.WriteDecimal((decimal)data, memberName);
}
else if (type == typeof(double))
{
this.WriteDouble((double)data, memberName);
}
else if (type == typeof(short))
{
this.WriteInt16((short)data, memberName);
}
else if (type == typeof(int))
{
this.WriteInt32((int)data, memberName);
}
else if (type == typeof(long))
{
this.WriteInt64((long)data, memberName);
}
else if (type == typeof(sbyte))
{
this.WriteSByte((sbyte)data, memberName);
}
else if (type == typeof(float))
{
this.WriteSingle((float)data, memberName);
}
else if (type == typeof(TimeSpan))
{
this.WriteTimeSpan((TimeSpan)data, memberName);
}
else if (type == typeof(ushort))
{
this.WriteUInt16((ushort)data, memberName);
}
else if (type == typeof(uint))
{
this.WriteUInt32((uint)data, memberName);
}
else if (type == typeof(ulong))
{
this.WriteUInt64((ulong)data, memberName);
}
else if (type.IsValueType)
{
this.WriteValueType(data, memberName, type);
}
this.WriteObjectRef(data, memberName, type);
}
/// When overridden in a derived class, writes an object reference to the stream already attached to the formatter.
/// The object reference to write.
/// The name of the member.
/// The type of object the reference points to.
// Token: 0x06002BBC RID: 11196
protected abstract void WriteObjectRef(object obj, string name, Type memberType);
/// When overridden in a derived class, writes an 8-bit signed integer to the stream already attached to the formatter.
/// The value to write.
/// The name of the member.
// Token: 0x06002BBD RID: 11197
[CLSCompliant(false)]
protected abstract void WriteSByte(sbyte val, string name);
/// When overridden in a derived class, writes a single-precision floating-point number to the stream already attached to the formatter.
/// The value to write.
/// The name of the member.
// Token: 0x06002BBE RID: 11198
protected abstract void WriteSingle(float val, string name);
/// When overridden in a derived class, writes a value to the stream already attached to the formatter.
/// The value to write.
/// The name of the member.
// Token: 0x06002BBF RID: 11199
protected abstract void WriteTimeSpan(TimeSpan val, string name);
/// When overridden in a derived class, writes a 16-bit unsigned integer to the stream already attached to the formatter.
/// The value to write.
/// The name of the member.
// Token: 0x06002BC0 RID: 11200
[CLSCompliant(false)]
protected abstract void WriteUInt16(ushort val, string name);
/// When overridden in a derived class, writes a 32-bit unsigned integer to the stream already attached to the formatter.
/// The value to write.
/// The name of the member.
// Token: 0x06002BC1 RID: 11201
[CLSCompliant(false)]
protected abstract void WriteUInt32(uint val, string name);
/// When overridden in a derived class, writes a 64-bit unsigned integer to the stream already attached to the formatter.
/// The value to write.
/// The name of the member.
// Token: 0x06002BC2 RID: 11202
[CLSCompliant(false)]
protected abstract void WriteUInt64(ulong val, string name);
/// When overridden in a derived class, writes a value of the given type to the stream already attached to the formatter.
/// The object representing the value type.
/// The name of the member.
/// The of the value type.
// Token: 0x06002BC3 RID: 11203
protected abstract void WriteValueType(object obj, string name, Type memberType);
/// Contains the used with the current formatter.
// Token: 0x040010FD RID: 4349
protected ObjectIDGenerator m_idGenerator = new ObjectIDGenerator();
/// Contains a of the objects left to serialize.
// Token: 0x040010FE RID: 4350
protected Queue m_objectQueue = new Queue();
}
}