XCardLibrary SetFullCardFilePathAndAddCardId(XCardLibrary cardLib, string basepath) { var fixedFilesWithCardSchema = new List <string>(); var ids = new List <Guid>(); foreach (var file in cardLib.FilesWithCardSchema) { string fullPath = Path.Combine(basepath, file); fixedFilesWithCardSchema.Add(fullPath); var cardInfo = Deserialize <XCardOnlyId>(fullPath); ids.Add(cardInfo.ID); } cardLib.FilesWithCardSchema = fixedFilesWithCardSchema.ToArray(); cardLib.CardsID = ids.ToArray(); return(cardLib); }
public JCardLib ConvertCardLib(XCardLibrary cardLib, ParentObjectInfo parentInfo) { if (cardLib.ID == null) { throw new Exception("Объект cardLib не может быть преобразован в JCardLib"); } if (string.IsNullOrEmpty(cardLib.Version)) { throw new Exception("В библиотеке карточек " + cardLib.Alias + " отсутствует версия"); } if (cardLib.CardsID == null || cardLib.CardsID.Any() == false) { throw new Exception("В библиотеке карточек " + cardLib.Alias + " отсутствуют карточки"); } var version = new JCardLibVersion { SystemVersion = parentInfo.SystemVersion, Version = cardLib.Version, Cards = cardLib.CardsID }; var jCardLib = new JCardLib { ID = cardLib.ID, Alias = cardLib.Alias, Name = GetRuName(cardLib.Names), Versions = new List <JCardLibVersion> { version } }; return(jCardLib); }