public bool Equals(Make other) { return(other != null && Manufacturer.Equals(other.Manufacturer) && AlternativeNames.Equals(other.AlternativeNames) && Models.Equals(other.Models)); }
/// <summary> /// This is testing if given string is somewhere in the location's texts /// </summary> /// <param name="subString"></param> /// <returns>returns code of field, where substring was found. /// Zero (0) means substring was not found. /// 1 : string was found at the start of Name or AlternativeName /// 2 : string was found within Name /// 3 : string was found within Alternative Name</returns> public int ContainsSubstring(string subString) { if (CityName.StartsWith(subString, StringComparison.CurrentCultureIgnoreCase) || (ASCIIName != null && ASCIIName.StartsWith(subString, StringComparison.CurrentCultureIgnoreCase))) { return(1); } if (CityName.IndexOf(subString, 0, StringComparison.CurrentCultureIgnoreCase) >= 0 || (ASCIIName != null && ASCIIName.IndexOf(subString, 0, StringComparison.CurrentCultureIgnoreCase) >= 0)) { return(2); } int index = AlternativeNames.IndexOf(subString, 0, StringComparison.CurrentCultureIgnoreCase); if (index > 0) { return((AlternativeNames[index - 1] == ',') ? 1 : 3); } else if (index == 0) { return(1); } else { return(0); } }
public GamesController(UpdatableAppSettings settings, IgdbApi igdbApi) { this.settings = settings; this.igdbApi = igdbApi; games = new Games(igdbApi); alternativeNames = new AlternativeNames(igdbApi); }
public override string ToString() { var x = new StringBuilder(); x.Append($"[{PluginName}] "); if (!AlternativeNames.Contains(Host)) { x.Append($"{Host} "); } var num = AlternativeNames.Count(); x.Append($"[{num} binding"); if (num != 1) { x.Append($"s"); } if (num > 0) { x.Append($" - {AlternativeNames.First()}"); } if (num > 1) { x.Append($", ..."); } if (!string.IsNullOrWhiteSpace(WebRootPath)) { x.Append($" @ {WebRootPath}"); } x.Append("]"); return(x.ToString()); }
/// <summary>Checks another FieldProperties instance for equality.</summary> /// <param name="other">The FieldProperties to check for equality.</param> /// <returns>Returns true if the other instance equals this one, false otherwise.</returns> public bool Equals(IFieldProperties other) { if (other == null) { return(false); } // check name if ((other.Name != Name) && (other.NameAtDatabase != NameAtDatabase)) { var splitters = " ,;".ToCharArray(); if (AlternativeNames?.Split(splitters, StringSplitOptions.RemoveEmptyEntries).Any(n => (n == other.Name) || (n == other.NameAtDatabase)) == true) { return(true); } return(other.AlternativeNames?.Split(splitters, StringSplitOptions.RemoveEmptyEntries).Any(n => (n == Name) || (n == NameAtDatabase)) == true); } if ((other.FieldInfo != null) && (FieldInfo != null)) { // both typed, full match needed return(other.ValueType == ValueType); } if (DataType == other.DataType) { return(true); } Trace.WriteLine($"FieldProperties.Equals {this} != {other}"); return(false); }
public IgdbApi(UpdatableAppSettings settings) { this.settings = settings; requestLimiterHandler = TimeLimiter .GetFromMaxCountByInterval(4, TimeSpan.FromSeconds(1)) .AsDelegatingHandler(); HttpClient = new HttpClient(requestLimiterHandler); HttpClient.DefaultRequestHeaders.Add("Accept", "application/json"); CacheRoot = settings.Settings.IGDB.CacheDirectory; if (!Path.IsPathRooted(CacheRoot)) { CacheRoot = Path.Combine(Paths.ExecutingDirectory, CacheRoot); } Games = new Games(this); AlternativeNames = new AlternativeNames(this); InvolvedCompanies = new InvolvedCompanies(this); Genres = new Genres(this); Websites = new Websites(this); GameModes = new GameModes(this); PlayerPerspectives = new PlayerPerspectives(this); Covers = new Covers(this); Artworks = new Artworks(this); Screenshots = new Screenshots(this); AgeRatings = new AgeRatings(this); Collections = new Collections(this); }
public void TestNetworkAlternativeNames() { AlternativeNames names = Config.Client.GetNetworkAlternativeNamesAsync(IdHelper.AMC).Result; Assert.NotNull(names); Assert.Equal(IdHelper.AMC, names.Id); Assert.Equal("American Movie Classics", names.Results[0].Name); Assert.Equal("1984–2002", names.Results[0].Type); }
/// <summary> /// Gets the alternative names of a network given a TMDb id /// </summary> /// <param name="networkId">The TMDb id of the network</param> /// <param name="cancellationToken">A cancellation token</param> public async Task <AlternativeNames> GetNetworkAlternativeNamesAsync(int networkId, CancellationToken cancellationToken = default) { RestRequest req = _client.Create("network/{networkId}/alternative_names"); req.AddUrlSegment("networkId", networkId.ToString(CultureInfo.InvariantCulture)); AlternativeNames response = await req.GetOfT <AlternativeNames>(cancellationToken).ConfigureAwait(false); return(response); }
public override int GetHashCode() { unchecked { var result = 0; result = (result * 397) ^ Manufacturer.GetHashCode(); result = (result * 397) ^ AlternativeNames.GetHashCode(); result = (result * 397) ^ Models.GetHashCode(); return(result); } }
public override bool Equals(object obj) { var makeModel = obj as Make; if (makeModel == null) { return(false); } return(Manufacturer.Equals(makeModel.Manufacturer) && AlternativeNames.Equals(makeModel.AlternativeNames) && Models.Equals(makeModel.Models)); }
public List <string> GetHosts(bool unicode) { var hosts = new List <string>(); if (HostIsDns == true) { hosts.Add(Host); } if (AlternativeNames != null && AlternativeNames.Any()) { hosts.AddRange(AlternativeNames); } var exclude = new List <string>(); if (!string.IsNullOrEmpty(ExcludeBindings)) { exclude = ExcludeBindings.Split(',').Select(x => x.ToLower().Trim()).ToList(); } var filtered = hosts. Where(x => !string.IsNullOrWhiteSpace(x)). Distinct(). Except(exclude); if (unicode) { var idn = new IdnMapping(); filtered = filtered.Select(x => idn.GetUnicode(x)); } if (filtered.Count() == 0) { Program.Log.Error("No DNS identifiers found."); throw new Exception("No DNS identifiers found."); } else if (filtered.Count() > Settings.maxNames) { Program.Log.Error("Too many hosts for a single certificate. Let's Encrypt has a maximum of {maxNames}.", Settings.maxNames); throw new Exception($"Too many hosts for a single certificate. Let's Encrypt has a maximum of {Settings.maxNames}."); } return(filtered.ToList()); }
/// <summary> /// Parse unique DNS identifiers that the certificate should be /// created for, taking into account the list of exclusions, /// support for IDNs and the limits of Let's Encrypt /// </summary> /// <param name="unicode"></param> /// <returns></returns> public List <string> GetHosts(bool unicode, bool allowZero = false) { var hosts = new List <string>(); if (HostIsDns == true) { hosts.Add(Host); } if (AlternativeNames != null && AlternativeNames.Any()) { hosts.AddRange(AlternativeNames); } var exclude = GetExcludedHosts(); var filtered = hosts. Where(x => !string.IsNullOrWhiteSpace(x)). Distinct(). Except(exclude); if (unicode) { var idn = new IdnMapping(); filtered = filtered.Select(x => idn.GetUnicode(x)); } if (filtered.Count() == 0) { if (!allowZero) { _log.Error("No DNS identifiers found."); throw new Exception("No DNS identifiers found."); } } else if (filtered.Count() > Settings.maxNames) { _log.Error("Too many hosts for a single certificate. Let's Encrypt has a maximum of {maxNames}.", Settings.maxNames); throw new Exception($"Too many hosts for a single certificate. Let's Encrypt has a maximum of {Settings.maxNames}."); } return(filtered.ToList()); }
/// <summary> /// Pretty print information about the target /// </summary> /// <returns></returns> public override string ToString() { var x = new StringBuilder(); x.Append($"[{TargetPluginName}] "); if (!AlternativeNames.Contains(Host)) { x.Append($"{Host} "); } if ((TargetSiteId ?? 0) > 0) { x.Append($"(SiteId {TargetSiteId.Value}) "); } x.Append("["); var num = AlternativeNames.Count(); if (num > 0) { x.Append($"{num} binding"); if (num > 1) { x.Append($"s"); } x.Append($" - {AlternativeNames.First()}"); if (num > 1) { x.Append($", ..."); } } if (!string.IsNullOrWhiteSpace(WebRootPath)) { x.Append($" @ {WebRootPath.Trim()}"); } x.Append("]"); return(x.ToString()); }
public void AddAlternateName(string name) { AlternativeNames.Add(name); }
public string GetDescription() { return(string.Format("Set user with values - Name:{0}; Enabled: {1}; LocalLogonEnabled: {2}; HasAlternativeNames: {3}", Name, Enabled, LocalLogonEnabled, AlternativeNames.Any())); }
public async Task TestNetworkAlternativeNamesAsync() { AlternativeNames names = await TMDbClient.GetNetworkAlternativeNamesAsync(IdHelper.AMC); await Verify(names); }