Beispiel #1
0
        public void TestCustomStream()
        {
            var exampleShaderDefinition = TestObjects.ShaderSamplerDefinition;
            Byte[] bytes = null;

            using (MemoryStream stream = new MemoryStream ())
            {
                using (var channel = new SerialisationChannel <BinaryStreamSerialiser> (
                    stream, ChannelMode.Write))
                {
                    channel.Write <ShaderSamplerDefinition> (exampleShaderDefinition);
                }

                bytes = stream.GetBuffer ();
            }

            using (MemoryStream stream = new MemoryStream (bytes))
            {
                using (var channel = new SerialisationChannel <BinaryStreamSerialiser> (
                    stream, ChannelMode.Read))
                {
                    ShaderSamplerDefinition ssd = channel.Read <ShaderSamplerDefinition> ();

                    Assert.That (ssd, Is.EqualTo (exampleShaderDefinition));
                }
            }
        }
Beispiel #2
0
        static void WriteAsset(IAsset a, String destination)
        {
            Console.WriteLine ("\t\tabout to write asset to " + destination);

            using (var stream = new FileStream (destination, FileMode.OpenOrCreate))
            {
                using (var sc = new SerialisationChannel
                    <BinaryStreamSerialiser>
                        (stream, ChannelMode.Write))
                {
                    // Cor Binary Asset File Header
                    //------------------------------------------------------------------------------------------------//
                    WriteFileHeader (sc);

                    // Now write the object
                    //------------------------------------------------------------------------------------------------//
                    Type assetType = a.GetType ();
                    sc.WriteReflective (assetType, a);

                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine ("\t\tBUILT " + destination);
                    Console.ResetColor ();
                }
            }
        }