Skip to content

(wip) Your first C# operator

ylmrx edited this page Feb 14, 2024 · 1 revision

Foreword

Tooll is a great platform to prototype your code, but it can be confusing at first how the link is made with the C# environment at work behind it. There's no SDK, or complex plugin-based approach around here : Tooll is your whole SDK.

You'll need some basic experience in both Tooll and C# in order to follow on this article.

Your new operator

This is already described in this article.

Open your tooll folder in your C# IDE (we'll use vscode here).

In order to keep this example minimal, we'll build a trivial network on our HomeCanvas, such as:

[{"Name":"Object","Id":"e413c142-007a-461e-b33b-849fb22947d5","Inputs":[],"Children":[{"Id":"4201acea-9efe-4ef2-b391-e5f30af2b323"/*Text*/,"SymbolId":"fd31d208-12fe-46bf-bfa3-101211f8f497","InputValues":[],"Outputs":[]},{"Id":"a05503f3-03a2-4635-8aee-ae212c6f8f42"/*AString*/,"SymbolId":"5880cbc3-a541-4484-a06a-0e6f77cdbe8e","InputValues":[],"Outputs":[]}],"Connections":[{"SourceParentOrChildId":"a05503f3-03a2-4635-8aee-ae212c6f8f42","SourceSlotId":"dd9d8718-addc-49b1-bd33-aac22b366f94","TargetParentOrChildId":"4201acea-9efe-4ef2-b391-e5f30af2b323","TargetSlotId":"f1f1be0e-d5bc-4940-bbc1-88bfa958f0e1"}]},{"Id":"e413c142-007a-461e-b33b-849fb22947d5"/*Object*/,"InputUis":[],"SymbolChildUis":[{"ChildId":"4201acea-9efe-4ef2-b391-e5f30af2b323"/*Text*/,"Style":"Expanded","Size":{"X":110.0,"Y":179.0},"Position":{"X":143.19415,"Y":10.019348}},{"ChildId":"a05503f3-03a2-4635-8aee-ae212c6f8f42"/*AString*/,"Position":{"X":0.0,"Y":0.0}}],"OutputUis":[]}]

Select these, make "Combine them into a new Type". Hit Ctrl+S to save.

Three files are created in your user Type folder, in Operators/Types/user/your_name/the_name_you_just_picked.

Open the the_name_you_just_picked.cs your IDE.

source code

        [Output(Guid = "42aab94d-c2d4-4334-8312-8bd74d83f5df")]
        public readonly Slot<string> overdone = new Slot<string>();

        public new_operator()
        {
            overdone.UpdateAction = Update;
        }

        private void Update(EvaluationContext context)
        {
            var inString = InputText.GetValue(context);
            overdone.Value = inString.Replace("Tooll", "Tooolll");
        }

pictures

Screenshot 2024-02-14 192915 Screenshot 2024-02-14 193241 Screenshot 2024-02-14 193651 Screenshot 2024-02-14 194407

Clone this wiki locally