Adopt .NET naming and structure: CsMic.* namespaces, PascalCase projects and solution; update Coco namespace; update package id and NuGet publish target; adjust project refs and tests.
This commit is contained in:
parent
e84cce9fef
commit
0a67e6e2cc
24 changed files with 54 additions and 49 deletions
38
src/StandardLibrary/functions/Sign.cs
Normal file
38
src/StandardLibrary/functions/Sign.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using CsMic;
|
||||
using FunctionValueType = CsMic.FunctionValueType;
|
||||
|
||||
namespace CsMic.StandardLibrary.Functions
|
||||
{
|
||||
public class Sign : FunctionBase, ICodedFunction
|
||||
{
|
||||
public const decimal POSITIVE = 1;
|
||||
public const decimal NEGATIVE = -1;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "sign";
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<FunctionArgument> ExpectedArguments
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return new FunctionArgument("value", FunctionValue.NUMBER);
|
||||
}
|
||||
}
|
||||
|
||||
public FunctionValue Execute(params FunctionArgument[] args)
|
||||
{
|
||||
return base.Execute(args, (_args) =>
|
||||
{
|
||||
var input = _args[0].Value;
|
||||
decimal number = Convert.ToDecimal(input.Value);
|
||||
|
||||
return new FunctionValue(FunctionValueType.Numeric, number >= 0 ? POSITIVE : NEGATIVE);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue