Revise LibAC
This commit is contained in:
parent
60ced631ba
commit
c4e7b6fa54
35 changed files with 44 additions and 326 deletions
|
@ -3,7 +3,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace LibZNI
|
namespace LibAC
|
||||||
{
|
{
|
||||||
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple =false, Inherited =true)]
|
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple =false, Inherited =true)]
|
||||||
public class AutoUpdater : Attribute
|
public class AutoUpdater : Attribute
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
|
||||||
namespace LibZNI
|
namespace LibAC
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class BigFloat : IComparable, IComparable<BigFloat>, IEquatable<BigFloat>
|
public class BigFloat : IComparable, IComparable<BigFloat>, IEquatable<BigFloat>
|
||||||
|
|
2
HTTP.cs
2
HTTP.cs
|
@ -8,7 +8,7 @@ using System.IO;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
|
|
||||||
namespace LibZNI
|
namespace LibAC
|
||||||
{
|
{
|
||||||
public class HTTP
|
public class HTTP
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using LibZNI.Serialization;
|
using LibAC.Serialization;
|
||||||
using LibZNI.Serialization.ZNIFile;
|
using LibAC.Serialization.ACFile;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -7,7 +7,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI
|
namespace LibAC
|
||||||
{
|
{
|
||||||
public class Hash : Serializable
|
public class Hash : Serializable
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace LibZNI.Integrity
|
|
||||||
{
|
|
||||||
internal class Branch
|
|
||||||
{
|
|
||||||
private Leaf lA;
|
|
||||||
private Leaf lB;
|
|
||||||
|
|
||||||
public Branch(Leaf a, Leaf b)
|
|
||||||
{
|
|
||||||
lA = a;
|
|
||||||
lB = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] GetNodeHash()
|
|
||||||
{
|
|
||||||
byte[] h1 = Tools.SHA256HashBytes(lA.InputBytes);
|
|
||||||
byte[] h2 = Tools.SHA256HashBytes(lB.InputBytes);
|
|
||||||
|
|
||||||
byte[] h3 = new byte[h1.Length + h2.Length];
|
|
||||||
h1.CopyTo(h3, 0);
|
|
||||||
h2.CopyTo(h3, h1.Length);
|
|
||||||
|
|
||||||
byte[] b = Tools.SHA256HashBytes(Tools.SHA256HashBytes(h3));
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
byte[] i = GetNodeHash();
|
|
||||||
return Tools.Hash2String(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace LibZNI.Integrity
|
|
||||||
{
|
|
||||||
internal class Leaf
|
|
||||||
{
|
|
||||||
public byte[] InputBytes;
|
|
||||||
public Leaf(byte[] inputBytes)
|
|
||||||
{
|
|
||||||
InputBytes = inputBytes;
|
|
||||||
}
|
|
||||||
public Leaf(string input)
|
|
||||||
{
|
|
||||||
InputBytes = Encoding.UTF8.GetBytes(input);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace LibZNI.Integrity
|
|
||||||
{
|
|
||||||
internal class LeafCreationException : Exception
|
|
||||||
{
|
|
||||||
public LeafCreationException(string sMsg):base(sMsg)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,88 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
#define MERKLE_VERBOSE
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace LibZNI.Integrity
|
|
||||||
{
|
|
||||||
public class Tree
|
|
||||||
{
|
|
||||||
private List<Leaf> Leaves;
|
|
||||||
public string MasterHash;
|
|
||||||
public Tree()
|
|
||||||
{
|
|
||||||
Leaves = new List<Leaf>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void NewLeaf(byte[] b = null, string s = null)
|
|
||||||
{
|
|
||||||
if(b != null)
|
|
||||||
{
|
|
||||||
Leaves.Add(new Leaf(b));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(s != null)
|
|
||||||
{
|
|
||||||
Leaves.Add(new Leaf(s));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new LeafCreationException("New leaf cannot be null!");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This process will lock the program up for a few moments while the tree is processed
|
|
||||||
/// </summary>
|
|
||||||
public void ProcessTree()
|
|
||||||
{
|
|
||||||
List<Branch> branches = new List<Branch>();
|
|
||||||
if((Leaves.Count % 2) != 0)
|
|
||||||
{
|
|
||||||
Leaves.Add(Leaves.Last());
|
|
||||||
}
|
|
||||||
for(int i=0;i< Leaves.Count; i += 2)
|
|
||||||
{
|
|
||||||
Branch br = new Branch(Leaves[i], Leaves[i+1]);
|
|
||||||
bool iDo = false;
|
|
||||||
#if MERKLE_VERBOSE
|
|
||||||
iDo = true;
|
|
||||||
#endif
|
|
||||||
if(iDo)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"New Branch: {br}");
|
|
||||||
}
|
|
||||||
branches.Add(br);
|
|
||||||
}
|
|
||||||
while(branches.Count > 1)
|
|
||||||
{
|
|
||||||
if((branches.Count % 2) != 0)
|
|
||||||
{
|
|
||||||
branches.Add(branches.Last());
|
|
||||||
}
|
|
||||||
Branch[] copy = branches.ToArray();
|
|
||||||
branches.Clear();
|
|
||||||
for(int i = 0; i < copy.Length; i += 2)
|
|
||||||
{
|
|
||||||
Leaf a = new Leaf(copy[i].GetNodeHash());
|
|
||||||
Leaf b = new Leaf(copy[i + 1].GetNodeHash());
|
|
||||||
bool iDo = false;
|
|
||||||
Branch br = new Branch(a,b);
|
|
||||||
#if MERKLE_VERBOSE
|
|
||||||
iDo=true;
|
|
||||||
#endif
|
|
||||||
if (iDo)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"New Branch: {br}");
|
|
||||||
}
|
|
||||||
branches.Add(br);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MasterHash = branches[0].ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,7 +5,7 @@ using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI
|
namespace LibAC
|
||||||
{
|
{
|
||||||
public interface IPlugin
|
public interface IPlugin
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
// All credit for the implementation of this file should go to the fNBT Authors, unless stated otherwise by comment!
|
// All credit for the implementation of this file should go to the fNBT Authors, unless stated otherwise by comment!
|
||||||
|
|
||||||
|
|
||||||
using LibZNI.Serialization.ZNIFile;
|
using LibAC.Serialization.ACFile;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace LibZNI.Serialization
|
namespace LibAC.Serialization
|
||||||
{
|
{
|
||||||
/// <summary> BinaryReader wrapper that takes care of reading primitives from an NBT stream,
|
/// <summary> BinaryReader wrapper that takes care of reading primitives from an NBT stream,
|
||||||
/// while taking care of endianness, string encoding, and skipping. </summary>
|
/// while taking care of endianness, string encoding, and skipping. </summary>
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
// DISCLAIMER: Taken from fNBT to be altered to fit the needs of ZNI NBT
|
// DISCLAIMER: Taken from fNBT to be altered to fit the needs of ZNI NBT
|
||||||
// All credit for the implementation of this file should go to the fNBT Authors, unless stated otherwise by comment!
|
// All credit for the implementation of this file should go to the fNBT Authors, unless stated otherwise by comment!
|
||||||
|
|
||||||
using LibZNI.Serialization.ZNIFile;
|
using LibAC.Serialization.ACFile;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace LibZNI.Serialization
|
namespace LibAC.Serialization
|
||||||
{
|
{
|
||||||
/// <summary> BinaryWriter wrapper that writes NBT primitives to a stream,
|
/// <summary> BinaryWriter wrapper that writes NBT primitives to a stream,
|
||||||
/// while taking care of endianness and string encoding, and counting bytes written. </summary>
|
/// while taking care of endianness and string encoding, and counting bytes written. </summary>
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
using LibZNI.Serialization.ZNIFile;
|
using LibAC.Serialization.ACFile;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI.Serialization
|
namespace LibAC.Serialization
|
||||||
{
|
{
|
||||||
public abstract class Serializable
|
public abstract class Serializable
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI.Serialization
|
namespace LibAC.Serialization
|
||||||
{
|
{
|
||||||
public static class SerializingHelper
|
public static class SerializingHelper
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using LibZNI.Serialization.ZNIFile;
|
using LibAC.Serialization.ACFile;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -7,7 +7,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI.Serialization
|
namespace LibAC.Serialization
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This class contains helper functions for interacting with streams and files that are encoded using ZNIFile's structure
|
/// This class contains helper functions for interacting with streams and files that are encoded using ZNIFile's structure
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI.Serialization.ZNIFile
|
namespace LibAC.Serialization.ACFile
|
||||||
{
|
{
|
||||||
public class BoolTag : Tag
|
public class BoolTag : Tag
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI.Serialization.ZNIFile
|
namespace LibAC.Serialization.ACFile
|
||||||
{
|
{
|
||||||
public class ByteArrayTag : Tag
|
public class ByteArrayTag : Tag
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI.Serialization.ZNIFile
|
namespace LibAC.Serialization.ACFile
|
||||||
{
|
{
|
||||||
public class ByteTag : Tag
|
public class ByteTag : Tag
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI.Serialization.ZNIFile
|
namespace LibAC.Serialization.ACFile
|
||||||
{
|
{
|
||||||
public class DoubleTag : Tag
|
public class DoubleTag : Tag
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI.Serialization.ZNIFile
|
namespace LibAC.Serialization.ACFile
|
||||||
{
|
{
|
||||||
public class FloatTag : Tag
|
public class FloatTag : Tag
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ using System.Reflection.Metadata.Ecma335;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI.Serialization.ZNIFile
|
namespace LibAC.Serialization.ACFile
|
||||||
{
|
{
|
||||||
public class Folder : Tag, ICollection<Tag>, ICollection
|
public class Folder : Tag, ICollection<Tag>, ICollection
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI.Serialization.ZNIFile
|
namespace LibAC.Serialization.ACFile
|
||||||
{
|
{
|
||||||
public class IntArrayTag : Tag
|
public class IntArrayTag : Tag
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI.Serialization.ZNIFile
|
namespace LibAC.Serialization.ACFile
|
||||||
{
|
{
|
||||||
public class IntTag : Tag
|
public class IntTag : Tag
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,7 +7,7 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using static System.Net.Mime.MediaTypeNames;
|
using static System.Net.Mime.MediaTypeNames;
|
||||||
|
|
||||||
namespace LibZNI.Serialization.ZNIFile
|
namespace LibAC.Serialization.ACFile
|
||||||
{
|
{
|
||||||
public class ListTag : Tag, IList<Tag>, IList
|
public class ListTag : Tag, IList<Tag>, IList
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI.Serialization.ZNIFile
|
namespace LibAC.Serialization.ACFile
|
||||||
{
|
{
|
||||||
public class LongArrayTag : Tag
|
public class LongArrayTag : Tag
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI.Serialization.ZNIFile
|
namespace LibAC.Serialization.ACFile
|
||||||
{
|
{
|
||||||
public class LongTag : Tag
|
public class LongTag : Tag
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI.Serialization.ZNIFile
|
namespace LibAC.Serialization.ACFile
|
||||||
{
|
{
|
||||||
public class ShortTag : Tag
|
public class ShortTag : Tag
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI.Serialization.ZNIFile
|
namespace LibAC.Serialization.ACFile
|
||||||
{
|
{
|
||||||
public class StringTag : Tag
|
public class StringTag : Tag
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI.Serialization.ZNIFile
|
namespace LibAC.Serialization.ACFile
|
||||||
{
|
{
|
||||||
public abstract class Tag : ICloneable, IComparable<Tag>
|
public abstract class Tag : ICloneable, IComparable<Tag>
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI.Serialization.ZNIFile
|
namespace LibAC.Serialization.ACFile
|
||||||
{
|
{
|
||||||
// Aria: Changed to a type of byte which keeps it to only one byte when writing out in serializing
|
// Aria: Changed to a type of byte which keeps it to only one byte when writing out in serializing
|
||||||
public enum TagType : byte
|
public enum TagType : byte
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI.Serialization.ZNIFile
|
namespace LibAC.Serialization.ACFile
|
||||||
{
|
{
|
||||||
public class UUIDTag : Tag
|
public class UUIDTag : Tag
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI.Serialization.ZNIFile
|
namespace LibAC.Serialization.ACFile
|
||||||
{
|
{
|
||||||
public class uLongTag : Tag
|
public class uLongTag : Tag
|
||||||
{
|
{
|
||||||
|
|
9
Tools.cs
9
Tools.cs
|
@ -9,7 +9,7 @@ using System.Text;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace LibZNI
|
namespace LibAC
|
||||||
{
|
{
|
||||||
|
|
||||||
public static class ConfigLocation
|
public static class ConfigLocation
|
||||||
|
@ -291,6 +291,13 @@ namespace LibZNI
|
||||||
return tmp._key;
|
return tmp._key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string ZHS(string ToHash, int len)
|
||||||
|
{
|
||||||
|
ZHash tmp = ZHash.Bytes2Hash(new byte[len]);
|
||||||
|
tmp.CalculateKey(ToHash);
|
||||||
|
return tmp._key;
|
||||||
|
}
|
||||||
|
|
||||||
public static string ZSR(string ToSerialize)
|
public static string ZSR(string ToSerialize)
|
||||||
{
|
{
|
||||||
ZHash tmp = new ZHash();
|
ZHash tmp = new ZHash();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using LibZNI.Serialization;
|
using LibAC.Serialization;
|
||||||
using LibZNI.Serialization.ZNIFile;
|
using LibAC.Serialization.ACFile;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -7,7 +7,7 @@ using System.Runtime;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibZNI
|
namespace LibAC
|
||||||
{
|
{
|
||||||
public class VersionNumberDifferentException : Exception
|
public class VersionNumberDifferentException : Exception
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
using LibZNI.Serialization;
|
|
||||||
using LibZNI.Serialization.ZNIFile;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// RAM-like memory
|
|
||||||
/// Memory is regularly saved to a temporary file called VM.RAM
|
|
||||||
/// The memory in this class should only be used for temporary persistance between tasks. It should be assumed that this data will purge every restart.
|
|
||||||
/// </summary>
|
|
||||||
namespace LibZNI
|
|
||||||
{
|
|
||||||
|
|
||||||
public class VolatileMemory : Serializable
|
|
||||||
{
|
|
||||||
public static Folder Memory = new Folder("MEM");
|
|
||||||
|
|
||||||
public override void save(Folder f)
|
|
||||||
{
|
|
||||||
f.Add(VolatileMemory.Memory);
|
|
||||||
}
|
|
||||||
public override void load(Folder f)
|
|
||||||
{
|
|
||||||
VolatileMemory.Memory = f["MEM"] as Folder;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void FullSave()
|
|
||||||
{
|
|
||||||
|
|
||||||
Folder f = new Folder("root");
|
|
||||||
save(f);
|
|
||||||
|
|
||||||
TagIO.SaveToFile(ConfigLocation.GetPath()+".volatile", f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
90
ZMap.cs
90
ZMap.cs
|
@ -1,90 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace LibZNI
|
|
||||||
{
|
|
||||||
public class VectorList<T, T2, V> : IComparable
|
|
||||||
{
|
|
||||||
public T Key { get; set; }
|
|
||||||
public T2 Key2 { get; set; }
|
|
||||||
public V Value { get; set; }
|
|
||||||
|
|
||||||
public VectorList(T x, T2 b, V c)
|
|
||||||
{
|
|
||||||
Key = x;
|
|
||||||
Key2 = b;
|
|
||||||
Value = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int CompareTo(object obj)
|
|
||||||
{
|
|
||||||
if(obj == null)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
VectorList<T, T2, V> _other = obj as VectorList<T, T2, V>;
|
|
||||||
if (Key.Equals(_other.Key))
|
|
||||||
{
|
|
||||||
if (Key2.Equals(_other.Key2))
|
|
||||||
{
|
|
||||||
if (Value.Equals(_other.Value))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public class ZMap<T,T2,V> : IEnumerable<VectorList<T, T2, V>>
|
|
||||||
{
|
|
||||||
public List<VectorList<T, T2, V>> _list = new List<VectorList<T, T2, V>>();
|
|
||||||
public void Add(VectorList<T,T2,V> item)
|
|
||||||
{
|
|
||||||
if(!_list.Contains(item))
|
|
||||||
_list.Add(item);
|
|
||||||
}
|
|
||||||
public void Remove(VectorList<T,T2,V> item)
|
|
||||||
{
|
|
||||||
_list.Remove(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
public V GetEntry(T a, T2 b)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return _list.First(x => x.Key.Equals(a) && x.Key2.Equals(b)).Value;
|
|
||||||
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return default(V);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public T2 GetK2(T a , V b)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return _list.First(x => x.Key.Equals(a) && x.Value.Equals(b)).Key2;
|
|
||||||
}catch
|
|
||||||
{
|
|
||||||
return default(T2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerator<VectorList<T, T2, V>> GetEnumerator()
|
|
||||||
{
|
|
||||||
return _list.GetEnumerator();
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator IEnumerable.GetEnumerator()
|
|
||||||
{
|
|
||||||
return GetEnumerator();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue