public static bool DataMatches(this ILicenseDetails me, ILicenseDetails other) { return(me != null && other != null && me.Id == other.Id && me.Issued == other.Issued && me.Expires == other.Expires && me.SubscriptionExpirationDate == other.SubscriptionExpirationDate && me.Pairs.All(pair => other.Get(pair.Key) == pair.Value)); }
/// <summary> /// Returns all valid license servers from the LicenseServers field /// </summary> /// <param name="details"></param> /// <returns></returns> public static IEnumerable <string> GetValidLicenseServers(this ILicenseDetails details) { return(details.Get("LicenseServers") ? .Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries) .Where(s => { Uri t; return Uri.TryCreate(s, UriKind.Absolute, out t) && t.Scheme == "https"; }) .Select(s => s.Trim()) ?? Enumerable.Empty <string>()); }
/// <summary> /// Enumerates any/all values from "Domain" and "Domains" field, trimming and lowercasing all values. /// </summary> /// <param name="details"></param> /// <returns></returns> public static IEnumerable <string> GetAllDomains(this ILicenseDetails details) { var domains = details.Get("Domains")?.Split(' ', '\t', ','); var domain = details.Get("Domain"); if (domain == null && domains == null) { return(Enumerable.Empty <string>()); } var list = new List <string>(1); if (domains != null) { list.AddRange(domains); } if (domain != null) { list.Add(domain); } return(list.Where(s => !IsNullOrWhiteSpace(s)).Select(s => s.Trim().ToLowerInvariant())); }
/// <summary> /// Enumerates the feature code list. No case changes are performed /// </summary> /// <param name="details"></param> /// <returns></returns> public static IEnumerable <string> GetFeatures(this ILicenseDetails details) => details?.Get("Features") ?.Split(new[] { ' ', '\t', ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(s => s.Trim()) .ToList() ?? Enumerable.Empty <string>();
public static string GetExpiryMessage(this ILicenseDetails details) => details?.Get("ExpiryMessage");
public static string GetRestrictions(this ILicenseDetails details) => details?.Get("Restrictions");
public static string GetSecret(this ILicenseDetails details) => details?.Get("Secret");
public static int?CheckLicenseIntervalMinutes(this ILicenseDetails details) => details?.Get("CheckLicenseIntervalMinutes").TryParseInt();
public static int?NetworkGraceMinutes(this ILicenseDetails details) => details?.Get("NetworkGraceMinutes").TryParseInt();
public static bool MustBeFetched(this ILicenseDetails details) => "true".Equals(details?.Get("MustBeFetched"), StringComparison.OrdinalIgnoreCase);
public static bool IsPublic(this ILicenseDetails details) => "true".Equals(details?.Get("IsPublic"), StringComparison.OrdinalIgnoreCase);
public static bool IsRevoked(this ILicenseDetails details) => "false".Equals(details?.Get("Valid"), StringComparison.OrdinalIgnoreCase);
public static bool IsRemotePlaceholder(this ILicenseDetails details) => "id".Equals(details?.Get("Kind"), StringComparison.OrdinalIgnoreCase);
public static string GetSecret(this ILicenseDetails details) { return(details.Get("Secret")); }