Skip to main content
Skip table of contents

Building WebTSM Services Extensions

Introduction

On this page you find a short description how to implement your own custom WebTSM Services extension.

How to Build a New WebTSM Services Extension

  1. Create a new Class Library Project in Visual Studio and select .NET 5.0 as Target Framework
  2. Add NuGet Package "HAKOM.Framework.Services"
  3. Add HAKOM.Config and HAKOM.License to the Project and set the following FileProperties for each file:


  4. Edit Project Properties → Build Events

    POWERSHELL
    xcopy "$(TargetDir)$(TargetName).dll" "$(TargetDir)extensions\" /y
    xcopy "$(TargetDir)$(TargetName).pdb" "$(TargetDir)extensions\" /y
    del "$(TargetDir)$(TargetName).dll"
    del "$(TargetDir)$(TargetName).pdb"
  5. Edit your csproj file and add the following target

    XML
    <Target Name="DotNetPublish" AfterTargets="PostBuild">
        <Exec Command="dotnet publish --no-build -f net5.0 -o "$(TargetDir)"" />
    </Target>
  6. Edit Project Properties → Debug


  7. Create your WebTSM Services Extension Controller Class:

    Minimal Working Extension

    C#
    using System;
    using HAKOM.Framework.Services.Extensibility;
    using Microsoft.AspNetCore.Mvc;
    
    namespace MyWebTSMExtension
    {
    	[WebTSMServiceExtension(Name: "mwe")]
    	public class MWExtensionController : ExtensionBaseController
    	{
    		[Route("foo")]
    		public IActionResult DoSomething([FromQuery]string param1)
    		{
    			return Ok("whatever");
    		}
    	}
    }
  8. Start Debugging and call your new Extension Method via GET "{ServiceURL}/extensions/mwe/foo"


Note that when prefixing the Name property of the WebTSMServiceExtension with anything that ends in a / you can expose several controllers under a common extension name.

Example:

Minimal Working Extension

C#
using System;
using HAKOM.Framework.Services.Extensibility;
using Microsoft.AspNetCore.Mvc;

namespace MyWebTSMExtension
{
	[WebTSMServiceExtension(Name: "mwe/onepart")]
	public class MWExtensionController : ExtensionBaseController
	{
		[Route("foo")]//This endpoint will be exposed under /extensions/mwe/onepart/foo
		public IActionResult DoSomething([FromQuery]string param1)
		{
			return Ok("whatever");
		}
	}

	[WebTSMServiceExtension(Name: "mwe/otherpart")]
	public class MWExtensionController : ExtensionBaseController
	{
		[Route("foo")]//This endpoint will be exposed under /extensions/mwe/otherpart/foo
		public IActionResult DoSomething([FromQuery]string param1)
		{ 
			return Ok("whatever"); 
		}
	}

}
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.