Browse Source

Removing references to Newtonsoft

Kenric Nugteren 3 weeks ago
parent
commit
5bd2f9369c

+ 1 - 1
PRS.Avalonia/PRS.Avalonia/MainViewModel.cs

@@ -53,7 +53,7 @@ public partial class MainViewModel : ViewModelBase
         PropertyChanged += MainViewModel_PropertyChanged;
 
         // change to HomeView 
-        Navigation.Reset<LoginViewModel>();
+        Navigation.Reset<TestViewModel>();
     }
 
     public override bool OnBackButtonPressed()

+ 1 - 3
PRS.Avalonia/PRS.Avalonia/TestView.axaml

@@ -13,9 +13,7 @@
 								BorderBrush="Black"
 								BorderThickness="1"
 								CornerRadius="4"
-								IsVisible="{Binding IsEditing}"
-								ShowButtons="False"
-								Mode="Ellipse"/>
+								IsVisible="{Binding IsEditing}"/>
 		<Image Name="Image" Source="{Binding Source}" IsVisible="{Binding !IsEditing}"/>
 	</Grid>
 </UserControl>

+ 5 - 7
prs.server/Engines/Certificate/CertificateEngine.cs

@@ -19,7 +19,6 @@ using GenHTTP.Modules.IO;
 using GenHTTP.Modules.Practices;
 using InABox.Core;
 using Microsoft.VisualBasic;
-using Newtonsoft.Json;
 using PRSServices;
 using Timer = System.Timers.Timer;
 
@@ -151,7 +150,7 @@ public class CertificateEngine : Engine<CertificateEngineProperties>
 
         if (typeof(T) == typeof(byte[])) return (T)(object)File.ReadAllBytes(path);
 
-        return JsonConvert.DeserializeObject<T>(File.ReadAllText(path)) ?? default;
+        return Serialization.Deserialize<T>(File.ReadAllText(path)) ?? default;
     }
 
     protected static void Save<T>(string path, T value)
@@ -171,8 +170,7 @@ public class CertificateEngine : Engine<CertificateEngineProperties>
         }
         else
         {
-            File.WriteAllText(path,
-                JsonConvert.SerializeObject(value, Formatting.Indented));
+            File.WriteAllText(path, Serialization.Serialize(value, true));
         }
     }
 
@@ -352,7 +350,7 @@ public class CertificateEngine : Engine<CertificateEngineProperties>
         if (Order?.Payload?.Error != null)
         {
             Logger.Send(LogType.Information, "", "Existing Order reported an Error:");
-            Logger.Send(LogType.Information, "", JsonConvert.SerializeObject(Order.Payload.Error));
+            Logger.Send(LogType.Information, "", Serialization.Serialize(Order.Payload.Error));
             Logger.Send(LogType.Information, "", "Resetting existing order");
             Order = null;
         }
@@ -408,12 +406,12 @@ public class CertificateEngine : Engine<CertificateEngineProperties>
                             if (Handler.AddChallengeHandling(chlngValidation))
                             {
                                 Logger.Send(LogType.Information, "", "Challenge Handler has handled challenge:");
-                                Logger.Send(LogType.Information, "", JsonConvert.SerializeObject(chlngValidation, Formatting.Indented));
+                                Logger.Send(LogType.Information, "", Serialization.Serialize(chlngValidation, true));
                                 var chlngUpdated = await acme.AnswerChallengeAsync(chlng.Url);
                                 if (chlngUpdated.Error != null)
                                 {
                                     Logger.Send(LogType.Error, "", "Submitting Challenge Answer reported an error:");
-                                    Logger.Send(LogType.Error, "", JsonConvert.SerializeObject(chlngUpdated.Error));
+                                    Logger.Send(LogType.Error, "", Serialization.Serialize(chlngUpdated.Error));
                                 }
                             }
 

+ 2 - 4
prs.server/Engines/GPS/GeoJSONFile.cs

@@ -111,10 +111,8 @@ public class GeoJSONFile
 
     public static GeoJSONFile? Load(string filename)
     {
-        var serializer = new Newtonsoft.Json.JsonSerializer();
-        using var sr = new StreamReader(filename);
-        using var jtr = new Newtonsoft.Json.JsonTextReader(sr);
-        var geojson = serializer.Deserialize<GeoJSONFile>(jtr);
+        using var file = File.OpenRead(filename);
+        var geojson = Serialization.Deserialize<GeoJSONFile>(file);
         return geojson;
     }
 }

+ 1 - 2
prs.server/Engines/WebEngine/WebListener.cs

@@ -18,7 +18,6 @@ using GenHTTP.Modules.IO.Streaming;
 using GenHTTP.Modules.Practices;
 using InABox.Clients;
 using InABox.Core;
-using Newtonsoft.Json.Linq;
 using PRSServer.Engines;
 using PRSServices;
 using RazorEngine;
@@ -354,7 +353,7 @@ namespace PRSServer
         /// <returns></returns>
         private IResponseBuilder HandleLogin(IRequest request)
         {
-            var obj = JObject.Parse(new StreamReader(request.Content).ReadToEnd());
+            var obj = Serialization.Deserialize<Dictionary<string, object?>>(request.Content);
 
             var username = obj["username"]?.ToString();
             var password = obj["password"]?.ToString();

+ 0 - 1
prs.shared/Database Update Scripts/Update_7_34.cs

@@ -4,7 +4,6 @@ using InABox.Database;
 using InABox.DynamicGrid;
 using InABox.WPF;
 using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Newtonsoft.Json.Linq;
 using NPOI.POIFS.FileSystem;
 using PRSClasses;
 using Syncfusion.Data.Extensions;

+ 4 - 4
prs.stores/Events/Event.cs

@@ -16,7 +16,7 @@ using System.Threading.Tasks;
 
 namespace PRS.Shared.Events;
 
-public interface IEventData
+public interface IEventData : IPolymorphicallySerialisable
 {
     IEvent Event { get; }
 
@@ -644,7 +644,7 @@ public class ChildEventDataModel : IChildEventDataModel
 
 #endregion
 
-public interface IEvent
+public interface IEvent : IPolymorphicallySerialisable
 {
     IEventDataModelDefinition DataModelDefinition();
 
@@ -734,7 +734,7 @@ public interface IEvent<TDataModel> : IEvent
     Notification GenerateNotification(TDataModel model);
 }
 
-public interface IEventTrigger
+public interface IEventTrigger : IPolymorphicallySerialisable
 {
     IEnumerable<string> ReferencedVariables { get; }
 
@@ -787,7 +787,7 @@ public class OrTrigger<TEvent, TDataModel> : IEventTrigger<TEvent, TDataModel>,
     }
 }
 
-public interface IEventAction
+public interface IEventAction : IPolymorphicallySerialisable
 {
     IEnumerable<string> ReferencedVariables { get; }