Пример #1
0
        public void Write(TE Dato)
        {
            try
            {
                var binaryFormatter = new BinaryFormatter {
                    Binder = new BinderDeDeserealizacion()
                };


                // writing to memory
                var memoryStream = new MemoryStream(2048);
                var writer       = new XORStream(memoryStream, _password);


                binaryFormatter.Serialize(writer, Dato);
                writer.Flush();
                string info = Convert.ToBase64String(memoryStream.GetBuffer());
                PlayerPrefs.SetString(Dato.id, info);
                PlayerPrefs.Save();
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
                return;
            }
        }
Пример #2
0
        public IList <TE> ReadList(string id, bool esResourceFolder)
        {
            try{
                if (esResourceFolder == false)
                {
                    var data = PlayerPrefs.GetString(id);
                    //If not blank then load it
                    if (!String.IsNullOrEmpty(data))
                    {
                        //Binary formatter for loading back
                        var binaryFormatter = new BinaryFormatter();
                        //Create a memory stream with the data
                        var    inputStream = new MemoryStream(Convert.FromBase64String(data));
                        string typeName;
                        object objeto;
                        using (inputStream)
                        {
                            using (var reader = new XORStream(inputStream, _password))
                            {
                                objeto = binaryFormatter.Deserialize(reader) as object;
                            }
                        }

                        var result = (IList <TE>)objeto;
                        return(result);
                    }
                }
            }
            catch (IOException e)
            {
                Debug.Log(e.Message);
                return(null);
            }
            return(null);
        }
Пример #3
0
        public void WriteTable(string id, Hashtable datos)
        {
            var binaryFormatter = new BinaryFormatter {
                Binder = new BinderDeDeserealizacion()
            };
            var memoryStream = new MemoryStream(2048);
            var writer       = new XORStream(memoryStream, _password);

            binaryFormatter.Serialize(writer, datos);
            writer.Flush();
            string info = Convert.ToBase64String(memoryStream.GetBuffer());

            PlayerPrefs.SetString(id, info);
            PlayerPrefs.Save();
        }
Пример #4
0
 public void WriteList(string id, IList <TE> datos)
 {
     try{
         var binaryFormatter = new BinaryFormatter {
             Binder = new BinderDeDeserealizacion()
         };
         var memoryStream = new MemoryStream(2048);
         var writer       = new XORStream(memoryStream, _password);
         binaryFormatter.Serialize(writer, datos);
         writer.Flush();
         string info = Convert.ToBase64String(memoryStream.GetBuffer());
         PlayerPrefs.SetString(id, info);
         PlayerPrefs.Save();
     }
     catch (Exception e)
     {
         Debug.Log(e.Message);
     }
 }