HiveSharp

Easy-peasy C# based scripting environment for your everyday tasks

Home   |   Download   |   Documentation   |   Donate

Back to Table of contents

How do I use HiveSharp?

Emm... However you want. Duh.

On a serious note, you need to write a script frist to be able to execute it - or have a look at the sample scripts included with the installation. You'll typically find them under "C:\Program Files (x86)\HiveSharp\SampleScripts".

HiveSharp scripts are referred to as modules to emphasize the fact that they contain executable functions as opposed to being executable in a self-sufficient way like shell scripts are. Each HiveSharp module constitutes a valid C# source file. A bare-bones module will consist of little more than a public static class with a public static method in it. Let's have a look at one of the samples, "RawSampleScript.cs":

//Simplistic HiveSharp module

using System;
using System.Windows.Forms;

class MyClass
{
    public static void MyMethod1(string s, int i = 123)
    {
        Console.WriteLine(i);
        MessageBox.Show(s);
        return;
    }
}

This module exposes a class with one method, MyMethod1, executable with one or two arguments. As it stands, no extra metadata is available to HiveSharp when inspecting this module. While it's possible for HiveSharp to execute MyMethod1, it can't infer any information as to what it does or what its parameters mean. Only you can do it by inspecting the source code, which is not ideal. Let's fix it. Cue "RawSampleScript.cs":

//Simplistic HiveSharp module with optional metadata

using System;
using System.Windows.Forms;
using HiveSharp.Runtime; // required for custom Publish attributes

[assembly: Publish("Sample script", "Sample HiveSharp script that demonstrates the basic concepts")]

[Publish("My Class", "Sample class"), Tags("Sample", "Test")]
class MyClass
{
	[Publish("My method #1", "Sample static method with no particular purpose to it"), Tags("Sample", "Test")]
	public static bool MyMethod1(
        [Publish("Greeting", "Content of the message box"), Values(Regex = "Hello,\\s.*")] string s,
        [Publish("Integer number", "The number that's output in the console"), Values(Min = 1, Max = 1024)] int i = 123)
	{
		Console.WriteLine(i);
		MessageBox.Show(s);
		return true;
	}
}

With this extra information at hand, HiveSharp can display user-friendly descriptions of classes, methods and their parameters, as well as apply constraints to arguments with which methods are being executed.

Experiment with scripting for HiveSharp and you'll see why we think it's so handy. Good luck and have fun!

Back to Table of contents

Copyright (C) 2014. Dennis Gurzhii. Please email support@hivesharp.com for support. Trademarks are property of respective owners. Endorsement not implied.