IScriptable interface

SSharp S# API

DropDown image DropDownHover image Collapse image Expand image CollapseAll image ExpandAll image Copy image CopyHover image

Let's look at IScriptable definition:

 

  /// <summary>

  /// Expose dynamic members of an Instance to the script.

  /// This require using of DefaultObjectBinder class as default object binder.

  /// </summary>

  public interface IScriptable

  {

    /// <summary>

    /// Should return object wrapped by IScriptable or this

    /// </summary>

    [Promote(false)]

    object Instance { get; }

 

    /// <summary>

    /// Gets a binding to an instance's member (field, property)

    /// </summary>

    [Promote(false)]

    IMemberBinding GetMember(string name, params object[] arguments);

 

    /// <summary>

    /// Gets a binding to an instance's method

    /// </summary>

    [Promote(false)]

    IBinding GetMethod(string name, params object[] arguments);

  }

Each class implementing this interface has special meaning in S#. Let's assume that variable scriptable associated with an instance implementing IScriptable interface. Then following examples are valid in S#:

 

a = scriptable.PropertyName;

//The same as following code:

// a = scriptable.GetMember("PropertyName").GetValue();

 

scriptable.PropertyName = 2;

//The same as following code:

//scriptable.GetMember("PropertyName").SetValue(2);

 

scriptable.MethodName(1,"test", 3);

//The same as following code:

// scriptable.GetMethod("MethodName").Invoke(currentContext, new object[] {1, "test", 3});