Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
SiliconStudio.Core.Utilities Class Reference

Utility class. More...

Static Public Member Functions

static void CopyMemory (IntPtr dest, IntPtr src, int sizeInBytesToCopy)
 
static void CopyMemory (IntPtr dest, IntPtr src, int sizeInBytesToCopy)
 
static unsafe bool CompareMemory (IntPtr from, IntPtr against, int sizeToCompare)
 Compares two block of memory. More...
 
static void ClearMemory (IntPtr dest, byte value, int sizeInBytesToClear)
 Clears the memory. More...
 
static int SizeOf< T > ()
 Return the sizeof a struct from a CLR. Equivalent to sizeof operator but works on generics too. More...
 
static int SizeOf< T > (T[] array)
 Return the sizeof an array of struct. Equivalent to sizeof operator but works on generics too. More...
 
static void Pin< T > (ref T source, Action< IntPtr > pinAction)
 Pins the specified source and call an action with the pinned pointer. More...
 
static void Pin< T > (T[] source, Action< IntPtr > pinAction)
 Pins the specified source and call an action with the pinned pointer. More...
 
static byte[] ToByteArray< T > (T[] source)
 Covnerts a structured array to an equivalent byte array. More...
 
static T Read< T > (IntPtr source)
 Reads the specified T data from a memory location. More...
 
static void Read< T > (IntPtr source, ref T data)
 Reads the specified T data from a memory location. More...
 
static void ReadOut< T > (IntPtr source, out T data)
 Reads the specified T data from a memory location. More...
 
static IntPtr ReadAndPosition< T > (IntPtr source, ref T data)
 Reads the specified T data from a memory location. More...
 
static IntPtr Read< T > (IntPtr source, T[] data, int offset, int count)
 Reads the specified array T[] data from a memory location. More...
 
static void Write< T > (IntPtr destination, ref T data)
 Writes the specified T data to a memory location. More...
 
static IntPtr WriteAndPosition< T > (IntPtr destination, ref T data)
 Writes the specified T data to a memory location. More...
 
static void Write< T > (byte[] destination, T[] data, int offset, int count)
 Writes the specified array T[] data to a memory location. More...
 
static IntPtr Write< T > (IntPtr destination, T[] data, int offset, int count)
 Writes the specified array T[] data to a memory location. More...
 
static unsafe IntPtr AllocateMemory (int sizeInBytes, int align=16)
 Allocate an aligned memory buffer. More...
 
static IntPtr AllocateClearedMemory (int sizeInBytes, byte clearValue=0, int align=16)
 Allocate an aligned memory buffer and clear it with a specified value (0 by defaault). More...
 
static bool IsMemoryAligned (IntPtr memoryPtr, int align=16)
 Determines whether the specified memory pointer is aligned in memory. More...
 
static unsafe void FreeMemory (IntPtr alignedBuffer)
 Allocate an aligned memory buffer. More...
 
static void Dispose< T > (ref T disposable)
 If non-null, disposes the specified object and set it to null, otherwise do nothing. More...
 
static string Join< T > (string separator, T[] array)
 String helper join method to display an array of object as a single string. More...
 
static string Join (string separator, IEnumerable elements)
 String helper join method to display an enumrable of object as a single string. More...
 
static string Join (string separator, IEnumerator elements)
 String helper join method to display an enumrable of object as a single string. More...
 
static byte[] ReadStream (Stream stream)
 Read stream to a byte[] buffer More...
 
static byte[] ReadStream (Stream stream, ref int readLength)
 Read stream to a byte[] buffer More...
 
static int GetHashCode (IDictionary dict)
 Computes a hashcode for a dictionary. More...
 
static int GetHashCode (IEnumerable it)
 Computes a hashcode for an enumeration More...
 
static int GetHashCode (IEnumerator it)
 Computes a hashcode for an enumeration More...
 
static bool Compare (IEnumerable left, IEnumerable right)
 Compares two collection, element by elements. More...
 
static bool Compare (IEnumerator leftIt, IEnumerator rightIt)
 Compares two collection, element by elements. More...
 
static bool Compare< TKey, TValue > (IDictionary< TKey, TValue > first, IDictionary< TKey, TValue > second)
 Compares two collection, element by elements. More...
 
static bool Compare< T > (ICollection< T > left, ICollection< T > right)
 Compares two collection, element by elements. More...
 
static void Swap< T > (ref T left, ref T right)
 Swaps the value between two references. More...
 
static void Sleep (TimeSpan sleepTime)
 Suspends the current thread of a sleepTimeInMillis. More...
 
static void Sleep (int sleepTimeInMillis)
 Suspends the current thread of a sleepTimeInMillis. More...
 

