Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
NativeStreamExtensions.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.IO;
4 
5 namespace SiliconStudio.Core.IO
6 {
7  /// <summary>
8  /// Extension methods concerning <see cref="NativeStream"/>.
9  /// </summary>
10  public static class NativeStreamExtensions
11  {
12  /// <summary>
13  /// Converts a <see cref="Stream"/> to a <see cref="NativeStream"/>.
14  /// </summary>
15  /// <remarks>
16  /// If <see cref="stream"/> is already a <see cref="NativeStream"/>, it will be returned as is.
17  /// Otherwise, a <see cref="NativeStreamWrapper"/> around it will be created.
18  /// </remarks>
19  /// <param name="stream">The stream.</param>
20  /// <returns></returns>
21  public static NativeStream ToNativeStream(this Stream stream)
22  {
23  var nativeStream = stream as NativeStream;
24  if (nativeStream == null)
25  nativeStream = new NativeStreamWrapper(stream);
26 
27  return nativeStream;
28  }
29  }
30 }
Extension methods concerning NativeStream.
static NativeStream ToNativeStream(this Stream stream)
Converts a Stream to a NativeStream.
A Stream with additional methods for native read and write operations using IntPtr.
Definition: NativeStream.cs:11