Skip to content

Execute Code

Nathan edited this page May 24, 2021 · 9 revisions

For the power users out there, I've included the ability for runtime compilation of your own code to act as an action!

Whenever you add a new Execute C# code action, you will be greeted with the following code snippet:

using System;

public class CPHInline
{
    public bool Execute()
    {
        // your main code goes here
        return true;
    }
}

For every execute code sub-action, this is the minimum that must be present for it to function.

You can also have an Init() and a Dispose() method that will be called when your code is first compiled, and when it is destroyed, so if you need to do any initialization steps, or cleanup steps, you'll be able to, THESE TWO METHODS ARE OPTIONAL.

You will want to add the following for init:

public void Init()
{
    // place your init code here
}

And the following for dispose:

public void Dispose()
{
    // place your dispose code here
}

You will be able to make calls to internal ChannelPointsHandler methods using a special CPH class, and all the methods available for use are here

Compiling Log

Shows some general information based on what buttons you've pressed, this will show any compiler errors, and general information when trying to find references

References

List the references required for compiling your code, you can right click to add specific references

Settings

Name

Set a descriptive name for your Execute Code sub-action for a quick glance at what it does

Description

Set a longer description of what your Execute Code sub-action does

Keep Instance Active

By ticking this option, your code will be kept alive for the lifetime of the application, this will allow you to preserve data between calls to this sub-action

Precompile on Application Start

By ticking this, your code will be automatically compiled when you start Channel Points Handler so it is ready to go, instead of the first time the sub-action is ran

Available Buttons

Format Document

This will auto-tab your document to make thing look a bit nicer

Find Refs

Will attempt to auto find some common references based on your using directives

Compile

Test the compilation of your code, see if it compiles clean ;)

Save and Compile

This will save your changes, and pre-compile the code so its ready to go the first time the action is hit

Ok

Save your changes

Cancel

Discard your changes

Examples

I will provide some samples for folks to use here

Clone this wiki locally