Detailed Description

Utility class.

Definition at line 13 of file Utilities.cs.

Member Function Documentation

static IntPtr SiliconStudio.Core.Utilities.AllocateClearedMemory ( int  sizeInBytes,
byte  clearValue = 0,
int  align = 16 
)
static

Allocate an aligned memory buffer and clear it with a specified value (0 by defaault).

Parameters
sizeInBytesSize of the buffer to allocate.
clearValueDefault value used to clear the buffer.
alignAlignment, 16 bytes by default.
Returns
A pointer to a buffer aligned.

To free this buffer, call FreeMemory

Definition at line 373 of file Utilities.cs.

static unsafe IntPtr SiliconStudio.Core.Utilities.AllocateMemory ( int  sizeInBytes,
int  align = 16 
)
static

Allocate an aligned memory buffer.

Parameters
sizeInBytesSize of the buffer to allocate.
alignAlignment, 16 bytes by default.
Returns
A pointer to a buffer aligned.

To free this buffer, call FreeMemory

Definition at line 354 of file Utilities.cs.

static void SiliconStudio.Core.Utilities.ClearMemory ( IntPtr  dest,
byte  value,
int  sizeInBytesToClear 
)
static

Clears the memory.

Parameters
destThe dest.
valueThe value.
sizeInBytesToClearThe size in bytes to clear.

Definition at line 122 of file Utilities.cs.

static bool SiliconStudio.Core.Utilities.Compare ( IEnumerable  left,
IEnumerable  right 
)
static

Compares two collection, element by elements.

Parameters
leftA "from" enumerator.
rightA "to" enumerator.
Returns
True if lists are identical. False otherwise.

Definition at line 584 of file Utilities.cs.

Referenced by SiliconStudio.Paradox.Shaders.ShaderClassSource.Equals(), and SiliconStudio.Paradox.Shaders.ShaderMixinSource.Equals().

static bool SiliconStudio.Core.Utilities.Compare ( IEnumerator  leftIt,
IEnumerator  rightIt 
)
static

Compares two collection, element by elements.

Parameters
leftItA "from" enumerator.
rightItA "to" enumerator.
Returns
True if lists are identical. False otherwise.

Definition at line 600 of file Utilities.cs.

static bool SiliconStudio.Core.Utilities.Compare< T > ( ICollection< T >  left,
ICollection< T >  right 
)
static

Compares two collection, element by elements.

Parameters
leftThe collection to compare from.
rightThe colllection to compare to.
Returns
True if lists are identical (but no necessarely of the same time). False otherwise.

Definition at line 658 of file Utilities.cs.

References DirectX.count.

static bool SiliconStudio.Core.Utilities.Compare< TKey, TValue > ( IDictionary< TKey, TValue >  first,
IDictionary< TKey, TValue >  second 
)
static

Compares two collection, element by elements.

Parameters
firstThe collection to compare from.
secondThe colllection to compare to.
Returns
True if lists are identical (but no necessarely of the same time). False otherwise.

Definition at line 633 of file Utilities.cs.

static unsafe bool SiliconStudio.Core.Utilities.CompareMemory ( IntPtr  from,
IntPtr  against,
int  sizeToCompare 
)
static

Compares two block of memory.

Parameters
fromThe pointer to compare from.
againstThe pointer to compare against.
sizeToCompareThe size in bytes to compare.
Returns
True if the buffers are equivalent, false otherwise.

Definition at line 86 of file Utilities.cs.

static void SiliconStudio.Core.Utilities.CopyMemory ( IntPtr  dest,
IntPtr  src,
int  sizeInBytesToCopy 
)
static

Definition at line 19 of file Utilities.cs.

static void SiliconStudio.Core.Utilities.CopyMemory ( IntPtr  dest,
IntPtr  src,
int  sizeInBytesToCopy 
)
static

Definition at line 73 of file Utilities.cs.

static void SiliconStudio.Core.Utilities.Dispose< T > ( ref T  disposable)
static

If non-null, disposes the specified object and set it to null, otherwise do nothing.

Parameters
disposableThe disposable.
Type Constraints
T :class 
T :IDisposable 

Definition at line 407 of file Utilities.cs.

static unsafe void SiliconStudio.Core.Utilities.FreeMemory ( IntPtr  alignedBuffer)
static

Allocate an aligned memory buffer.

Returns
A pointer to a buffer aligned.

The buffer must have been allocated with AllocateMemory

Definition at line 398 of file Utilities.cs.

static int SiliconStudio.Core.Utilities.GetHashCode ( IDictionary  dict)
static

Computes a hashcode for a dictionary.

