a simple helper stream class to manage data between strings and binary formats, for printing outputs to console.
Inheritance: System.IO.MemoryStream
示例#1
0
        /// <summary>
        /// Helper methods to test de/serialization of and input object and simpl type scope in particular format
        /// </summary>
        /// <param name="originalObject">Original object</param>
        /// <param name="simplTypesScope">Type scope to attempt serialization and deserializaton</param>
        /// <param name="format">Format to de/serialize in</param>
        public static void TestSimplObject(Object originalObject, SimplTypesScope simplTypesScope, Format format)
        {
            Console.WriteLine("Serializing object " + originalObject);
            Console.WriteLine("-----------------------------------------------------------------------------");
            HelperStream originalStream = TestSerialization(originalObject, format);

            Console.WriteLine();
            Object deserializedObj = TestDeserialization(simplTypesScope, originalStream, format);

            TestMethods.AssertSimplTypesEqual(originalObject, deserializedObj);

            Console.WriteLine("Deserialized object " + deserializedObj);
            Console.WriteLine("-----------------------------------------------------------------------------");
            HelperStream deserializedReserializedStream = TestSerialization(deserializedObj, format);
        }
示例#2
0
        /// <summary>
        /// serializes data and returns an the serialized data as a stream for application to use.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="format"></param>
        /// <returns></returns>
        public static HelperStream TestSerialization(Object obj, Format format)
        {
            HelperStream hStream = new HelperStream();

            SimplTypesScope.Serialize(obj, hStream, format);

            /*switch (format)
             * {
             *  case Format.Tlv:
             *      PrettyPrint.PrintBinary(hStream.BinaryData, format);
             *      break;
             *  default:
             *      PrettyPrint.PrintString(hStream.StringData, format);
             *      break;
             * }*/
            Console.WriteLine(Encoding.UTF8.GetString(hStream.ToArray()));
            return(new HelperStream(hStream.BinaryData));
        }