Is there some custom hooks to allow me to add a custom API to Telligent? I see the IApi interface, but it looks like the DI is hand rolled in the Telligent.Evolution.Web.Modules.ApiModule class. I would like an API and have the Telligent context like the existing APIs.
I have also create a controller with the attribute RestResource(""), but no luck.
[RestResource("test")] public class TestController : IController, ITestController { private readonly IMapper<User, RestUser> _userMapper; public TestController(IMapper<User, RestUser> userMapper) { _userMapper = userMapper; } public TestResponse Show(TestRequest request) { TestResponse response = new TestResponse((IRestRequest)request); response.Answer = "yes"; return response; } }
And then registered the actions with the IRegisterActions plugin
public class TestActionRegistrar : IRegisterActions { public void RegisterActions(IActionRegistry registry) { registry.RegisterAllActionsIn(this.GetType().Assembly); } }
Then registered the Service loader
public class TestModuleIServiceLoader : IServiceLoader { public void Load(IBindingSyntax controller) { controller.Bind<IRegisterRoutes>().To<TestRouteRegistrar>().InSingletonScope(); controller.Bind<IRegisterActions>().To<TestActionRegistrar>().InSingletonScope(); } }
I think I reached the end of the line, sealed class. The DI for services is a sealed class. Looks like it only adds Telligent services and not any I can build. Might need a custom Global.asax
private sealed class ContentViewWriteContext : IDisposable { private readonly ITenantSiteContext _context; public ContentViewWriteContext(Guid id) { if (!Services.IsInitialized) Services.Initialize((IEnumerable<Assembly>) new Assembly[1] { Assembly.Load(Strings.Get(1951479)) }); this._context = Services.Get<ITenantSiteContext>(); this._context.SetCurrent(id); } public void Dispose() { this._context.Unload(); } }
More code
[edited by: Chris Auer at 8:40 PM (GMT 0) on Tue, Nov 10 2020]