mirror of
https://github.com/BtbN/ClanServer.git
synced 2026-09-06 23:45:15 -05:00
Add helpers for adding to lists
This commit is contained in:
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace eAmuseCore.KBinXML
|
||||
namespace eAmuseCore.KBinXML.Helpers
|
||||
{
|
||||
static class EnumHelpers
|
||||
{
|
||||
@@ -163,9 +163,30 @@ namespace eAmuseCore.KBinXML
|
||||
return input.TakeD(1).First();
|
||||
}
|
||||
|
||||
public static IEnumerable<object> Box<T>(this IEnumerable<T> input)
|
||||
public static void AddU8(this List<byte> list, byte data)
|
||||
{
|
||||
return input.Select(v => (object)v);
|
||||
list.Add(data);
|
||||
}
|
||||
|
||||
public static void AddS8(this List<byte> list, sbyte data)
|
||||
{
|
||||
list.Add(unchecked((byte)data));
|
||||
}
|
||||
|
||||
public static void AddU32(this List<byte> list, uint data)
|
||||
{
|
||||
IEnumerable<byte> bytes = BitConverter.GetBytes(data);
|
||||
if (BitConverter.IsLittleEndian)
|
||||
bytes = bytes.Reverse();
|
||||
list.AddRange(bytes);
|
||||
}
|
||||
|
||||
public static void AddS32(this List<byte> list, int data)
|
||||
{
|
||||
IEnumerable<byte> bytes = BitConverter.GetBytes(data);
|
||||
if (BitConverter.IsLittleEndian)
|
||||
bytes = bytes.Reverse();
|
||||
list.AddRange(bytes);
|
||||
}
|
||||
|
||||
public static IEnumerable<byte> TakeBytesAligned(ref IEnumerable<byte> input, int size = -1)
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using eAmuseCore.KBinXML.Helpers;
|
||||
|
||||
namespace eAmuseCore.KBinXML
|
||||
{
|
||||
public class KBinXML
|
||||
@@ -59,6 +60,19 @@ namespace eAmuseCore.KBinXML
|
||||
public IEnumerable<byte> Bytes { get; private set; }
|
||||
public Encoding BinEncoding { get; private set; }
|
||||
|
||||
public KBinXML(XDocument doc, Encoding encoding, bool compress = true)
|
||||
{
|
||||
Document = doc;
|
||||
compressed = compress;
|
||||
BinEncoding = encoding;
|
||||
|
||||
Generate();
|
||||
}
|
||||
|
||||
public KBinXML(XDocument doc, bool compress = true)
|
||||
:this(doc, Encoding.GetEncoding(932), compress)
|
||||
{ }
|
||||
|
||||
public KBinXML(IEnumerable<byte> input)
|
||||
{
|
||||
Bytes = input;
|
||||
@@ -66,25 +80,19 @@ namespace eAmuseCore.KBinXML
|
||||
Parse();
|
||||
}
|
||||
|
||||
public KBinXML(XDocument doc, Encoding encoding, bool compress = true)
|
||||
{
|
||||
Document = doc;
|
||||
compressed = compress;
|
||||
BinEncoding = encoding;
|
||||
}
|
||||
|
||||
public KBinXML(XDocument doc, bool compress = true)
|
||||
{
|
||||
Document = doc;
|
||||
compressed = compress;
|
||||
BinEncoding = Encoding.GetEncoding(932);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Document.ToString();
|
||||
}
|
||||
|
||||
private void Generate()
|
||||
{
|
||||
List<byte> header = new List<byte>(8);
|
||||
}
|
||||
|
||||
private List<byte> nodeList = null, dataList = null;
|
||||
private int dataByteOffset = 0, dataWordOffset = 0;
|
||||
|
||||
private void Parse()
|
||||
{
|
||||
IEnumerable<byte> input = Bytes;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System;
|
||||
|
||||
using eAmuseCore.KBinXML.Helpers;
|
||||
|
||||
namespace eAmuseCore.KBinXML
|
||||
{
|
||||
static class SixBit
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace eAmuseCore.KBinXML
|
||||
namespace eAmuseCore.KBinXML.Helpers
|
||||
{
|
||||
public interface IKValue
|
||||
{
|
||||
|
||||
@@ -4,9 +4,10 @@ using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
|
||||
using eAmuseCore.KBinXML.Helpers;
|
||||
|
||||
namespace eAmuseCore.KBinXML.XmlTypes
|
||||
{
|
||||
#pragma warning disable IDE0060 // Remove unused parameter
|
||||
|
||||
Reference in New Issue
Block a user