using System.Collections.Generic;

namespace com.itac.mes.imsapi.client.dotnet
{
    /// <summary>
    /// Legacy compatibility base class from IMSApiDotNet 10.0.0-3.
    /// Literal constants remain available for source compatibility; the class itself
    /// is also retained because IMSApiDotNetBase inherited from it in the old DLL.
    /// </summary>
    public class IMSApiDotNetConstants
    {
        public const int RES_OK = 0;
        public const int IMSAPI_NOT_INITIALIZED = -10301;
        public const int IMSAPI_INITIALIZED_ALREADY = -10302;
        public const int IMSAPI_LOCATOR_INIT_FAILED = -10303;
        public const int IMSAPI_LOOKUP_FAILED = -10304;
        public const int IMSAPI_REMOTE_SERVER_CALL_FAILED = -10305;

        private readonly Dictionary<int,string> errorDescriptions = new Dictionary<int,string>
        {
            { IMSAPI_NOT_INITIALIZED, "imsapi is not initialized" },
            { IMSAPI_INITIALIZED_ALREADY, "imsapi is initialized already" },
            { IMSAPI_LOCATOR_INIT_FAILED, "locator init failed" },
            { IMSAPI_LOOKUP_FAILED, "lookup for imsapi failed" },
            { IMSAPI_REMOTE_SERVER_CALL_FAILED, "remote server call failed" }
        };

        public string getIMSApiDotNetErrorText(int result)
        {
            string text;
            return errorDescriptions.TryGetValue(result, out text)
                ? text
                : "no error text found for " + result;
        }
    }
}
