Table of Contents

Class MegaFormSdk

Namespace
MegaForm.Sdk
Assembly
MegaForm.Sdk.dll

Ambient accessor for hosts that cannot use constructor injection — e.g. a DNN Razor host, a DDR template, or a legacy .ascx. Call Initialize(IServiceProvider) once at host startup with the application's IServiceProvider, then use RunAsync<T>(Func<IMegaFormClient, Task<T>>) which opens a DI scope, resolves the client, and disposes it.

// DNN razor host:
var forms = await MegaFormSdk.RunAsync(c => c.Forms.ListFormsAsync(
    new FormQuery { Status = "published" },
    new MegaFormScope { PortalId = PortalSettings.PortalId }));

In DI hosts (Oqtane/Web), prefer injecting IMegaFormClient directly.

public static class MegaFormSdk
Inheritance
MegaFormSdk
Inherited Members

Properties

IsInitialized

True once Initialize(IServiceProvider) has been called.

public static bool IsInitialized { get; }

Property Value

bool

Methods

Initialize(IServiceProvider)

Wire the ambient accessor to the host's service provider (call once at startup).

public static void Initialize(IServiceProvider serviceProvider)

Parameters

serviceProvider IServiceProvider

RunAsync(Func<IMegaFormClient, Task>)

Open a scope, resolve IMegaFormClient, run action, dispose the scope.

public static Task RunAsync(Func<IMegaFormClient, Task> action)

Parameters

action Func<IMegaFormClient, Task>

Returns

Task

RunAsync<T>(Func<IMegaFormClient, Task<T>>)

Open a scope, resolve IMegaFormClient, run action, dispose the scope.

public static Task<T> RunAsync<T>(Func<IMegaFormClient, Task<T>> action)

Parameters

action Func<IMegaFormClient, Task<T>>

Returns

Task<T>

Type Parameters

T