1 /* 2 * "GEDKeeper", the personal genealogical database editor. 3 * Copyright (C) 2009-2021 by Sergey V. Zhdanovskih. 4 * 5 * This file is part of "GEDKeeper". 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 using System; 22 using GDModel.Providers.GEDCOM; 23 using GKCore.Types; 24 25 namespace GDModel 26 { 27 public sealed class GDMRepositoryRecord : GDMRecord 28 { 29 private GDMAddress fAddress; 30 private string fRepositoryName; 31 32 33 public GDMAddress Address 34 { 35 get { return fAddress; } 36 } 37 38 public string RepositoryName 39 { 40 get { return fRepositoryName; } 41 set { fRepositoryName = value; } 42 } 43 44 GDMRepositoryRecord(GDMTree tree)45 public GDMRepositoryRecord(GDMTree tree) : base(tree) 46 { 47 SetName(GEDCOMTagType.REPO); 48 49 fAddress = new GDMAddress(); 50 fRepositoryName = string.Empty; 51 } 52 TrimExcess()53 internal override void TrimExcess() 54 { 55 base.TrimExcess(); 56 57 fAddress.TrimExcess(); 58 } 59 Assign(GDMTag source)60 public override void Assign(GDMTag source) 61 { 62 GDMRepositoryRecord otherRepo = (source as GDMRepositoryRecord); 63 if (otherRepo == null) 64 throw new ArgumentException(@"Argument is null or wrong type", "source"); 65 66 base.Assign(otherRepo); 67 68 fAddress.Assign(otherRepo.fAddress); 69 fRepositoryName = otherRepo.fRepositoryName; 70 } 71 Clear()72 public override void Clear() 73 { 74 base.Clear(); 75 76 fAddress.Clear(); 77 fRepositoryName = string.Empty; 78 } 79 IsEmpty()80 public override bool IsEmpty() 81 { 82 return base.IsEmpty() && fAddress.IsEmpty() && string.IsNullOrEmpty(fRepositoryName); 83 } 84 85 // TODO: connect to use IsMatch(GDMTag tag, MatchParams matchParams)86 public override float IsMatch(GDMTag tag, MatchParams matchParams) 87 { 88 GDMRepositoryRecord otherRep = tag as GDMRepositoryRecord; 89 if (otherRep == null) return 0.0f; 90 91 float match = GetStrMatch(RepositoryName, otherRep.RepositoryName, matchParams); 92 return match; 93 } 94 ReplaceXRefs(GDMXRefReplacer map)95 public override void ReplaceXRefs(GDMXRefReplacer map) 96 { 97 base.ReplaceXRefs(map); 98 fAddress.ReplaceXRefs(map); 99 } 100 } 101 } 102