public void Save() { var unityPackageManifestPath = Path.Combine(Project.UnityProjectRoot, "Packages", "manifest.json"); var factory = new JsonFactory <UnityPackageManifest>(); factory.Serialize(unityPackageManifestPath, this); }
public Task SendAsync <ValueT>(string message, ValueT value, ISerializer <ValueT> serializer) { if (serializer is null) { throw new ArgumentNullException(nameof(serializer)); } OnDebug($"Send: {value} => {message}"); var data = serializer.Serialize(value); var dataMessage = new DataMessage(message, data); var msgSerializer = new JsonFactory <DataMessage>(); return(SendAsync(msgSerializer.Serialize(dataMessage))); }
public static void Save(IEnumerable <Connection> connections) { if (connections is null) { throw new ArgumentNullException(nameof(connections)); } ConnectionsFile.Directory.Create(); var saver = new JsonFactory <Connection[]>(); using var stream = ConnectionsFile.Open(FileMode.Create, FileAccess.Write, FileShare.None); saver.Serialize(stream, connections.ToArray()); foreach (var connection in connections) { connection.Commit(); } }
public void SerializeToFile() { const string fileName = "testSerializationToFile.json"; if (File.Exists(fileName)) { File.Delete(fileName); } var factory = new JsonFactory <string[]>(); var values = new[] { "asdf", "qwer", "zxcv" }; factory.Serialize(fileName, values); Assert.IsTrue(File.Exists(fileName)); }