using ComPDFKit.NativeMethod;
using System;
using System.Xml;

public static class SDKLicenseHelper
{
    public static string key = string.Empty;
    public static string secret = string.Empty; 

    public static bool LicenseVerify()
    {
        string sdkLicensePath = "license_key_windows.xml";
        XmlDocument xmlDocument = new XmlDocument();
        xmlDocument.Load(sdkLicensePath);

        XmlNode keyNode = xmlDocument.SelectSingleNode("/license/key");
        XmlNode secretNode = xmlDocument.SelectSingleNode("/license/secret");

        if (keyNode != null && secretNode != null)
        {
            key = keyNode.InnerText;
            secret = secretNode.InnerText;

        }
        else
        {
            Console.WriteLine("Key or secret element not found in the XML.");
        }
        bool result = CPDFSDKVerifier.LoadNativeLibrary();
        if (!result)
            return false;

        LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(key, secret);
        if (verifyResult != LicenseErrorCode.LICENSE_ERR_SUCCESS)
            return false;
        return result;
    }
}