Returns
Hashcode for the list.

Definition at line 527 of file Utilities.cs.

Referenced by SiliconStudio.Paradox.Shaders.ShaderMixinSource.GetHashCode().

static int SiliconStudio.Core.Utilities.GetHashCode ( IEnumerable  it)
static

Computes a hashcode for an enumeration

Parameters
itAn enumerator.
Returns
Hashcode for the list.

Definition at line 546 of file Utilities.cs.

static int SiliconStudio.Core.Utilities.GetHashCode ( IEnumerator  it)
static

Computes a hashcode for an enumeration

Parameters
itAn enumerator.
Returns
Hashcode for the list.

Definition at line 564 of file Utilities.cs.

static bool SiliconStudio.Core.Utilities.IsMemoryAligned ( IntPtr  memoryPtr,
int  align = 16 
)
static

Determines whether the specified memory pointer is aligned in memory.

Parameters
memoryPtrThe memory pointer.
alignThe align.
Returns
true if the specified memory pointer is aligned in memory; otherwise, false.

Definition at line 386 of file Utilities.cs.

Referenced by SiliconStudio.Core.ObjectCollector.Add< T >().

static string SiliconStudio.Core.Utilities.Join ( string  separator,
IEnumerable  elements 
)
static

String helper join method to display an enumrable of object as a single string.

Parameters
separatorThe separator.
elementsThe enumerable.
Returns
a string with array elements serparated by the seperator

Definition at line 442 of file Utilities.cs.

static string SiliconStudio.Core.Utilities.Join ( string  separator,
IEnumerator  elements 
)
static

String helper join method to display an enumrable of object as a single string.

Parameters
separatorThe separator.
elementsThe enumerable.
Returns
a string with array elements serparated by the seperator

Definition at line 464 of file Utilities.cs.

static string SiliconStudio.Core.Utilities.Join< T > ( string  separator,
T[]  array 
)
static

String helper join method to display an array of object as a single string.

Parameters
separatorThe separator.
arrayThe array.
Returns
a string with array elements serparated by the seperator

Definition at line 422 of file Utilities.cs.

static void SiliconStudio.Core.Utilities.Pin< T > ( ref T  source,
Action< IntPtr >  pinAction 
)
static

Pins the specified source and call an action with the pinned pointer.

Template Parameters
TThe type of the structure to pin
Parameters
sourceThe source.
pinActionThe pin action to perform on the pinned pointer.
Type Constraints
T :struct 

Definition at line 157 of file Utilities.cs.

static void SiliconStudio.Core.Utilities.Pin< T > ( T[]  source,
Action< IntPtr >  pinAction 
)
static

Pins the specified source and call an action with the pinned pointer.

Template Parameters
TThe type of the structure to pin
Parameters
sourceThe source array.
pinActionThe pin action to perform on the pinned pointer.
Type Constraints
T :struct 

Definition at line 171 of file Utilities.cs.

static T SiliconStudio.Core.Utilities.Read< T > ( IntPtr  source)
static

Reads the specified T data from a memory location.

Template Parameters
TType of a data to read
Parameters
sourceMemory location to read from.
Returns
The data read from the memory location
Type Constraints
T :struct 

Definition at line 208 of file Utilities.cs.

static void SiliconStudio.Core.Utilities.Read< T > ( IntPtr  source,
ref T  data 
)
static

Reads the specified T data from a memory location.

Template Parameters
TType of a data to read
Parameters
sourceMemory location to read from.
dataThe data write to.
Returns
source pointer + sizeof(T)
Type Constraints
T :struct 

Definition at line 223 of file Utilities.cs.

static IntPtr SiliconStudio.Core.Utilities.Read< T > ( IntPtr  source,
T[]  data,
int  offset,
int  count 
)
static

Reads the specified array T[] data from a memory location.

Template Parameters
TType of a data to read
Parameters
sourceMemory location to read from.
dataThe data write to.
offsetThe offset in the array to write to.
countThe number of T element to read from the memory location
Returns
source pointer + sizeof(T) * count
Type Constraints
T :struct 

Definition at line 270 of file Utilities.cs.

References DirectX.count.

static IntPtr SiliconStudio.Core.Utilities.ReadAndPosition< T > ( IntPtr  source,
ref T  data 
)
static

Reads the specified T data from a memory location.

Template Parameters
TType of a data to read
Parameters
sourceMemory location to read from.
dataThe data write to.
Returns
source pointer + sizeof(T)
Type Constraints
T :struct 

Definition at line 253 of file Utilities.cs.

static void SiliconStudio.Core.Utilities.ReadOut< T > ( IntPtr  source,
out T  data 
)
static

