Ejemplo n.º 1
0
        public static void WriteAsset(Stream stream, object asset, ITypeWriterFactory typeWriterFactory)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            else if (typeWriterFactory == null)
            {
                throw new ArgumentNullException("typeWriterFactory");
            }


            var writer = new AssetWriter(typeWriterFactory);

            writer.Write(asset);

            var contentStream = writer.writer.BaseStream;

            writer.writer = new BinaryWriter(stream);
            writer.Write(VERSION);
            writer.WriteTypesUsed();

            contentStream.Position = 0;
            contentStream.CopyTo(stream);

            contentStream.Dispose();
        }
Ejemplo n.º 2
0
        public static void WriteAsset(Stream stream, object asset, ITypeWriterFactory typeWriterFactory)
        {
            if (stream == null)
                throw new ArgumentNullException("stream");
            else if (typeWriterFactory == null)
                throw new ArgumentNullException("typeWriterFactory");

            var writer = new AssetWriter(typeWriterFactory);
            writer.Write(asset);

            var contentStream = writer.writer.BaseStream;

            writer.writer = new BinaryWriter(stream);
            writer.Write(VERSION);
            writer.WriteTypesUsed();

            contentStream.Position = 0;
            contentStream.CopyTo(stream);

            contentStream.Dispose();
        }