//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
//**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************//
using System;
using System.Runtime.CompilerServices;
namespace BansheeEngine
{
/** @addtogroup Serialization
* @{
*/
///
/// Provides utility methods dealing with object serialization.
///
public static class SerializableUtility
{
///
/// Clones the specified object. Non-serializable types and fields are ignored in clone. A deep copy is performed
/// on all serializable elements except for resources or game objects.
///
/// Non-null reference to the object to clone. Object type must be serializable.
/// Deep copy of the original object.
public static object Clone(object original)
{
return Internal_Clone(original);
}
///
/// Creates an empty instance of the specified type.
///
/// Type of the object to create. Must be serializable.
/// New instance of the specified type, or null if the type is not serializable.
public static T Create()
{
return (T)Internal_Create(typeof(T));
}
///
/// Creates an empty instance of the specified type.
///
/// Type of the object to create. Must be serializable.
/// New instance of the specified type, or null if the type is not serializable.
public static object Create(Type type)
{
return Internal_Create(type);
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern object Internal_Clone(object original);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern object Internal_Create(Type type);
}
/** @} */
}