Ejemplo n.º 1
0
        public IImportable Import()
        {
            Stream s = null;

            try
            {
                using (s = File.Open(_setting.FullPath, FileMode.Open))
                {
                    BinaryFormatter formatter = new BinaryFormatter();
                    byte[]          bytes     = (byte[])formatter.Deserialize(s);
                    _data = BinaryIO.FromBytes <object>(bytes);
                }
            }
            catch (Exception ex)
            {
                Log.Fatal(ex);
            }
            finally
            {
                if (s != null)
                {
                    s.Close();
                }
            }

            return(this);
        }
Ejemplo n.º 2
0
        public void ExportRepositoryToByteArray()
        {
            // arrange
            var input = new TestRepository {
                MyProperty = "hello test"
            };

            // act
            var bytes  = BinaryIO.ToBytes(input);
            var result = BinaryIO.FromBytes <TestRepository>(bytes);

            // assert
            Assert.AreEqual(result.MyProperty, input.MyProperty);
        }