I took one of the example programs provided and translated into Oxygene with Oxydizer.
Here is the C# program that works:
using System;
using System.Threading.Tasks;
using GoApi;
using GoApi.Core;
using GoApi.Core.Global;
namespace AuthorizationDemo
{
internal class Program
{
// Main method for C# 7.1 and above
public static async Task Main(string[] args)
{
await RunDemo();
}
//// Main method for C# 7.0 and below. Be careful with Wait, you can get deadlocks. It is highly recommended to update to C# 7.1 for console applications.
//// To change the C# version, open the project properties, go to Build, then click the Advanced button in the bottom right, and select your C# version.
//// If you can't find an appropriate C# version you may need to update your Visual Studio.
//public static void Main(string[] args)
//{
// RunDemo().Wait();
//}
/// <summary>
/// The purpose of this demo is to test if the PowerOffice Go Authentication server will allow us
/// to be authorized to access the PowerOffice GO API.
/// </summary>
private static async Task RunDemo()
{
try
{
// Create authorization settings for the test client
Console.WriteLine("Setting up authorization settings..");
// Set up authorization settings
var authorizationSettings = new AuthorizationSettings
{
ApplicationKey = "",
ClientKey = "",
TokenStore = new BasicTokenStore(@"my.tokenstore"),
EndPointHost = Settings.EndPointMode.Production
};
// Request authorization from the PowerOffice GO authentication server
Console.WriteLine("Requesting authorization..");
var api = await Go.CreateAsync(authorizationSettings);
// If no exceptions is thrown by now, we have sucessfully been authorized to access the PowerOffice GO API
Console.WriteLine("Authorization granted!");
}
catch (ApiException e)
{
Console.WriteLine("Error: " + e.Message);
}
// Wait for user input
Console.WriteLine("\n\nPress any key...");
Console.ReadKey();
}
}
}
Here is the Oxygene program that don’t work:
namespace ConsoleApplication1;
interface
uses
System,
System.Threading.Tasks,
GoApi,
GoApi.Core,
GoApi.Core.Global;
type
Program = assembly class
private
class method RunDemo: Task;
public
// Main method for C# 7.1 and above
class method Main(args: array of String): Task;
end;
implementation
class method Program.Main(args: array of String): Task;
begin
await RunDemo();
//RunDemo.Wait;
end;
class method Program.RunDemo: Task;
begin
try
// Create authorization settings for the test client
Console.WriteLine(‘Setting up authorization settings…’);
// Set up authorization settings
var authorizationSettings := new AuthorizationSettings(
ApplicationKey := ’ ',
ClientKey := ’ ',
TokenStore := new BasicTokenStore(‘my.tokenstore’),
EndPointHost := Settings.EndPointMode.Production);
// Request authorization from the PowerOffice GO authentication server
Console.WriteLine('Requesting authorization..');
var api := await Go.CreateAsync(authorizationSettings);
// If no exceptions is thrown by now, we have sucessfully been authorized to access the PowerOffice GO API
Console.WriteLine('Authorization granted!');
except
on e: ApiException do begin
Console.WriteLine(‘Error: ’ + e.Message);
end;
end;
// Wait for user input
Console.WriteLine(#10#10’Press any key…’);
Console.ReadKey();
end;
end.
Is there someone who can spot the error in the Oxygene-code?
And is Oxygene at the level of C# 7.1 or is it below?
Best regards
Geir Harald Humstad