Skip to content

Commit 8c4777c

Browse files
committed
Updated packages + Storage tests
1 parent 111e722 commit 8c4777c

39 files changed

+146
-74
lines changed

GAIL.Networking/Container/ClientContainer.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
using System.Net.Sockets;
33
using GAIL.Networking.Streams;
44
using GAIL.Serializing.Formatters;
5-
using OxDED.Terminal;
6-
using OxDED.Terminal.Logging;
7-
using OxDED.Terminal.Logging.Targets;
5+
using LambdaKit.Logging;
6+
using LambdaKit.Terminal;
7+
using LambdaKit.Logging.Targets;
88

99
namespace GAIL.Networking.Client;
1010

@@ -137,7 +137,11 @@ public void SetLogger(Logger? logger = null, bool disable = false) {
137137
);
138138
int index = Logger.GetTargetIndex<TerminalTarget>();
139139
if (index > -1) {
140-
Logger.GetTarget<TerminalTarget>(index)!.Format = "<{0}>: ("+Color.DarkBlue.ToForegroundANSI()+"{2}"+ANSI.Styles.ResetAll+")[{5}"+ANSI.Styles.Bold+"{3}"+ANSI.Styles.ResetAll+"] : {5}{4}"+ANSI.Styles.ResetAll;
140+
Logger.GetTarget<TerminalTarget>(index)!.Format =
141+
new StyleBuilder().Text("<{0}>: (")
142+
.Foreground((StandardColor)StandardColor.Colors.Blue).Text("{2}")
143+
.Reset().Text(")[{5}").Bold().Text("{3}").Bold(false)
144+
.Text("] : {5}{4}").Reset().ToString();
141145
Logger.GetTarget<TerminalTarget>(index)!.NameFormat = "{0} - {1}";
142146
}
143147
index = Logger.GetTargetIndex<FileTarget>();

GAIL.Networking/Container/ServerContainer.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
using System.Collections.ObjectModel;
22
using System.Net;
33
using System.Net.Sockets;
4-
using GAIL.Serializing.Formatters;
5-
using OxDED.Terminal;
6-
using OxDED.Terminal.Logging;
7-
using OxDED.Terminal.Logging.Targets;
4+
using LambdaKit.Logging;
5+
using LambdaKit.Logging.Targets;
6+
using LambdaKit.Terminal;
87

98
namespace GAIL.Networking.Server;
109

@@ -133,7 +132,11 @@ public void SetLogger(Logger? logger = null) {
133132
);
134133
int index = Logger.GetTargetIndex<TerminalTarget>();
135134
if (index > -1) {
136-
Logger.GetTarget<TerminalTarget>(index)!.Format = "<{0}>: ("+Color.DarkBlue.ToForegroundANSI()+"{2}"+ANSI.Styles.ResetAll+")[{5}"+ANSI.Styles.Bold+"{3}"+ANSI.Styles.ResetAll+"] : {5}{4}"+ANSI.Styles.ResetAll;
135+
Logger.GetTarget<TerminalTarget>(index)!.Format =
136+
new StyleBuilder().Text("<{0}>: (")
137+
.Foreground((StandardColor)StandardColor.Colors.Blue).Text("{2}")
138+
.Reset().Text(")[{5}").Bold().Text("{3}").Bold(false)
139+
.Text("] : {5}{4}").Reset().ToString();
137140
Logger.GetTarget<TerminalTarget>(index)!.NameFormat = "{0} - {1}";
138141
}
139142
index = Logger.GetTargetIndex<FileTarget>();

GAIL.Networking/GAIL.Networking.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@
1414
</ItemGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="0xDED.Terminal" Version="4.2.5" />
1817
</ItemGroup>
1918

2019
<ItemGroup>
2120
<ProjectReference Include="..\GAIL.Serializing\GAIL.Serializing.csproj" />
2221
</ItemGroup>
2322

23+
<ItemGroup>
24+
<PackageReference Include="LambdaKit.Logging" Version="5.0.0" />
25+
<PackageReference Include="LambdaKit.Terminal" Version="5.0.0" />
26+
</ItemGroup>
27+
2428
</Project>

GAIL.Networking/NetworkRegister.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Reflection;
22
using GAIL.Serializing;
33
using GAIL.Serializing.Formatters;
4-
using OxDED.Terminal.Logging;
4+
using LambdaKit.Logging;
55

66
namespace GAIL.Networking;
77

GAIL.Networking/NetworkTarget.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using GAIL.Networking.Client;
22
using GAIL.Networking.Server;
3-
using OxDED.Terminal.Logging;
4-
using OxDED.Terminal.Logging.Targets;
3+
using LambdaKit.Logging;
4+
using LambdaKit.Logging.Targets;
55

66
namespace GAIL.Networking;
77

GAIL.Networking/Packet/Packets.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using GAIL.Serializing;
2-
using OxDED.Terminal.Logging;
2+
using LambdaKit.Logging;
33

44
namespace GAIL.Networking;
55

GAIL.Networking/Streams/NetworkParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using GAIL.Serializing;
22
using GAIL.Serializing.Formatters;
3-
using OxDED.Terminal.Logging;
3+
using LambdaKit.Logging;
44

55
namespace GAIL.Networking.Streams;
66

GAIL.Storage/GAIL.Storage.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
</ItemGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="0xDED.Terminal" Version="4.2.5" />
1817
</ItemGroup>
1918

2019
<ItemGroup>

GAIL.Storage/Parser/StorageParser.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,26 @@ public virtual List<IMember> ReadMembers(bool hasKey = true) {
106106
/// Applies the formatter to make it parsable (should call at the beginning).
107107
/// </summary>
108108
/// <param name="formatter">The formatter to use for decoding.</param>
109-
public void Decode(IFormatter formatter) {
110-
byte[] raw = new byte[4];
111-
InStream.Read(raw);
112-
IntSerializable @int = new(default);
113-
@int.Parse(raw);
114-
raw = new byte[@int.Value];
115-
InStream.Read(raw);
116-
BaseStream = new MemoryStream(formatter.Decode(raw));
109+
public void Decode(IFormatter? formatter = null) {
110+
BaseStream.Dispose();
111+
112+
byte[] buffer = new byte[4];
113+
InStream.Read(buffer);
114+
IntSerializable size = (IntSerializable)IntSerializable.Info.Creator(buffer);
115+
116+
buffer = new byte[size.Value];
117+
InStream.Read(buffer);
118+
119+
if (formatter != null) buffer = formatter.Decode(buffer);
120+
121+
BaseStream = new MemoryStream(buffer);
117122
}
118123
/// <summary>
119124
/// Parses the stream.
120125
/// </summary>
121126
/// <returns>A dictionary containing the key and child.</returns>
122127
/// <param name="formatter">The formatter to use for decoding.</param>
123-
public Dictionary<string, IMember> Parse(IFormatter formatter) {
128+
public Dictionary<string, IMember> Parse(IFormatter? formatter = null) {
124129
Decode(formatter);
125130

126131
return ReadMembers().ToDictionary(static x => x.Key, static x => x);

GAIL.Storage/Parser/StorageSerializer.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ public void WriteChildren(List<IMember> children, bool hasKey = true) {
9292
/// Applies the formatter (should call at the end).
9393
/// </summary>
9494
/// <param name="formatter">The formatter to apply.</param>
95-
public void Encode(IFormatter formatter) {
96-
byte[] result = formatter.Encode((BaseStream as MemoryStream)!.ToArray());
95+
public void Encode(IFormatter? formatter = null) {
96+
byte[] result = [.. (BaseStream as MemoryStream)!.ToArray()];
97+
BaseStream.SetLength(0);
98+
if (formatter != null) result = formatter.Encode(result);
99+
97100
OutStream.Write(new IntSerializable(result.Length).Serialize());
98101
OutStream.Write(result);
99102
}
@@ -103,7 +106,7 @@ public void Encode(IFormatter formatter) {
103106
/// </summary>
104107
/// <param name="children">The children to write to the stream.</param>
105108
/// <param name="formatter">The formatter to use for encoding.</param>
106-
public void Serialize(ReadOnlyDictionary<string, IMember> children, IFormatter formatter) {
109+
public void Serialize(ReadOnlyDictionary<string, IMember> children, IFormatter? formatter = null) {
107110
WriteChildren([.. children.Values]);
108111
WriteType(MemberType.End);
109112

0 commit comments

Comments
 (0)