Tuesday 19 June 2012

REPL C# Editor to edit another REPL C# Editor ( i.e. 'Script the Script')

Here is a practical C# example of what can be done with the Type Confusion capabilities added to the O2 Platform.



What is happening in this GUI is that the REPL script on the right is given as a parameter (via the script variable) the REPL gui on the left (which is of type ascx_Simple_Script_Editor);

The problem is that the ascx_Simple_Script_Editor object comes from a dynamically compiled dll (with ascx_Simple_Script_Editor.cs) and the object from the left cannot be casted into the same type on the right.

The solution is to do a Type Confusion cast, which has no direct side effects since the objects are the same.

Here is the code that builds this GUI:

Here is the code that is running on the right-hand-side REPL environment:

To see a practical example of this ideas, next time you are inside an O2 C# REPL Editor, go to the context menu and chose the menu item: Utils -> Script this Script