mirror of https://github.com/dapr/dotnet-sdk.git
Fixed build error
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
This commit is contained in:
parent
3ca5e340c6
commit
f32c22565b
|
@ -17,48 +17,45 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using Dapr.Client;
|
||||
|
||||
namespace Samples.Client
|
||||
namespace Samples.Client;
|
||||
|
||||
public class InvokeServiceHttpNonDaprEndpointExample : Example
|
||||
{
|
||||
public class InvokeServiceHttpNonDaprEndpointExample : Example
|
||||
public override string DisplayName => "Invoke a non Dapr endpoint using DaprClient";
|
||||
|
||||
public override async Task RunAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
public override string DisplayName => "Invoke a non Dapr endpoint using DaprClient";
|
||||
|
||||
public override async Task RunAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
using var client = new DaprClientBuilder().Build();
|
||||
using var client = new DaprClientBuilder().Build();
|
||||
|
||||
// Invoke a POST method named "deposit" that takes input of type "Transaction" as defined in the RoutingSample.
|
||||
Console.WriteLine("Invoking deposit using non Dapr endpoint.");
|
||||
var data = new { id = "17", amount = 99m };
|
||||
var account = await client.InvokeMethodAsync<object, Account>("http://localhost:5000", "deposit", data, cancellationToken);
|
||||
Console.WriteLine("Returned: id:{0} | Balance:{1}", account.Id, account.Balance);
|
||||
// Invoke a POST method named "deposit" that takes input of type "Transaction" as defined in the RoutingSample.
|
||||
Console.WriteLine("Invoking deposit using non Dapr endpoint.");
|
||||
var data = new { id = "17", amount = 99m };
|
||||
var account = await client.InvokeMethodAsync<object, Account>("http://localhost:5000", "deposit", data, cancellationToken);
|
||||
Console.WriteLine("Returned: id:{0} | Balance:{1}", account.Id, account.Balance);
|
||||
|
||||
// Invokes a POST method named "Withdraw" that takes input of type "Transaction" as defined in the RoutingSample.
|
||||
Console.WriteLine("Invoking withdraw using non Dapr endpoint.");
|
||||
data = new { id = "17", amount = 10m, };
|
||||
await client.InvokeMethodAsync<object>("http://localhost:5000", "withdraw", data, cancellationToken);
|
||||
Console.WriteLine("Completed");
|
||||
// Invokes a POST method named "Withdraw" that takes input of type "Transaction" as defined in the RoutingSample.
|
||||
Console.WriteLine("Invoking withdraw using non Dapr endpoint.");
|
||||
data = new { id = "17", amount = 10m, };
|
||||
await client.InvokeMethodAsync<object>("http://localhost:5000", "withdraw", data, cancellationToken);
|
||||
Console.WriteLine("Completed");
|
||||
|
||||
// Invokes a GET method named "hello" that takes input of type "MyData" and returns a string.
|
||||
Console.WriteLine("Invoking balance using non Dapr endpoint.");
|
||||
account = await client.InvokeMethodAsync<Account>(HttpMethod.Get, "http://localhost:5000", "17", cancellationToken);
|
||||
Console.WriteLine($"Received balance {account.Balance}");
|
||||
}
|
||||
|
||||
internal class Transaction
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
|
||||
public decimal Amount { get; set; }
|
||||
}
|
||||
|
||||
internal class Account
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
|
||||
public decimal Balance { get; set; }
|
||||
}
|
||||
// Invokes a GET method named "hello" that takes input of type "MyData" and returns a string.
|
||||
Console.WriteLine("Invoking balance using non Dapr endpoint.");
|
||||
account = await client.InvokeMethodAsync<Account>(HttpMethod.Get, "http://localhost:5000", "17", cancellationToken);
|
||||
Console.WriteLine($"Received balance {account.Balance}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal class Transaction
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
|
||||
public decimal Amount { get; set; }
|
||||
}
|
||||
|
||||
internal class Account
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
|
||||
public decimal Balance { get; set; }
|
||||
}
|
||||
}
|
|
@ -15,24 +15,24 @@ using System;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Samples.Client
|
||||
namespace Samples.Client;
|
||||
|
||||
class Program
|
||||
{
|
||||
class Program
|
||||
{
|
||||
private static readonly Example[] Examples = new Example[]
|
||||
{
|
||||
new InvokeServiceGrpcExample(),
|
||||
new InvokeServiceHttpExample(),
|
||||
new InvokeServiceHttpClientExample(),
|
||||
new InvokeServiceHttpNonDaprEndpointExample()
|
||||
};
|
||||
private static readonly Example[] Examples =
|
||||
[
|
||||
new InvokeServiceGrpcExample(),
|
||||
new InvokeServiceHttpExample(),
|
||||
new InvokeServiceHttpClientExample(),
|
||||
new InvokeServiceHttpNonDaprEndpointExample()
|
||||
];
|
||||
|
||||
static async Task<int> Main(string[] args)
|
||||
{
|
||||
if (args.Length > 0 && int.TryParse(args[0], out var index) && index >= 0 && index < Examples.Length)
|
||||
{
|
||||
var cts = new CancellationTokenSource();
|
||||
Console.CancelKeyPress += (object? sender, ConsoleCancelEventArgs e) => cts.Cancel();
|
||||
Console.CancelKeyPress += (sender, e) => cts.Cancel();
|
||||
|
||||
await Examples[index].RunAsync(cts.Token);
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue