Example #1
0
        public void Serialize(Stream stream, IVersionedDataCache data_cache_obj)
        {
            UnityEngine.Debug.Assert(data_cache_obj != null && data_cache_obj is DefaultDataCache,
                                     "data_cache_obj is null or is not DefaultDataCache");
            UnityEngine.Debug.Assert(stream != null && stream.CanWrite,
                                     "stream is null or can not write");

            DefaultDataCache data = data_cache_obj as DefaultDataCache;

            using (TextWriter writer = new StreamWriter(stream))
            {
                writer.WriteLine(data.Version);
                writer.Write(data.Content);
            }
        }
Example #2
0
        public IVersionedDataCache Deserialize(Stream stream)
        {
            UnityEngine.Debug.Assert(stream != null && stream.CanRead,
                                     "stream is null or can not read");

            DefaultDataCache data = new DefaultDataCache();

            using (TextReader reader = new StreamReader(stream))
            {
                data.Version = reader.ReadLine();
                data.Content = reader.ReadToEnd();
            }

            return(data);
        }