Esempio n. 1
0
 public void WriteTo(ICanRead other)
 {
     other.ReadFrom(this);
 }
Esempio n. 2
0
        /// <summary>
        /// Save an object to a stream
        /// </summary>
        /// <param name="self"></param>
        /// <param name="stream"></param>
        public static void WriteTo(this ICanRead self, Stream stream)
        {
            IMemento memento = new StreamMemento(stream, new FormatterStrategy());

            memento.ReadFrom(self);
        }
Esempio n. 3
0
        /// <summary>
        /// Initialize an object from a stream
        /// </summary>
        /// <param name="self"></param>
        /// <param name="stream"></param>
        public static void ReadFrom(this ICanRead self, Stream stream)
        {
            var memento = new StreamMemento(stream, new FormatterStrategy());

            self.ReadFrom(memento);
        }
Esempio n. 4
0
 public ContiniousReader(ICanRead readable, IFormatterStrategy readFormatter)
 {
     ReadFormatter = readFormatter;
     Readers       = new Stack <IEnumerator>();
     Readers.Push(readFormatter.ReadFormatted(readable).GetEnumerator());
 }
Esempio n. 5
0
 /// <summary>
 /// Returns a snapshot memento of an object
 /// </summary>
 /// <param name="self"></param>
 /// <returns></returns>
 public static IMemento GetMemento(this ICanRead self)
 {
     return(self.GetMemento(new MemoryStream()));
 }
Esempio n. 6
0
 /// <summary>
 /// Deep-clone one object into another
 /// </summary>
 /// <param name="self"></param>
 /// <param name="other"></param>
 public static void CloneTo(this ICanRead self, ICanRead other)
 {
     other.ReadFrom(new ContiniousReader(self, new FormatterStrategy()));
 }
Esempio n. 7
0
 public ReadWriter(IReaderWriterFactory factory)
 {
     reader = factory.CreateReader();
     writer = factory.CreateWriter();
 }