public override int GetHashCode() { unchecked { return(((AlternateName != null ? AlternateName.GetHashCode() : 0) * 397) ^ (OpGgUrlLink != null ? OpGgUrlLink.GetHashCode() : 0)); } }
private void OKBtn_Click(object sender, EventArgs e) { try { if (UseAlternateName.Checked && AlternateName.Text.Trim().Length == 0) { MessageBox.Show(this, Strings.AlternateNameMissing, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); AlternateName.Focus(); return; } if (UseHeader.Checked && !System.IO.File.Exists(HeaderPath.Text)) { MessageBox.Show(this, Strings.HeaderFileMissing, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); HeaderPath.Focus(); return; } if (!System.IO.File.Exists(ContentPath.Text)) { MessageBox.Show(this, Strings.ContentFileMissing, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); ContentPath.Focus(); return; } } catch (Exception ex) { string msg = NestedExceptionMessageProcessor.GetFullMessage(ex); MessageBox.Show(this, string.Format(Strings.FilenameValidationError, msg), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.DialogResult = DialogResult.OK; this.Close(); }
public IEnumerable <AlternateName> AlternateNames() { if (xml == null) { yield break; } XmlNodeList nodes = xml.SelectNodes("alternateName"); if (nodes == null) { yield break; } foreach (XmlElement node in nodes) { AlternateName a = new AlternateName(); if (node.HasAttribute("isShortName")) { a.IsShortName = Convert.ToBoolean(node.GetAttribute("isShortName")); } if (node.HasAttribute("isPreferredName")) { a.IsPreferredName = Convert.ToBoolean(node.GetAttribute("isPreferredName")); } if (node.HasAttribute("lang")) { a.Language = node.GetAttribute("lang"); a.Name = node.InnerText; } yield return(a); } }
public override int GetHashCode() { return(AlternateNameType.GetHashCode() ^ AlternateName.GetHashCode()); }
public static void AttachDatabase(this MangaObject value, DatabaseObject databaseObject, Boolean databaseAsMaster = false, Boolean preferDatabaseDescription = false) { if (databaseAsMaster) { if (!String.IsNullOrWhiteSpace(value.Name) && !value.AlternateNames.Any(o => o.ToLower() == value.Name.ToLower())) { value.AlternateNames.Add(value.Name); } value.Name = databaseObject.Name; } else if (!String.IsNullOrWhiteSpace(databaseObject.Name) && !value.AlternateNames.Any(o => o.ToLower() == databaseObject.Name.ToLower())) { value.AlternateNames.Add(databaseObject.Name); } // AlternateNames foreach (String AlternateName in databaseObject.AlternateNames) { if (!String.IsNullOrWhiteSpace(AlternateName) && !value.AlternateNames.Any(o => o.ToLower() == AlternateName.ToLower())) { value.AlternateNames.Add(AlternateName); } } // Description // Prefer database description if longer. if (databaseAsMaster || preferDatabaseDescription || String.IsNullOrWhiteSpace(value.Description) || value.Description.Length < databaseObject.Description.Length) { if (!String.IsNullOrWhiteSpace(databaseObject.Description)) { value.Description = databaseObject.Description; } } // Genres foreach (String Genre in databaseObject.Genres) { if (!String.IsNullOrWhiteSpace(Genre) && !value.Genres.Any(o => o.ToLower() == Genre.ToLower())) { value.Genres.Add(Genre); } } // DatabaseLocations // value.DatabaseLocations = databaseObject.Locations; foreach (LocationObject DatabaseLocation in databaseObject.Locations) { if (!value.DatabaseLocations.Any(o => o.ExtensionName == DatabaseLocation.ExtensionName)) { value.DatabaseLocations.Add(DatabaseLocation); } } // Covers foreach (LocationObject Cover in databaseObject.Covers) { if (!String.IsNullOrWhiteSpace(Cover.Url) && !value.CoverLocations.Any(o => Equals(o.Url, Cover.Url))) { value.CoverLocations.Insert(0, Cover); } } // Released if (value.Released.Equals(DateTime.MinValue) && databaseObject.ReleaseYear > 0) { value.Released = new DateTime(databaseObject.ReleaseYear, 1, 1); } }
public static void Merge(this MangaObject mangaObject, IEnumerable <MangaObject> list) { if (list.Count() > 0) { // Name if (String.IsNullOrWhiteSpace(mangaObject.Name)) { MangaObject FoD_Obj = list.FirstOrDefault(mO => !String.IsNullOrWhiteSpace(mO.Name)); if (FoD_Obj != null) { mangaObject.Name = FoD_Obj.Name; } } // Released if (mangaObject.Released.Equals(DateTime.MinValue)) { MangaObject FoD_Obj = list.FirstOrDefault(mO => mO.Released > DateTime.MinValue); if (FoD_Obj != null) { mangaObject.Released = FoD_Obj.Released; } } // Rating if (mangaObject.Rating < 0) { MangaObject FoD_Obj = list.FirstOrDefault(mO => mO.Rating >= 0); if (FoD_Obj != null) { mangaObject.Rating = FoD_Obj.Rating; } } // Description if (String.IsNullOrWhiteSpace(mangaObject.Description)) { MangaObject FoD_Obj = list.FirstOrDefault(mO => !String.IsNullOrWhiteSpace(mO.Description)); if (FoD_Obj != null) { mangaObject.Description = FoD_Obj.Description; } } // MangaType & PageFlowDirection if (mangaObject.MangaType == Enums.MangaObjectType.Unknown) { MangaObject FoD_Obj = list.FirstOrDefault(mO => mO.MangaType != Enums.MangaObjectType.Unknown); if (FoD_Obj != null) { mangaObject.MangaType = FoD_Obj.MangaType; mangaObject.PageFlowDirection = FoD_Obj.PageFlowDirection; } } // Locations foreach (List <LocationObject> Locations in (from MangaObject obj in list where obj != null select obj.Locations)) { foreach (LocationObject Location in Locations) { if (!mangaObject.Locations.Any(o => o.ExtensionName == Location.ExtensionName)) { mangaObject.Locations.Add(Location); } else { // Update existing location url Int32 idx = mangaObject.Locations.FindIndex(o => o.ExtensionName == Location.ExtensionName); mangaObject.Locations.RemoveAt(idx); mangaObject.Locations.Insert(idx, Location); } } } // DatabaseLocations foreach (List <LocationObject> DatabaseLocations in (from MangaObject obj in list where obj != null select obj.DatabaseLocations)) { foreach (LocationObject DatabaseLocation in DatabaseLocations) { if (!mangaObject.DatabaseLocations.Any(o => o.ExtensionName == DatabaseLocation.ExtensionName)) { mangaObject.DatabaseLocations.Add(DatabaseLocation); } } } // Artists foreach (List <String> Artists in (from MangaObject obj in list where obj != null select obj.Artists)) { foreach (String Artist in Artists) { if (Artist != null && !mangaObject.Artists.Any(o => o.ToLower() == Artist.ToLower())) { mangaObject.Artists.Add(Artist); } } } // Authors foreach (List <String> Authors in (from MangaObject obj in list where obj != null select obj.Authors)) { foreach (String Author in Authors) { if (Author != null && !mangaObject.Authors.Any(o => o.ToLower() == Author.ToLower())) { mangaObject.Authors.Add(Author); } } } // Covers foreach (List <LocationObject> Covers in (from MangaObject obj in list where obj != null select obj.CoverLocations)) { foreach (LocationObject Cover in Covers) { if (Cover != null && !mangaObject.CoverLocations.Any(o => Equals(o.Url, Cover.Url))) { mangaObject.CoverLocations.Add(Cover); } } } mangaObject.CoverLocations.RemoveAll(c => String.IsNullOrWhiteSpace(c.Url)); // AlternateNames foreach (String Name in (from MangaObject obj in list where obj != null select obj.Name)) { if (!mangaObject.AlternateNames.Any(o => o.ToLower() == Name.ToLower()) && Name != null) { mangaObject.AlternateNames.Add(Name); } } foreach (List <String> AlternateNames in (from MangaObject obj in list where obj != null select obj.AlternateNames)) { foreach (String AlternateName in AlternateNames) { if (AlternateName != null && !mangaObject.AlternateNames.Any(o => o.ToLower() == AlternateName.ToLower())) { mangaObject.AlternateNames.Add(AlternateName); } } } // Genres foreach (List <String> Genres in (from MangaObject obj in list where obj != null select obj.Genres)) { foreach (String Genre in Genres) { if (Genre != null && !mangaObject.Genres.Any(o => o.ToLower() == Genre.ToLower())) { mangaObject.Genres.Add(Genre); } } } // Chapters foreach (List <ChapterObject> Chapters in (from MangaObject obj in list where obj != null select obj.Chapters)) { foreach (ChapterObject Chapter in Chapters) { if (Chapter != null) { ChapterObject chapterObject = mangaObject.Chapters.FirstOrDefault(o => { if (!Int32.Equals(o.Chapter, Chapter.Chapter)) { return(false); } if (!Int32.Equals(o.SubChapter, Chapter.SubChapter)) { return(false); } return(true); }); if (ChapterObject.Equals(chapterObject, null)) { mangaObject.Chapters.Add(Chapter); } else { chapterObject.Merge(Chapter); } } } } mangaObject.SortChapters(); } }
public override int GetHashCode() { return(AlternateName.GetHashCode() ^ 387); }
/// <summary> /// Displays the results of a Denni Hlasatel death index search on a person's full name and death reporting date /// </summary> /// <param name="sender">originator of the event</param> /// <param name="e">additional details on the event</param>j /// <remarks>This method is used to display the results of the <see cref="mnuDenniHlasatelSearch_Click"/> event handler</remarks> void OnDhDocumentLoaded(object sender, WebBrowserDocumentCompletedEventArgs e) { string sInnerHtml = string.Empty, sLastFullName = string.Empty; foreach (IDeathRecord drNext in _denniHlasatelMatches) { string sCurrentFullName = drNext.FirstName + " " + drNext.LastName; if (sCurrentFullName != sLastFullName) { sInnerHtml += "<h1>" + sCurrentFullName + "</h1>"; if (_mdB != null) { var lAlternateNames = new List<AlternateName>(); List<GivenName> lGivenNames = GivenName.MatchToPlainTextName(drNext.FirstName, _mdB); Surname snPrimary = Surname.Get(drNext.LastName); List<Surname.NativeForm> lSurnames = snPrimary.AlternateForms; var qSurname = (from sn in _mdB.Prijmenis where sn.PlainText == drNext.LastName select sn.Web).ToList<string>(); if ((lGivenNames.Count > 0) || (qSurname.Count > 0)) { if (lGivenNames.Count < 1) lGivenNames.Add(GivenName.Get(drNext.FirstName)); if (qSurname.Count < 1) qSurname.Add(drNext.LastName); foreach (var gnNext in lGivenNames) { foreach (string sSurname in qSurname) { var altNext = new AlternateName(gnNext.Value, sSurname); lAlternateNames.Add(altNext); altNext.GivenNameCount = gnNext.MaleCount + gnNext.FemaleCount; } } } if (lAlternateNames.Count > 0) { sInnerHtml += "<h2>Alternate forms of the name:</h2>"; foreach (AlternateName altNext in lAlternateNames) { string sNext = altNext.GivenName + " " + altNext.Surname; if (altNext.GivenNameCount > 0) sNext += " (" + altNext.GivenNameCount + " individuals with this given name)"; sInnerHtml += sNext + "<br>"; } } if (lSurnames.Count > 1) { sInnerHtml = lSurnames.Aggregate("<h2>Alternate forms of the surname:</h2>", (current, nfNext) => current + (nfNext.Web + ", ")); sInnerHtml += "<br>"; } } sInnerHtml += "<h2>Records:</h2>"; } sLastFullName = sCurrentFullName; sInnerHtml += "<a target=\"_blank\" href=\"" + IllinoisDeathIndexWebQuery.GetUrl(drNext) + "\">" + "#" + drNext.CertificateNumber + "</a>: " // sInnerHtml += "<a href=\"" + IllinoisDeathIndexWebQuery.GetUrl(drNext) + "\">" + "#" + drNext.CertificateNumber.ToString() + "</a>: " + Utilities.CzechDate( drNext.FilingDate ) + " (" + drNext.FilingDate.ToLongDateString() + ")<br>"; } // HtmlElement frame = webBrowser1.Document.GetElementsByTagName("iframe")[0]; try { var frame = webBrowser1.Document.Window.Frames["Display_Area"]; // frame.InnerHtml = sInnerHtml; // frame.InnerText = sInnerHtml; frame.Document.Body.InnerHtml = sInnerHtml; } catch (Exception ex ) { txtResponse.AppendText( "Exception when attempting to write to document frame. The HTML to be displayed is:" + Environment.NewLine + sInnerHtml + Environment.NewLine + "The exception text is:" + ex); } }
private void ConnectPage(IDomain domain, string goToPageName) { foreach (IPage Item in domain.Pages) { if (Item.Name == goToPageName) { GoToPage = Item; break; } } if (GoToPage == null && goToPageName == Page.CurrentPage.Name) { GoToPage = Page.CurrentPage; } else if (GoToPage == null && goToPageName == Page.PreviousPage.Name) { GoToPage = Page.PreviousPage; } else if (GoToPage != null) { GoToPage.SetIsReachable(); } else { string[] Splitted = goToPageName.Split(':'); string SplittedPrefix = Splitted.Length > 0 && Splitted[0].Length > 0 ? Splitted[0] : ""; string SplittedSuffix = Splitted.Length > 1 && Splitted[1].Length > 0 ? Splitted[1].Substring(Splitted[1].Length - 1) : ""; string AnyPagePrefix = Page.AnyPage.Name.Substring(0, Page.AnyPage.Name.Length - 1); string AnyPageSuffix = Page.AnyPage.Name.Substring(Page.AnyPage.Name.Length - 1); if (SplittedPrefix == AnyPagePrefix && SplittedSuffix == AnyPageSuffix) { GoToPage = Page.AnyPage; string[] AlternateNames = Splitted[1].Substring(0, Splitted[1].Length - 1).Split(';'); foreach (string AlternateName in AlternateNames) { string TrimmedAlternate = AlternateName.Trim(); IPage Alternate = null; foreach (IPage Item in domain.Pages) { if (Item.Name == TrimmedAlternate) { Alternate = Item; break; } } if (Alternate != null) { if (AlternatePages.Contains(Alternate)) { throw new ParsingException(222, NavigationSource.Source, $"Custom page destination '{TrimmedAlternate}' is repeated."); } Alternate.SetIsReachable(); AlternatePages.Add(Alternate); } else if (AlternateName == Page.CurrentPage.Name) { if (!AlternatePages.Contains(Page.CurrentPage)) { AlternatePages.Add(Page.CurrentPage); } } else if (AlternateName == Page.PreviousPage.Name) { if (!AlternatePages.Contains(Page.PreviousPage)) { AlternatePages.Add(Page.PreviousPage); } } else { throw new ParsingException(176, NavigationSource.Source, $"Unknown page name '{TrimmedAlternate}'."); } } if (AlternatePages.Count == 0) { throw new ParsingException(223, NavigationSource.Source, "A custom page must declare at least one destination page."); } } } if (BeforeObjectEvent != null) { BeforeObjectEvent.SetIsProvidingCustomPageName(NavigationSource, GoToPage == Page.AnyPage); } if (GoToPage == null) { throw new ParsingException(176, NavigationSource.Source, $"Unknown page name '{goToPageName}'."); } if (GoToPage == Page.AnyPage && (BeforeObject == null || BeforeObjectEvent == null)) { throw new ParsingException(177, NavigationSource.Source, "A custom page must be set with a 'before' event."); } }
public static DatabaseObject Merge(IEnumerable <DatabaseObject> list) { if (list == null || list.Count() == 0) { return(null); } DatabaseObject databaseObject = list.First(); if (list.Count() > 1) { databaseObject.ReleaseYear = (Int32)Math.Round((from DatabaseObject obj in list select obj.ReleaseYear).Average()); // Locations foreach (List <LocationObject> Locations in (from DatabaseObject obj in list.Skip(1) where obj != null select obj.Locations)) { foreach (LocationObject Location in Locations) { if (!databaseObject.Locations.Any(o => o.ExtensionName == Location.ExtensionName)) { databaseObject.Locations.Add(Location); } } } // Covers foreach (List <LocationObject> Covers in (from DatabaseObject obj in list.Skip(1) where obj != null select obj.Covers)) { foreach (LocationObject Cover in Covers) { if (!databaseObject.Covers.Any(o => o == Cover)) { databaseObject.Covers.Add(Cover); } } } // AlternateNames foreach (String Name in (from DatabaseObject obj in list.Skip(1) where obj != null select obj.Name)) { if (!databaseObject.AlternateNames.Any(o => o.ToLower() == Name.ToLower())) { databaseObject.AlternateNames.Add(Name); } } foreach (List <String> AlternateNames in (from DatabaseObject obj in list.Skip(1) select obj.AlternateNames)) { foreach (String AlternateName in AlternateNames) { if (!databaseObject.AlternateNames.Any(o => o.ToLower() == AlternateName.ToLower())) { databaseObject.AlternateNames.Add(AlternateName); } } } // Staff foreach (List <String> Staff in (from DatabaseObject obj in list.Skip(1) where obj != null select obj.Staff)) { foreach (String Person in Staff) { if (!databaseObject.Staff.Any(o => o.ToLower() == Person.ToLower())) { databaseObject.Staff.Add(Person); } } } // Genres foreach (List <String> Genres in (from DatabaseObject obj in list.Skip(1) where obj != null select obj.Genres)) { foreach (String Genre in Genres) { if (!databaseObject.Genres.Any(o => o.ToLower() == Genre.ToLower())) { databaseObject.Genres.Add(Genre); } } } } return(databaseObject); }