Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
GetServiceProvidersForPayments.cs
1using System;
2using System.Collections.Generic;
3using System.Reflection;
4using System.Threading.Tasks;
6using Waher.Script;
10
11namespace Paiwise.Functions
12{
17 {
27 : base(CountryCode, Currency, Start, Length, Expression)
28 {
29 }
30
34 public override string FunctionName => nameof(GetServiceProvidersForPayments);
35
39 public override string[] DefaultArgumentNames => new string[] { "CountryCode", "Currency" };
40
45 public override bool IsAsynchronous => true;
46
55 {
56 return this.EvaluateScalarAsync(Argument1, Argument2, Variables).Result;
57 }
58
66 public override async Task<IElement> EvaluateScalarAsync(string Argument1, string Argument2, Variables Variables)
67 {
68 List<IPaymentService> Providers = new List<IPaymentService>();
69
70 Type[] ServiceTypes = Types.GetTypesImplementingInterface(typeof(IPaymentServiceProvider));
71
72 foreach (Type T in ServiceTypes)
73 {
74 ConstructorInfo CI = Types.GetDefaultConstructor(T);
75 if (CI is null)
76 continue;
77
79 IPaymentService[] Services = await ServiceProvider.GetServicesForPayment(Argument2, Argument1);
80
81 foreach (IPaymentService Service in Services)
82 Providers.Add(Service);
83 }
84
85 return new ObjectVector(Providers.ToArray());
86 }
87 }
88}
Gets service providers that can be used to pay for services, given a country and a currency.
override bool IsAsynchronous
If the node (or its decendants) include asynchronous evaluation. Asynchronous nodes should be evaluat...
GetServiceProvidersForPayments(ScriptNode CountryCode, ScriptNode Currency, int Start, int Length, Expression Expression)
Gets service providers that can be used to pay for services, given a country and a currency.
override IElement EvaluateScalar(string Argument1, string Argument2, Variables Variables)
Evaluates the function on two scalar arguments.
override string[] DefaultArgumentNames
Default Argument names
override async Task< IElement > EvaluateScalarAsync(string Argument1, string Argument2, Variables Variables)
Evaluates the function on two scalar arguments.
Contains information about a service provider.
Static class that dynamically manages types and interfaces available in the runtime environment.
Definition: Types.cs:14
static object[] NoParameters
Contains an empty array of parameter values.
Definition: Types.cs:548
static Type[] GetTypesImplementingInterface(string InterfaceFullName)
Gets all types implementing a given interface.
Definition: Types.cs:84
static ConstructorInfo GetDefaultConstructor(Type Type)
Gets the default constructor of a type, if one exists.
Definition: Types.cs:1630
Class managing a script expression.
Definition: Expression.cs:39
Base class for funcions of two scalar variables.
ScriptNode Argument2
Function argument 2.
ScriptNode Argument1
Function argument 1.
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
int Length
Length of expression covered by node.
Definition: ScriptNode.cs:101
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
Collection of variables.
Definition: Variables.cs:25
Interface for information about a service provider that users can use to pay for services.
Interface for information about a service provider that users can use to pay for services.
Basic interface for all types of elements.
Definition: IElement.cs:20