Exemplo n.º 1
0
        public static async void SaveToFileAsync(string path, GenericSerializableData data, string identifier = "", string fileExtension = ".bin")
        {
            try
            {
                WestdriveSettings.CheckIO = IOState.pending;
                using (var file = File.Create(path + "-" + identifier + fileExtension))
                {
                    WestdriveSettings.CheckIO = IOState.working;

                    await Task.Run(() =>
                    {
                        Serializer.Serialize(file, data);
                        file.Flush();
                    });

                    file.Close();
                }

                WestdriveSettings.CheckIO = IOState.ready;
            }
            catch (System.Exception e)
            {
                Debug.LogError(e);
                throw;
            }
        }
Exemplo n.º 2
0
        //Converts Raw data into Json format
        public static string ConvertToJSON(GenericSerializableData rawData)
        {
            string JSONString = Newtonsoft.Json.JsonConvert.SerializeObject(rawData);

            return(JSONString);
        }