Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
BlobStream.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using SiliconStudio.Core.IO;
5 
6 namespace SiliconStudio.Core.Storage
7 {
8  /// <summary>
9  /// A read-only <see cref="NativeMemoryStream"/> that will properly keep references on its underlying <see cref="Blob"/>.
10  /// </summary>
12  {
13  private Blob blob;
14 
15  public BlobStream(Blob blob) : base(blob.Content, blob.Size)
16  {
17  this.blob = blob;
18 
19  // Keep a reference on the blob while its data is used.
20  this.blob.AddReference();
21  }
22 
23  protected override void Dispose(bool disposing)
24  {
25  base.Dispose(disposing);
26 
27  // Release reference on the blob
28  blob.Release();
29  }
30 
31  /// <inheritdoc/>
32  public override void WriteByte(byte value)
33  {
34  throw new NotSupportedException();
35  }
36 
37  /// <inheritdoc/>
38  public override void Write(IntPtr buffer, int count)
39  {
40  throw new NotSupportedException();
41  }
42 
43  /// <inheritdoc/>
44  public override void Write(byte[] buffer, int offset, int count)
45  {
46  throw new NotSupportedException();
47  }
48 
49  /// <inheritdoc/>
50  public override bool CanWrite
51  {
52  get
53  {
54  return false;
55  }
56  }
57  }
58 }
Stores immutable binary content.
Definition: Blob.cs:13
A read-only NativeMemoryStream that will properly keep references on its underlying Blob...
Definition: BlobStream.cs:11
override void Write(byte[] buffer, int offset, int count)
Definition: BlobStream.cs:44
_In_ size_t count
Definition: DirectXTexP.h:174
A MemoryStream over a native memory region.
override void Dispose(bool disposing)
Definition: BlobStream.cs:23
override void WriteByte(byte value)
Definition: BlobStream.cs:32
Only valid for a property / field that has a class or struct type. When restored, instead of recreati...
override void Write(IntPtr buffer, int count)
Writes a block of bytes to this stream using data from a buffer. The buffer containing data to write ...
Definition: BlobStream.cs:38