| ScribuntoWikiSiteExtensionsScribuntoExecuteLuaAsyncT(WikiSite, String, CancellationToken) Method |
This is preliminary documentation and is subject to change.
Evaluates an ad-hoc Lua module with the specified module content in Scribunto Lua console, and gets the returned value.
Namespace: WikiClientLibrary.ScribuntoAssembly: WikiClientLibrary (in WikiClientLibrary.dll) Version: 0.9.0-int.2+447d1d590e6726b7881f750a0a0e42908f3e417e
Syntax public static Task<T> ScribuntoExecuteLuaAsync<T>(
this WikiSite site,
string moduleContent,
CancellationToken cancellationToken
)
<ExtensionAttribute>
Public Shared Function ScribuntoExecuteLuaAsync(Of T) (
site As WikiSite,
moduleContent As String,
cancellationToken As CancellationToken
) As Task(Of T)
Dim site As WikiSite
Dim moduleContent As String
Dim cancellationToken As CancellationToken
Dim returnValue As Task(Of T)
returnValue = site.ScribuntoExecuteLuaAsync(moduleContent,
cancellationToken)
public:
[ExtensionAttribute]
generic<typename T>
static Task<T>^ ScribuntoExecuteLuaAsync(
WikiSite^ site,
String^ moduleContent,
CancellationToken cancellationToken
)
[<ExtensionAttribute>]
static member ScribuntoExecuteLuaAsync :
site : WikiSite *
moduleContent : string *
cancellationToken : CancellationToken -> Task<'T>
Parameters
- site WikiSite
- The MediaWiki site on which to evaluate the module.
- moduleContent String
- The module content to be evaluated. You need to use return statement to return any value from the module.
- cancellationToken CancellationToken
- A token used to cancel the operation.
Type Parameters
- T
- The expected evaluation return value type.
Return Value
TaskTThe deserialized Lua evaluation result.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
WikiSite. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
Remarks This method will let MediaWiki server to evaluate moduleContent as an ad-hoc Lua module,
and to serialize the return value into JSON with
mw.text.jsonEncode
method. The returned value will be deserialized by WCL with your specified serializerOptions.
You need to read the documentation for jsonEncode carefully, as there might be some common pitfalls, such as
empty Lua table will be serialized as JSON [] rather than {}.
Due to the nature of JSON serialization and deserialization,
you cannot return Lua functions or tables containing functions in the module.
See Also