unit MathServiceImplementation;

interface

uses
  XData.Server.Module,
  XData.Service.Common,
  MathService;

type
  [ServiceImplementation]
  TArithmeticService = class(TInterfacedObject, IArithmeticService)
  public
    function Add(A, B: Double): Double;
    function Subtract(A, B: Double): Double;
    function Power(Base, Exponent: Double): Double;
    function NotThisFunctionPlease: Integer;
  end;

  [ServiceImplementation]
  TTrigonometryService = class(TInterfacedObject, ITrigonometryService)
  public
    function Sin(Angle: Double): Double;
    function Cos(Angle: Double): Double;
  end;

implementation

uses
  System.Math;

{ TMathService }

function TArithmeticService.Add(A, B: Double): Double;
begin
  Result := A + B;
end;

function TArithmeticService.NotThisFunctionPlease: Integer;
begin
  Result := -1;
end;

function TArithmeticService.Power(Base, Exponent: Double): Double;
begin
  Result := System.Math.Power(Base, Exponent);
end;

function TArithmeticService.Subtract(A, B: Double): Double;
begin
  Result := A - B;
end;

{ TTrigonometryService }

function TTrigonometryService.Cos(Angle: Double): Double;
begin
  Result := System.Cos(Angle);
end;

function TTrigonometryService.Sin(Angle: Double): Double;
begin
  Result := System.Sin(Angle);
end;

initialization
  RegisterServiceType(TArithmeticService);
  RegisterServiceType(TTrigonometryService);

end.
