using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace BansheeEngine
{
#pragma warning disable 649
///
/// Allows you to access meta-data about a managed object and its fields. Similar to Reflection but simpler and faster.
///
public sealed class SerializableObject : ScriptObject
{
internal SerializableProperty parentProperty;
internal object parentObject;
private SerializableField[] _fields;
///
/// Creates a new serializable object for the specified object type.
///
/// C# type of the object.
/// Property used for retrieving this entry.
public SerializableObject(Type objectType, SerializableProperty parentProperty)
{
Internal_CreateInstance(this, objectType);
this.parentProperty = parentProperty;
this.parentObject = null;
}
///
/// Creates a new serializable object for the specified object type.
///
/// C# type of the object.
/// Specific instance of the object of .
public SerializableObject(Type objectType, object parentObject)
{
Internal_CreateInstance(this, objectType);
this.parentProperty = null;
this.parentObject = parentObject;
}
///
/// Creates a new serializable object for the specified object. Object must not be null.
///
/// Specific instance of the object.
public SerializableObject(object parentObject)
{
Internal_CreateInstance(this, parentObject.GetType());
this.parentProperty = null;
this.parentObject = parentObject;
}
///
/// Returns all fields in the object.
///
public SerializableField[] Fields
{
get { return _fields; }
}
///
/// Returns the specific object instance this object is operating on.
///
/// Object instance.
public object GetReferencedObject()
{
if (parentProperty != null)
return parentProperty.GetValue