protected static string?LoadInternalResourceAsString(string?resourceName, Assembly?assembly = null)
        {
            // Getting the calling assembly if it is not passed to this method must be done directly here and not in another method of this assembly, as the calling assembly would then the current one.
            if (assembly == null)
            {
                assembly = Assembly.GetCallingAssembly();
            }

            try
            {
                using var stream = AgLinkPlcEmbeddedRequirementsHelper.LoadInternalResourceAsStream(resourceName, assembly);

                //  Either the file does not exist or it is not marked as embedded resource.
                if (stream == null)
                {
                    return(null);
                }

                //  Get byte array from the file from embedded resource.
                using var reader = new System.IO.StreamReader(stream, System.Text.Encoding.UTF8);
                var content = reader.ReadToEnd();
                return(content);
            }
            catch (Exception ex)
            {
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    System.Diagnostics.Debugger.Break();
                }
                return(null);
            }
        }
        /// <summary>
        /// Loads the embedded error file.
        /// </summary>
        /// <returns> The error file as single string or null. </returns>
        internal static string?LoadErrorMapping()
        {
            var currentAssembly  = DemoAgLinkPlcEmbeddedRequirementsHelper.CurrentAssembly;
            var resourceNames    = DemoAgLinkPlcEmbeddedRequirementsHelper.ResourceNames;
            var errorFileName    = "AGLink40_Error.txt";
            var resourceName     = resourceNames.FirstOrDefault(name => name.ToLower().Contains(errorFileName.ToLower()));
            var errorFileContent = AgLinkPlcEmbeddedRequirementsHelper.LoadInternalResourceAsString(resourceName, currentAssembly);

            return(errorFileContent);
        }
        /// <summary>
        /// Loads the embedded license key.
        /// </summary>
        /// <returns> The license key or null. </returns>
        internal static string?LoadLicenseKey()
        {
            var currentAssembly = DemoAgLinkPlcEmbeddedRequirementsHelper.CurrentAssembly;
            var resourceNames   = DemoAgLinkPlcEmbeddedRequirementsHelper.ResourceNames;
            var licenseFileName = "AGLink.license";
            var resourceName    = resourceNames.FirstOrDefault(name => name.ToLower().Contains(licenseFileName.ToLower()));
            var licenseKey      = AgLinkPlcEmbeddedRequirementsHelper.LoadInternalResourceAsString(resourceName, currentAssembly);

            return(licenseKey);
        }
        /// <summary>
        /// Loads the embedded unmanaged assembly.
        /// </summary>
        /// <param name="is64BitProcess"> Optional boolean if the 64-bit version of the unmanaged assembly should be loaded. By default this is determined by <see cref="Environment.Is64BitProcess"/>. </param>
        /// <returns> The file name of the unmanaged assembly and its content as a <see cref="Stream"/> reset to <see cref="SeekOrigin.Begin"/>. This stream is not closed and needs to be disposed! </returns>
        internal static (string FileName, Stream?ResourceStream) LoadUnmanagedAssembly(bool?is64BitProcess = null)
        {
            is64BitProcess ??= Environment.Is64BitProcess;
            var currentAssembly           = DemoAgLinkPlcEmbeddedRequirementsHelper.CurrentAssembly;
            var resourceNames             = DemoAgLinkPlcEmbeddedRequirementsHelper.ResourceNames;
            var unmanagedAssemblyFileName = $"AGLink40{(is64BitProcess.Value ? "_x64" : "")}.dll";
            var resourceName   = resourceNames.FirstOrDefault(name => name.ToLower().Contains(unmanagedAssemblyFileName.ToLower()));
            var resourceStream = AgLinkPlcEmbeddedRequirementsHelper.LoadInternalResourceAsStream(resourceName, currentAssembly);

            if (resourceStream?.CanSeek ?? false)
            {
                resourceStream.Seek(0, SeekOrigin.Begin);
            }
            return(unmanagedAssemblyFileName, resourceStream);
        }
 static DemoAgLinkPlcEmbeddedRequirementsHelper()
 {
     CurrentAssembly = Assembly.GetExecutingAssembly();
     ResourceNames   = AgLinkPlcEmbeddedRequirementsHelper.GetAlResourceNames(CurrentAssembly);
 }