/// <summary> /// 装備を取得する /// </summary> /// <param name="iSearchString">餌名称(正規表現)</param> /// <returns>装備の一覧</returns> public List <GearDBGearModel> SelectGear(string iSearchString, GearDBPositionKind iPosition) { logger.Trace("SearchString={0}", iSearchString); List <GearDBGearModel> ret = new List <GearDBGearModel>(); GearDBModel gearDB = getGearDB(); if (iSearchString == string.Empty && iPosition == GearDBPositionKind.Unknown) { ret = gearDB.Gear; } else { foreach (GearDBGearModel gear in gearDB.Gear) { if ((iSearchString != string.Empty && iPosition != GearDBPositionKind.Unknown && MiscTool.IsRegexString(gear.GearName, iSearchString) && gear.Position == iPosition) || (iSearchString != string.Empty && iPosition == GearDBPositionKind.Unknown && MiscTool.IsRegexString(gear.GearName, iSearchString)) || (iSearchString == string.Empty && iPosition != GearDBPositionKind.Unknown && gear.Position == iPosition)) { ret.Add(gear); } } } ret.Sort(GearDBModel.SortTypeName); return(ret); }
/// <summary> /// Gear.xmlの内容を全て取得する /// </summary> /// <returns>GearDBModel</returns> private GearDBModel getGearDB() { try { string xmlFilename = PATH_FISHDB + @"\" + FILENAME_GEARDB; GearDBModel gearDB = new GearDBModel(); if (File.Exists(xmlFilename)) { FileStream fs = new FileStream(xmlFilename, System.IO.FileMode.Open); XmlSerializer serializer = new XmlSerializer(typeof(GearDBModel)); gearDB = (GearDBModel)serializer.Deserialize(fs); fs.Close(); } return(gearDB); } catch (Exception e) { logger.Fatal("{0}の取得中にエラーが発生しました。", FILENAME_GEARDB); throw e; } }