using WinRT.BxlComponent.Plugin.BxlMpXamarinSDK.Abstractions;
using System;

namespace WinRT.BxlComponent.Plugin.BxlMpXamarinSDK
{
    /// <summary>
    /// Cross platform BxlMpXamarinSDK implemenations
    /// </summary>
    internal class MPosDeviceFactory
    {
        static Lazy<IMPosDeviceFactory> Implementation
            = new Lazy<IMPosDeviceFactory>(() => CreateFactoryImpl(), System.Threading.LazyThreadSafetyMode.PublicationOnly);

        /// <summary>
        /// Current settings to use
        /// </summary>
        public static IMPosDeviceFactory Current
        {
            get
            {
                var ret = Implementation.Value;
                if (ret == null)
                {
                    throw NotImplementedInReferenceAssembly();
                }
                return ret;
            }
        }

        static IMPosDeviceFactory CreateFactoryImpl()
        {
#if PORTABLE
            return null;
#else
            return new MPosDeviceFactoryImplementation();
#endif
        }

        internal static Exception NotImplementedInReferenceAssembly()
        {
            return new NotImplementedException("This functionality is not implemented in the portable version of this assembly.  You should reference the NuGet package from your main application project in order to reference the platform-specific implementation.");
        }
    }
}
