|
@@ -1,11 +1,12 @@
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.IO;
|
|
|
|
|
|
namespace InABox.Core
|
|
|
{
|
|
|
public abstract class PackableDictionary<T> : Dictionary<string, T>, IPackable
|
|
|
{
|
|
|
- public void Pack(FastBinaryWriter writer)
|
|
|
+ public void Pack(BinaryWriter writer)
|
|
|
{
|
|
|
writer.Write(Count);
|
|
|
foreach (var key in Keys)
|
|
@@ -15,7 +16,7 @@ namespace InABox.Core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void Unpack(FastBinaryReader reader)
|
|
|
+ public void Unpack(BinaryReader reader)
|
|
|
{
|
|
|
Clear();
|
|
|
var iCount = reader.ReadInt32();
|
|
@@ -56,19 +57,19 @@ namespace InABox.Core
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public abstract void PackItem(FastBinaryWriter writer, T value);
|
|
|
+ public abstract void PackItem(BinaryWriter writer, T value);
|
|
|
|
|
|
- public abstract T UnpackItem(FastBinaryReader reader);
|
|
|
+ public abstract T UnpackItem(BinaryReader reader);
|
|
|
}
|
|
|
|
|
|
public class PackableStringDictionary : PackableDictionary<string>
|
|
|
{
|
|
|
- public override void PackItem(FastBinaryWriter writer, string value)
|
|
|
+ public override void PackItem(BinaryWriter writer, string value)
|
|
|
{
|
|
|
writer.Write(value);
|
|
|
}
|
|
|
|
|
|
- public override string UnpackItem(FastBinaryReader reader)
|
|
|
+ public override string UnpackItem(BinaryReader reader)
|
|
|
{
|
|
|
return reader.ReadString();
|
|
|
}
|
|
@@ -76,12 +77,12 @@ namespace InABox.Core
|
|
|
|
|
|
public class PackableBooleanDictionary : PackableDictionary<bool>
|
|
|
{
|
|
|
- public override void PackItem(FastBinaryWriter writer, bool value)
|
|
|
+ public override void PackItem(BinaryWriter writer, bool value)
|
|
|
{
|
|
|
writer.Write(value);
|
|
|
}
|
|
|
|
|
|
- public override bool UnpackItem(FastBinaryReader reader)
|
|
|
+ public override bool UnpackItem(BinaryReader reader)
|
|
|
{
|
|
|
return reader.ReadBoolean();
|
|
|
}
|
|
@@ -133,7 +134,7 @@ namespace InABox.Core
|
|
|
}
|
|
|
|
|
|
|
|
|
- public override void PackItem(FastBinaryWriter writer, object value)
|
|
|
+ public override void PackItem(BinaryWriter writer, object value)
|
|
|
{
|
|
|
if (value == null)
|
|
|
{
|
|
@@ -148,7 +149,7 @@ namespace InABox.Core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public override object UnpackItem(FastBinaryReader reader)
|
|
|
+ public override object UnpackItem(BinaryReader reader)
|
|
|
{
|
|
|
var index = reader.ReadInt16();
|
|
|
var type = GetType(index);
|