Reads the specified T data from a memory location.

Template Parameters
TType of a data to read
Parameters
sourceMemory location to read from.
dataThe data write to.
Returns
source pointer + sizeof(T)
Type Constraints
T :struct 

Definition at line 238 of file Utilities.cs.

static byte [] SiliconStudio.Core.Utilities.ReadStream ( Stream  stream)
static

Read stream to a byte[] buffer

Parameters
streaminput stream
Returns
a byte[] buffer

Definition at line 485 of file Utilities.cs.

Referenced by SiliconStudio.Paradox.Graphics.Image.Load().

static byte [] SiliconStudio.Core.Utilities.ReadStream ( Stream  stream,
ref int  readLength 
)
static

Read stream to a byte[] buffer

Parameters
streaminput stream
readLengthlength to read
Returns
a byte[] buffer

Definition at line 497 of file Utilities.cs.

static int SiliconStudio.Core.Utilities.SizeOf< T > ( )
static

Return the sizeof a struct from a CLR. Equivalent to sizeof operator but works on generics too.

Template Parameters
Ta struct to evaluate
Returns
sizeof this struct
Type Constraints
T :struct 

Definition at line 135 of file Utilities.cs.

static int SiliconStudio.Core.Utilities.SizeOf< T > ( T[]  array)
static

Return the sizeof an array of struct. Equivalent to sizeof operator but works on generics too.

Template Parameters
Ta struct
Parameters
arrayThe array of struct to evaluate.
Returns
sizeof in bytes of this array of struct
Type Constraints
T :struct 

Definition at line 146 of file Utilities.cs.

static void SiliconStudio.Core.Utilities.Sleep ( TimeSpan  sleepTime)
static

Suspends the current thread of a sleepTimeInMillis.

Parameters
sleepTimeThe duration to sleep.

Definition at line 704 of file Utilities.cs.

static void SiliconStudio.Core.Utilities.Sleep ( int  sleepTimeInMillis)
static

Suspends the current thread of a sleepTimeInMillis.

Parameters
sleepTimeInMillisThe duration to sleep in milliseconds.

Definition at line 717 of file Utilities.cs.

static void SiliconStudio.Core.Utilities.Swap< T > ( ref T  left,
ref T  right 
)
static

Swaps the value between two references.

Template Parameters
TType of a data to swap.
Parameters
leftThe left value.
rightThe right value.

Definition at line 693 of file Utilities.cs.

static byte [] SiliconStudio.Core.Utilities.ToByteArray< T > ( T[]  source)
static

Covnerts a structured array to an equivalent byte array.

Template Parameters
T
Parameters
sourceThe source.
Returns
Type Constraints
T :struct 

Definition at line 185 of file Utilities.cs.

static void SiliconStudio.Core.Utilities.Write< T > ( IntPtr  destination,
ref T  data 
)
static

Writes the specified T data to a memory location.

Template Parameters
TType of a data to write
Parameters
destinationMemory location to write to.
dataThe data to write.
Returns
destination pointer + sizeof(T)
Type Constraints
T :struct 

Definition at line 285 of file Utilities.cs.

static void SiliconStudio.Core.Utilities.Write< T > ( byte[]  destination,
T[]  data,
int  offset,
int  count 
)
static

Writes the specified array T[] data to a memory location.

Template Parameters
TType of a data to write
Parameters
destinationMemory location to write to.
dataThe array of T data to write.
offsetThe offset in the array to read from.
countThe number of T element to write to the memory location
Returns
destination pointer + sizeof(T) * count
Type Constraints
T :struct 

Definition at line 317 of file Utilities.cs.

References DirectX.count.

static IntPtr SiliconStudio.Core.Utilities.Write< T > ( IntPtr  destination,
T[]  data,
int  offset,
int  count 
)
static

Writes the specified array T[] data to a memory location.

Template Parameters
TType of a data to write
Parameters
destinationMemory location to write to.
dataThe array of T data to write.
offsetThe offset in the array to read from.
countThe number of T element to write to the memory location
Returns
destination pointer + sizeof(T) * count
Type Constraints
T :struct 

Definition at line 337 of file Utilities.cs.

References DirectX.count.

static IntPtr SiliconStudio.Core.Utilities.WriteAndPosition< T > ( IntPtr  destination,
ref T  data 
)
static

Writes the specified T data to a memory location.

Template Parameters
TType of a data to write
Parameters
destinationMemory location to write to.
dataThe data to write.
Returns
destination pointer + sizeof(T)
Type Constraints
T :struct 

Definition at line 300 of file Utilities.cs.


The documentation for this class was generated from the following file: