コード例 #1
0
        public async Task <bool> Export()
        {
            await Task.Run(() =>
            {
                fs.Write(new byte[len_header], 0, len_header);
                if (header.H_ENCRYPTED)
                {
                    fs.Write(lve.ToBytes(len_verified).XorCrypt(magic), 0, len_verified);
                }
                for (int i = 0; i < Resources.Count;)
                {
                    _writeHeader(Resources[i], ref i);
                    Resources[i - 1] = null;
                    OnSingleEndpointReached?.Invoke();
                }
                Resources.Clear();
                fs.Seek(0, SeekOrigin.Begin);
                fs.Write(header.ToBytes(len_header), 0, len_header);
                OnEndpointReached?.Invoke(Resources.Count);
            });

            fs.Flush();
            fs.Close();
            return(true);
        }
コード例 #2
0
 public async Task <LrssResource> ReadResource(LrssIndex li)
 {
     return(await Task.Run(() =>
     {
         try
         {
             return new LrssResource(li.Size, li.Name, li.Type)
             {
                 Data = GetContent(li.Size, li.Address, li.Occupied)
             };
         }
         catch (Exception)
         {
             return null;
         }
         finally
         {
             OnEndpointReached?.Invoke(li.Occupied);
         }
     }));
 }