-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from delegateas/tst/metadata-function-reg
feat!: Redesigned the way functions are resolved
- Loading branch information
Showing
66 changed files
with
400 additions
and
524 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using ExpressionEngine.Functions.Base; | ||
|
||
namespace ExpressionEngine | ||
{ | ||
/// <summary> | ||
/// FunctionMetadata is used to register functions | ||
/// </summary> | ||
public class FunctionMetadata | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="function">Function must implement <see cref="IFunction"/></param> | ||
/// <param name="alias"></param> | ||
public FunctionMetadata(Type function, string alias) | ||
{ | ||
|
||
Function = function; | ||
Alias = alias; | ||
} | ||
|
||
/// <summary> | ||
/// Function implementation | ||
/// </summary> | ||
public Type Function { get; set; } | ||
|
||
/// <summary> | ||
/// Alias used to invoke function | ||
/// </summary> | ||
public string Alias { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,17 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace ExpressionEngine.Functions.Base | ||
{ | ||
/// <summary> | ||
/// Interface for implementing a function | ||
/// </summary> | ||
public interface IFunction | ||
{ | ||
string FunctionName { get; } | ||
ValueTask<ValueContainer> ExecuteFunction(ValueContainer[] strings); | ||
/// <summary> | ||
/// Execute the given function implementation | ||
/// </summary> | ||
/// <param name="parameters">Parameters given to the functiopn</param> | ||
/// <returns>ValueContainer with the result</returns> | ||
ValueTask<ValueContainer> ExecuteFunction(params ValueContainer[] parameters); | ||
} | ||
|
||
public abstract class Function : IFunction | ||
{ | ||
public string FunctionName { get; } | ||
|
||
protected Function(string functionName) | ||
{ | ||
FunctionName = functionName ?? throw new ArgumentNullException(nameof(functionName)); | ||
} | ||
|
||
public abstract ValueTask<ValueContainer> ExecuteFunction(params ValueContainer[] parameters); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.