Exemple #1
0
    /// <summary>Writes a private field to the writer. Note that this should only be called within an ES3Type.</summary>
    /// <param name="name">The name of the field.</param>
    /// <param name="objectContainingField">The object containing the property we want to write.</param>
    public void WritePrivateField(string name, object objectContainingField)
    {
        var field = ES3Reflection.GetES3ReflectedMember(objectContainingField.GetType(), name);

        if (field.IsNull)
        {
            throw new MissingMemberException("A private field named " + name + " does not exist in the type " + objectContainingField.GetType());
        }
        WriteProperty(name, field.GetValue(objectContainingField), ES3TypeMgr.GetOrCreateES3Type(field.MemberType));
    }
Exemple #2
0
    public void WritePrivateFieldByRef(string name, object objectContainingField)
    {
        var field = ES3Reflection.GetES3ReflectedMember(objectContainingField.GetType(), name);

        if (field.IsNull)
        {
            throw new MissingMemberException("A private field named " + name + " does not exist in the type " + objectContainingField.GetType());
        }
        WritePropertyByRef(name, (UnityEngine.Object)field.GetValue(objectContainingField));
    }
Exemple #3
0
    /// <summary>Sets the value of a private field on an object.</summary>
    /// <param name="name">The name of the field we want to set.</param>
    /// <param name="value">The value we want to set the field to.</param>
    /// <param name="objectContainingProperty">The object containing the field we want to set.</param>
    public void SetPrivateField(string name, object value, object objectContainingField)
    {
        var field = ES3Reflection.GetES3ReflectedMember(objectContainingField.GetType(), name);

        if (field.IsNull)
        {
            throw new MissingMemberException("A private field named " + name + " does not exist in the type " + objectContainingField.GetType());
        }
        field.SetValue(objectContainingField, value);
    }