-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Class and No Head Support #8
Comments
lol... bro you read my mind...
Writer Exampleusing Byter;
By b = new By();
List<DateTime> times = new List<DateTime>();
Video video = new Video();
Player player = new Player();
b.Add(times);
b.Add(video);
b.Add(plater); byte[] MY_BUFFER = b.Buffer; Reader Exampleusing Byter;
By b = new By(MY_BUFFER);
List<DateTime> times = b.Get<List<DateTime>>();
Video video = b.Get<video>();
Player player = b.Get<Player>();
if (b.IsValid == false)
{
// error on parser
} Encodingusing Byter;
string a = "ABC";
byte[] b = a.GetBytes(); // UTF8 is default;
byte[] c = a.GetBytes(Encoding.UTF32); using Byter;
byte[] a = new byte[] { 1, 2, 3, 4, 5, 6 };
byte[] b = a.GetString(); // UTF8 is default;
byte[] c = a.GetString(Encoding.UTF32); // update default from utf8 to utf32 encoding
StringExtension.Default = Encoding.UTF32;
// string props
string example = "aLe";
string a = example.ToCapitalize(); // output: Ale
string a = example.ToLowerCase(); // output: ale
string a = example.ToUpperCase(); // output: ALE Templatepublic class Video
{
public string name;
public int Likes;
public DateTime UploadTime;
public string[] Tags;
public Metadata Meta;
}
public class Metadata
{
public byte[] buffer;
public Vector3 Something;
}
public class Player
{
public long Id;
public Vector3 position;
public Quaternion rotation;
public Vector3 scale;
public bool running;
puublic int HP;
} Supported Types// 1 byte
Null = TypesPrefix + 0,
Sbyte = TypesPrefix + 1,
Byte = TypesPrefix + 2,
Bool = TypesPrefix + 3,
// 2 bytes
Char = TypesPrefix + 4,
Short = TypesPrefix + 5,
Ushort = TypesPrefix + 6,
// 4 bytes
Uint = TypesPrefix + 7,
Int = TypesPrefix + 8,
Float = TypesPrefix + 9,
Enum = TypesPrefix + 10,
// 8 bytes
Long = TypesPrefix + 11,
Ulong = TypesPrefix + 12,
Double = TypesPrefix + 13,
// 16 bytes
Decimal = TypesPrefix + 14,
// dynamic
Bytes = TypesPrefix + 15,
String = TypesPrefix + 16,
BigInteger = TypesPrefix + 18,
// Symbols
Class = TypesPrefix + 19,
Struct = TypesPrefix + 20,
Array = TypesPrefix + 21,
DateTime = TypesPrefix + 22,
List = TypesPrefix + 23, |
it's looks very good. |
Yes sir! By b = new By();
b.Add((int)100);
b.Add((long)100);
b.Add((short)400);
b.Add((decimal)500);
int i = b.Get<int>();
long l = b.Get<long>();
....
bool sucess = b.IsValid; Now don't have logs or error handles. My recommendation you also can use dynamic read technical, I'll documents is soon. Supported with all Byter version, Looks like: v1, v2 example: Reader r = new Reader (<buffer>);
int v = r.Read<int>();
MyEnum t = (MyEnum)v;
if (t == MyEnum.ChatBuffer)
{
string messageId = r.Read<string>();
....
}
else if (t == MyEnum.PositionBuffer)
{
int playerId = r.Read<int>();
....
} v3 will use By r = new By (<buffer>);
int v = r.Get<int>();
MyEnum t = (MyEnum)v;
if (t == MyEnum.ChatBuffer)
{
string messageId = r.Get<string>();
....
}
else if (t == MyEnum.PositionBuffer)
{
int playerId = r.Get<int>();
....
} Thankful for feedback in version 4 I'll implement your feature, it'll look like code Below b.OnSucess(Type t, string message) =>
{
// message: sucess in read <long> type. Buffer Index <32>. current element <4>
});
b.OnError((Type t, string message) =>
{
// message: error in read <long> type. Buffer Index <32>. past element <3>
}); |
@KFKMan the version 3 is released 🥇 |
Can you add Class support?
With Two Types Of Reading;
1- With Prop Index (you can create a Attribute for that like Index(0) İndex(1))
2- With Head Data => With Prop Name or if class has no duplicate property type Reading With only property type
On Read Ended => Result class need to be returned.
.Result => Serialize/Deserialize Result
.IsSuccesfull => Simply check for any big error accoured if not check for Errors ant have element
.Errors => A dictionary like a <Property, Error> for giving which properties are not readed/writed.
And can you add Extension methods like ReadInt(), WriteInt(), ReadBool().... etc. This will help developers to detect problem.
The text was updated successfully, but these errors were encountered: