Esempio n. 1
0
 async void UpdateDescription()
 {
     try
     {
         var link = SelectedEngine?.RootLink;
         if (SelectedEngine?.EngineId != cachedEngineId)
         {
             cachedEngineId = SelectedEngine?.EngineId;
             if (link != null)
             {
                 references = await ServiceLocator.Current.GetServiceOrThrow<IStorageService>().ThreadData.LoadBoardReferences(link);
             }
             else
             {
                 references = null;
             }
         }
     }
     catch
     {
         references = null;
     }
     if (string.IsNullOrWhiteSpace(ShortName))
     {
         Description = "";
     }
     else
     {
         var sn = ShortName.Trim();
         var lts = ServiceLocator.Current.GetServiceOrThrow<ILinkTransformService>();
         var board = (references?.References ?? new List<BoardReference>()).FirstOrDefault(b => sn.Equals(lts.GetBoardShortName(b.Link), StringComparison.OrdinalIgnoreCase));
         if (board != null)
         {
             Description = board.DisplayName;
         }
         else
         {
             Description = null;
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Сохранить ссылки на борды.
 /// </summary>
 /// <param name="data">Данные.</param>
 /// <returns>Таск.</returns>
 public async Task SaveBoardReferences(BoardReferences data)
 {
     var linkHash = Services.GetServiceOrThrow<ILinkHashService>();
     var hash = linkHash.GetLinkHash(data.RootLink);
     var folder = await GetBoardReferencesFolder();
     var fileName = string.Format("{0}.dat", hash);
     var file = await folder.CreateFileAsync(fileName, CreationCollisionOption.OpenIfExists);
     await WriteXmlObject(file, folder, data, true);
     boardReferenceses[hash] = data;
 }