Ejemplo n.º 1
0
        protected override Task CommitWriteStreamInternal(IStorageStream stream)
        {
            PlayerPrefsStorageStream memoryStream = (PlayerPrefsStorageStream)stream;
            string data = null;

            if (useBase64)
            {
                data = Convert.ToBase64String(((MemoryStream)memoryStream.UnderlyingStream).ToArray());
            }
            else
            {
                data = this.TextEncoding.GetString(((MemoryStream)memoryStream.UnderlyingStream).ToArray());
            }
            PlayerPrefs.SetString(memoryStream.Identifier, data);
            return(Task.CompletedTask);
        }
Ejemplo n.º 2
0
        public override Task <IStorageStream> GetReadStream(string identifier)
        {
            MemoryStream memoryStream = null;

            if (useBase64)
            {
                memoryStream = new MemoryStream(Convert.FromBase64String(PlayerPrefs.GetString(identifier)));
            }
            else
            {
                memoryStream = new MemoryStream(this.TextEncoding.GetBytes(PlayerPrefs.GetString(identifier)));
            }
            PlayerPrefsStorageStream storageStream = new PlayerPrefsStorageStream(identifier, memoryStream);

            return(Task.FromResult <IStorageStream>(storageStream));
        }
Ejemplo n.º 3
0
        public override Task <IStorageStream> GetWriteStream(string identifier)
        {
            PlayerPrefsStorageStream storageStream = new PlayerPrefsStorageStream(identifier, new MemoryStream());

            return(Task.FromResult <IStorageStream>(storageStream));
        }