mirror of
https://github.com/BtbN/ClanServer.git
synced 2026-03-26 03:54:55 -05:00
Avoid using Count()
This commit is contained in:
parent
3981091915
commit
558c6cb360
|
|
@ -187,14 +187,14 @@ namespace eAmuseCore.KBinXML
|
|||
dataList.Realign();
|
||||
}
|
||||
|
||||
private IEnumerable<byte> GetNodeData(XElement node, byte nodeType, XmlType xmlType, int count)
|
||||
private byte[] GetNodeData(XElement node, byte nodeType, XmlType xmlType, int count)
|
||||
{
|
||||
if (nodeType == XmlType.StrType)
|
||||
{
|
||||
if (count != 1)
|
||||
throw new FormatException("String value cannot have a count != 1.");
|
||||
|
||||
return BinEncoding.GetBytes(node.Value).Concat(new byte[] { 0 });
|
||||
return BinEncoding.GetBytes(node.Value).Concat(new byte[] { 0 }).ToArray();
|
||||
}
|
||||
else if (nodeType == XmlType.BinType)
|
||||
{
|
||||
|
|
@ -210,7 +210,7 @@ namespace eAmuseCore.KBinXML
|
|||
}
|
||||
else
|
||||
{
|
||||
IEnumerable<string> parts = node.Value.Split(' ').AsEnumerable();
|
||||
IEnumerable<string> parts = node.Value.Split(' ');
|
||||
if (parts.Count() != count * xmlType.Count)
|
||||
throw new ArgumentException("Node value does not have required amount of fields.", "node");
|
||||
|
||||
|
|
@ -223,7 +223,7 @@ namespace eAmuseCore.KBinXML
|
|||
parts = parts.Skip(xmlType.Count);
|
||||
}
|
||||
|
||||
return res;
|
||||
return res.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -262,11 +262,11 @@ namespace eAmuseCore.KBinXML
|
|||
|
||||
if (nodeType != XmlType.VoidType)
|
||||
{
|
||||
IEnumerable<byte> data = GetNodeData(node, nodeType, xmlType, count);
|
||||
byte[] data = GetNodeData(node, nodeType, xmlType, count);
|
||||
|
||||
if (isArray || xmlType.Count < 0)
|
||||
{
|
||||
dataList.AddU32((uint)data.Count());
|
||||
dataList.AddU32((uint)data.Length);
|
||||
dataList.AddRangeAligned(data);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -91,8 +91,11 @@ namespace eAmuseCore.KBinXML
|
|||
|
||||
public string KToString(IEnumerable<byte> input)
|
||||
{
|
||||
if (input.Take(Size).Count() != Size)
|
||||
input = input.Take(Size);
|
||||
ICollection<byte> col = input as ICollection<byte>;
|
||||
if (col != null && col.Count != Size)
|
||||
throw new ArgumentException("input does not provide enough data", "input");
|
||||
|
||||
return Converter.KToString(input);
|
||||
}
|
||||
|
||||
|
|
@ -117,7 +120,8 @@ namespace eAmuseCore.KBinXML
|
|||
KBinToString toString = b =>
|
||||
{
|
||||
IEnumerable<byte> data = b.Take(size);
|
||||
if (data.Count() != size)
|
||||
ICollection<byte> col = data as ICollection<byte>;
|
||||
if (col != null && col.Count != size)
|
||||
throw new ArgumentException("input does not provide enough data for all elements", "b");
|
||||
|
||||
string[] res = new string[count];
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@ namespace eAmuseTest
|
|||
else if (compress != "none")
|
||||
throw new ArgumentException("Unsupported compression algorithm");
|
||||
|
||||
KBinXML kbinxml = new KBinXML(rawData);
|
||||
Console.WriteLine("GO");
|
||||
|
||||
KBinXML kbinxml = new KBinXML(rawData.ToArray());
|
||||
|
||||
Console.WriteLine(kbinxml);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user