using System; using System.Linq; using System.Reflection; using Aspose.Gis; namespace GitConverter.Lib.Licensing { /// /// Embedded-only Aspose.GIS license loader. /// - Attempts to load Aspose.Total.Net.lic embedded into the GitConverter.Lib assembly. /// - Methods are best-effort: return true on success, false on failure and do not throw. /// public static class AsposeLicenseManager { private const string LicenseFileName = "Aspose.Total.Net.lic"; /// /// Apply embedded license only. Returns true when an embedded license was found and applied. /// public static bool ApplyLicense() { return ApplyLicenseFromEmbeddedResource(); } private static bool ApplyLicenseFromEmbeddedResource() { try { // Use the library assembly (this assembly) to locate the embedded resource reliably. var asm = typeof(AsposeLicenseManager).GetTypeInfo().Assembly; var resourceName = asm.GetManifestResourceNames() .FirstOrDefault(n => n.EndsWith(LicenseFileName, StringComparison.OrdinalIgnoreCase)); if (string.IsNullOrEmpty(resourceName)) return false; using (var s = asm.GetManifestResourceStream(resourceName)) { if (s == null) return false; var license = new License(); license.SetLicense(s); return true; } } catch { // Best-effort only: swallow exceptions and return false. return false; } } } }