/// <summary> /// (search.merge) /// </summary> /// <param name="query"></param> /// <returns>catalogs contains song, album, artist</returns> public async override Task <CatalogContent> GetCatalogAsync(string query, int pageNumber = 1, int?pageSize = default(int?)) { return(await this.GetResponse(new CatalogContent(), SearchMethod.Merge(query, pageNumber, pageSize), (o) => { ContentConverter.Convert(o, (merge)JsonConvert.DeserializeObject(o.Value, typeof(merge))); })); }
/// <summary> /// gedaninfo /// </summary> /// <param name="listid"></param> /// <returns></returns> public async override Task <SongListInfoContent> GedanInfoAsync(string listid) { return(await this.GetResponse(new SongListInfoContent(), DiyMethod.GedanInfo(listid), (o) => { ContentConverter.Convert(o, (gedanInfo)JsonConvert.DeserializeObject(o.Value, typeof(gedanInfo))); })); }
private static string convertDocomoMailto(string s) { string s1 = s; char ch = '\n'; return(ContentConverter.replaceString(ContentConverter.replaceString(ContentConverter.replaceString(ContentConverter.removeString(ContentConverter.removeString(s1, "MATMSG:"), ";"), "TO:", "MAILTO:"), "SUB:", (string)(object)ch + (object)"SUBJECT:"), "BODY:", (string)(object)ch + (object)"BODY:") + (object)ch); }
public Task Upload(Tag tag, CommentContent comment, DigitalSignature digitalSignature, TimeSpan miningTime, CancellationToken token) { if (tag == null) { throw new ArgumentNullException(nameof(tag)); } if (comment == null) { throw new ArgumentNullException(nameof(comment)); } if (digitalSignature == null) { throw new ArgumentNullException(nameof(digitalSignature)); } return(_coreManager.VolatileSetStream(ContentConverter.ToStream(comment, 0), TimeSpan.FromDays(360), token) .ContinueWith(task => { MulticastClue MulticastClue; try { var miner = new Miner(CashAlgorithm.Version1, -1, miningTime); MulticastClue = new MulticastClue("ChatMessage", tag, DateTime.UtcNow, task.Result, digitalSignature, miner, token); } catch (MinerException) { return; } _coreManager.UploadMetadata(MulticastClue); })); }
public async override Task <SongListContent> GedanAsync(int pageNumber, int?pageSize = 30) { return(await this.GetResponse(new SongListContent(), DiyMethod.Gedan(pageNumber, pageSize), (o) => { ContentConverter.Convert(o, (gedan)JsonConvert.DeserializeObject(o.Value, typeof(gedan))); })); }
private static string convertDocomoBookmark(string targetString) { targetString = ContentConverter.removeString(targetString, "MEBKM:"); targetString = ContentConverter.removeString(targetString, "TITLE:"); targetString = ContentConverter.removeString(targetString, ";"); targetString = ContentConverter.removeString(targetString, "URL:"); return(targetString); }
public BlogReader(IFileSystem fileSystem, ContentParser parser, ContentConverter converter, ContentProcessor processor) { _fileSystem = fileSystem; _parser = parser; _converter = converter; _processor = processor; }
/// <summary> /// get infos async /// </summary> /// <param name="songId"></param> /// <returns>content</returns> public async override Task <SongInfoContent> GetInfosAsync(string songId) { return(await this.GetResponse(new SongInfoContent(), SongMethod.GetInfos(songId), (o) => { if (o.HasError) { return; } ContentConverter.Convert(o, (getinfos)JsonConvert.DeserializeObject(o.Value, typeof(getinfos))); })); }
private static string convertDocomoAddressBook(string targetString) { targetString = ContentConverter.removeString(targetString, "MECARD:"); targetString = ContentConverter.removeString(targetString, ";"); targetString = ContentConverter.replaceString(targetString, "N:", "NAME1:"); targetString = ContentConverter.replaceString(targetString, "SOUND:", (string)(object)ContentConverter.n + (object)"NAME2:"); targetString = ContentConverter.replaceString(targetString, "TEL:", (string)(object)ContentConverter.n + (object)"TEL1:"); targetString = ContentConverter.replaceString(targetString, "EMAIL:", (string)(object)ContentConverter.n + (object)"MAIL1:"); targetString += (string)(object)ContentConverter.n; return(targetString); }
private void CompileFile(ContentConverter converter, string originalFile) { string xnbFile = Path.ChangeExtension(originalFile, "xnb"); #if !DEBUG if (File.Exists(xnbFile) && File.GetLastWriteTimeUtc(xnbFile) > File.GetLastWriteTimeUtc(originalFile)) { return; } #endif Console.WriteLine($"\nConverting: { originalFile }"); try { string directory = Path.GetDirectoryName(originalFile); object description = converter.Importer.Import(originalFile, contentImporterContext); object content = converter.Processor.Process(description, contentProcessorContext); using (FileStream fs = new FileStream(xnbFile, FileMode.Create)) compileMethod.Invoke( contentCompiler, new object[] { fs, content, contentProcessorContext.TargetPlatform, contentProcessorContext.TargetProfile, converter.Compress, directory, directory } ); } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; if (e is InvalidContentException ex) { converter.LogError(originalFile, ex); } else { Console.WriteLine($"{ originalFile }: error: { e.Message }"); } Console.ResetColor(); } }
private static ReadOnlyDictionary <string, ContentConverter> GetConverters() { IDictionary <string, ContentConverter> converters = new Dictionary <string, ContentConverter>(); foreach (Type converterType in Assembly.GetExecutingAssembly().GetTypes().Where(x => !x.IsAbstract && x.IsSubclassOf(typeof(ContentConverter)))) { ContentConverter converter = (ContentConverter)Activator.CreateInstance(converterType); foreach (string extension in converter.Extensions.Split('|')) { converters.Add(converter.Extensions, converter); } } return(new ReadOnlyDictionary <string, ContentConverter>(converters)); }
public Task <BroadcastProfileMessage> GetProfile(Signature signature, DateTime?creationTimeLowerLimit) { if (signature == null) { throw new ArgumentNullException(nameof(signature)); } var BroadcastClue = _coreManager.GetBroadcastClue(signature, "Profile"); if (BroadcastClue == null) { return(Task.FromResult <BroadcastProfileMessage>(null)); } if (creationTimeLowerLimit != null && BroadcastClue.CreationTime <= creationTimeLowerLimit) { return(Task.FromResult <BroadcastProfileMessage>(null)); } return(Task.Run(() => { try { var stream = _coreManager.VolatileGetStream(BroadcastClue.Metadata, 1024 * 1024 * 32); if (stream == null) { return null; } var content = ContentConverter.FromStream <ProfileContent>(stream, 0); if (content == null) { return null; } var result = new BroadcastProfileMessage( BroadcastClue.Certificate.GetSignature(), BroadcastClue.CreationTime, content); return result; } catch (Exception e) { Log.Error(e); } return null; })); }
public Task Upload(StoreContent store, DigitalSignature digitalSignature, CancellationToken token) { if (store == null) { throw new ArgumentNullException(nameof(store)); } if (digitalSignature == null) { throw new ArgumentNullException(nameof(digitalSignature)); } return(_coreManager.VolatileSetStream(ContentConverter.ToStream(store, 0), TimeSpan.FromDays(360), token) .ContinueWith(task => { _coreManager.UploadMetadata(new BroadcastClue("Store", DateTime.UtcNow, task.Result, digitalSignature)); })); }
public async Task <IActionResult> GetAsync([FromRoute] string id, CancellationToken cancellationToken) { if (id == null) { var error = ServiceErrorResponses.InvalidRouteParameter("DocumentId"); return(this.BadRequest(error)); } var modelContent = await contentRepository.GetAsync(id); if (modelContent == null) { var error = ServiceErrorResponses.NoSuchObject("Content", "Not content with such id " + id); return(this.NotFound(error)); } var clientContent = ContentConverter.Convert(modelContent); return(Ok(clientContent)); }
public Task Upload(Signature targetSignature, CommentContent comment, AgreementPublicKey agreementPublicKey, DigitalSignature digitalSignature, CancellationToken token) { if (targetSignature == null) { throw new ArgumentNullException(nameof(targetSignature)); } if (comment == null) { throw new ArgumentNullException(nameof(comment)); } if (digitalSignature == null) { throw new ArgumentNullException(nameof(digitalSignature)); } return(_coreManager.VolatileSetStream(ContentConverter.ToCryptoStream(comment, 1024 * 256, agreementPublicKey, 0), TimeSpan.FromDays(360), token) .ContinueWith(task => { _coreManager.UploadMetadata(new UnicastClue("MailMessage", targetSignature, DateTime.UtcNow, task.Result, digitalSignature)); })); }
public TopicReader( IFileSystem fileSystem, ContentParser contentParser, ContentConverter contentConverter, ContentProcessor contentProcessor) { if (fileSystem == null) { throw new ArgumentNullException(nameof(fileSystem)); } if (contentParser == null) { throw new ArgumentNullException(nameof(contentParser)); } if (contentConverter == null) { throw new ArgumentNullException(nameof(contentConverter)); } _fileSystem = fileSystem; _contentParser = contentParser; _contentConverter = contentConverter; _contentProcessor = contentProcessor; }
public static string convert(string targetString) { if (targetString == null) { return(targetString); } if (targetString.IndexOf("MEBKM:") > -1) { targetString = ContentConverter.convertDocomoBookmark(targetString); } if (targetString.IndexOf("MECARD:") > -1) { targetString = ContentConverter.convertDocomoAddressBook(targetString); } if (targetString.IndexOf("MATMSG:") > -1) { targetString = ContentConverter.convertDocomoMailto(targetString); } if (targetString.IndexOf("http\\://") > -1) { targetString = ContentConverter.replaceString(targetString, "http\\://", "\nhttp://"); } return(targetString); }
public static async Task Execute(IJobContext context) { if (!CliUtils.ParseArgs(Options, context.Args)) { return; } if (_isHelp) { PrintUsage(); return; } if (string.IsNullOrEmpty(_directory)) { await CliUtils.PrintErrorAsync("未指定需要转换至最新版本的备份数据文件夹:directory"); return; } var oldTreeInfo = new TreeInfo(_directory); var newTreeInfo = new TreeInfo(Folder); if (!DirectoryUtils.IsDirectoryExists(oldTreeInfo.DirectoryPath)) { await CliUtils.PrintErrorAsync($"备份数据的文件夹 {oldTreeInfo.DirectoryPath} 不存在"); return; } DirectoryUtils.CreateDirectoryIfNotExists(newTreeInfo.DirectoryPath); var updater = new UpdaterManager(oldTreeInfo, newTreeInfo); var version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); await Console.Out.WriteLineAsync($"备份数据文件夹: {oldTreeInfo.DirectoryPath},升级数据文件夹: {newTreeInfo.DirectoryPath},升级版本: {version.Substring(0, version.Length - 2)}"); var oldTableNames = TranslateUtils.JsonDeserialize <List <string> >(await FileUtils.ReadTextAsync(oldTreeInfo.TablesFilePath, Encoding.UTF8)); var newTableNames = new List <string>(); await CliUtils.PrintRowLineAsync(); await CliUtils.PrintRowAsync("备份表名称", "升级表名称", "总条数"); await CliUtils.PrintRowLineAsync(); var siteIdList = new List <int>(); var tableNameListForContent = new List <string>(); var tableNameListForGovPublic = new List <string>(); var tableNameListForGovInteract = new List <string>(); var tableNameListForJob = new List <string>(); UpdateUtils.LoadSites(oldTreeInfo, siteIdList, tableNameListForContent, tableNameListForGovPublic, tableNameListForGovInteract, tableNameListForJob); var splitSiteTableDict = new Dictionary <int, TableInfo>(); if (_contentSplit) { var converter = ContentConverter.GetSplitConverter(); foreach (var siteId in siteIdList) { splitSiteTableDict.Add(siteId, new TableInfo { Columns = converter.NewColumns, TotalCount = 0, RowFiles = new List <string>() }); } } foreach (var oldTableName in oldTableNames) { var oldMetadataFilePath = oldTreeInfo.GetTableMetadataFilePath(oldTableName); if (!FileUtils.IsFileExists(oldMetadataFilePath)) { continue; } var oldTableInfo = TranslateUtils.JsonDeserialize <TableInfo>(await FileUtils.ReadTextAsync(oldMetadataFilePath, Encoding.UTF8)); if (StringUtils.ContainsIgnoreCase(tableNameListForContent, oldTableName)) { if (_contentSplit) { var converter = ContentConverter.GetConverter(oldTableName, oldTableInfo.Columns); await updater.UpdateSplitContentsTableInfoAsync(splitSiteTableDict, siteIdList, oldTableName, oldTableInfo, converter); } else { var converter = ContentConverter.GetConverter(oldTableName, oldTableInfo.Columns); var tuple = await updater.GetNewTableInfoAsync(oldTableName, oldTableInfo, converter); if (tuple != null) { newTableNames.Add(tuple.Item1); await FileUtils.WriteTextAsync(newTreeInfo.GetTableMetadataFilePath(tuple.Item1), Encoding.UTF8, TranslateUtils.JsonSerialize(tuple.Item2)); } } } else { var tuple = await updater.UpdateTableInfoAsync(oldTableName, oldTableInfo, tableNameListForGovPublic, tableNameListForGovInteract, tableNameListForJob); if (tuple != null) { newTableNames.Add(tuple.Item1); await FileUtils.WriteTextAsync(newTreeInfo.GetTableMetadataFilePath(tuple.Item1), Encoding.UTF8, TranslateUtils.JsonSerialize(tuple.Item2)); } } } if (_contentSplit) { foreach (var siteId in siteIdList) { var siteTableInfo = splitSiteTableDict[siteId]; var siteTableName = ContentDao.GetContentTableName(siteId); newTableNames.Add(siteTableName); await FileUtils.WriteTextAsync(newTreeInfo.GetTableMetadataFilePath(siteTableName), Encoding.UTF8, TranslateUtils.JsonSerialize(siteTableInfo)); } await UpdateUtils.UpdateSitesSplitTableNameAsync(newTreeInfo, splitSiteTableDict); } await FileUtils.WriteTextAsync(newTreeInfo.TablesFilePath, Encoding.UTF8, TranslateUtils.JsonSerialize(newTableNames)); await CliUtils.PrintRowLineAsync(); await Console.Out.WriteLineAsync($"恭喜,成功从备份文件夹:{oldTreeInfo.DirectoryPath} 升级至新版本:{newTreeInfo.DirectoryPath} !"); }
private static string removeString(string s, string s1) { return(ContentConverter.replaceString(s, s1, "")); }
public Task <IEnumerable <MulticastCommentMessage> > GetMulticastCommentMessages(Tag tag, int trustMessageCountUpperLimit, int untrustMessageCountUpperLimit, IEnumerable <MessageCondition> conditions) { if (tag == null) { throw new ArgumentNullException(nameof(tag)); } var now = DateTime.UtcNow; return(Task.Run(() => { try { var filter = new Dictionary <Signature, HashSet <DateTime> >(); { foreach (var item in conditions) { filter.GetOrAdd(item.AuthorSignature, (_) => new HashSet <DateTime>()).Add(item.CreationTime); } } var trustedMetadatas = new List <MulticastClue>(); var untrustedMetadatas = new List <MulticastClue>(); { foreach (var MulticastClue in _coreManager.GetMulticastClues(tag, "ChatMessage")) { if (_searchSignatures.Contains(MulticastClue.Certificate.GetSignature())) { trustedMetadatas.Add(MulticastClue); } else { untrustedMetadatas.Add(MulticastClue); } } trustedMetadatas.Sort((x, y) => y.CreationTime.CompareTo(x.CreationTime)); untrustedMetadatas.Sort((x, y) => { int c; if (0 != (c = y.Cost.CashAlgorithm.CompareTo(x.Cost.CashAlgorithm))) { return c; } if (0 != (c = y.Cost.Value.CompareTo(x.Cost.Value))) { return c; } return y.CreationTime.CompareTo(x.CreationTime); }); } var results = new List <MulticastCommentMessage>(); foreach (var MulticastClue in CollectionUtils.Unite(trustedMetadatas.Take(trustMessageCountUpperLimit), untrustedMetadatas.Take(untrustMessageCountUpperLimit))) { if (filter.TryGetValue(MulticastClue.Certificate.GetSignature(), out var hashSet) && hashSet.Contains(MulticastClue.CreationTime)) { continue; } var stream = _coreManager.VolatileGetStream(MulticastClue.Metadata, 1024 * 1024 * 1); if (stream == null) { continue; } var content = ContentConverter.FromStream <CommentContent>(stream, 0); if (content == null) { continue; } var result = new MulticastCommentMessage( MulticastClue.Tag, MulticastClue.Certificate.GetSignature(), MulticastClue.CreationTime, MulticastClue.Cost, content); results.Add(result); } return (IEnumerable <MulticastCommentMessage>)results.ToArray(); } catch (Exception e) { Log.Error(e); } return Array.Empty <MulticastCommentMessage>(); })); }
public Protobuf(ContentConverter converter) { _converter = converter; }
public Json(ContentConverter converter) { _converter = converter; }
public virtual void actionPerformed(System.Object event_sender, System.EventArgs event_Renamed) { if (event_sender.Equals(openMenu)) { chooser.ShowDialog(this); if (new System.IO.FileInfo(chooser.FileName) == null) { return; } try { sourceImage = ImageIO.read(new System.IO.FileInfo(chooser.FileName)); } catch (System.Exception e) { SupportClass.WriteStackTrace(e, Console.Error); } } else if (SupportClass.CommandManager.GetCommand(event_sender).Equals("Open from URL")) { try { //UPGRADE_TODO: Class 'java.net.URL' was converted to a 'System.Uri' which does not throw an exception if a URL specifies an unknown protocol. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1132'" sourceImage = ImageIO.read(new System.Uri(url.Text)); } catch (System.Exception e) { SupportClass.WriteStackTrace(e, Console.Error); } } else { return; } if (sourceImageLabel != null) { //UPGRADE_TODO: Method 'javax.swing.JFrame.getContentPane' was converted to 'System.Windows.Forms.Form' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaxswingJFramegetContentPane'" ((System.Windows.Forms.ContainerControl) this).Controls.Remove(sourceImageLabel); } System.Windows.Forms.Label temp_label; temp_label = new System.Windows.Forms.Label(); temp_label.Image = (System.Drawing.Image)sourceImage.Clone(); sourceImageLabel = temp_label; //UPGRADE_TODO: Method 'javax.swing.JFrame.getContentPane' was converted to 'System.Windows.Forms.Form' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaxswingJFramegetContentPane'" //UPGRADE_TODO: Method 'java.awt.Container.add' was converted to 'System.Windows.Forms.ContainerControl.Controls.Add' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtContaineradd_javaawtComponent_javalangObject'" ((System.Windows.Forms.ContainerControl) this).Controls.Add(sourceImageLabel); sourceImageLabel.Dock = System.Windows.Forms.DockStyle.Left; sourceImageLabel.BringToFront(); QRCodeDecoder decoder = new QRCodeDecoder(); if (canvas != null) { //UPGRADE_TODO: Method 'javax.swing.JFrame.getContentPane' was converted to 'System.Windows.Forms.Form' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaxswingJFramegetContentPane'" ((System.Windows.Forms.ContainerControl) this).Controls.Remove(canvas); //canvas.setImage(null); } canvas = new J2SEDebugCanvas(); QRCodeDecoder.setCanvas(canvas); //UPGRADE_TODO: Method 'javax.swing.JFrame.getContentPane' was converted to 'System.Windows.Forms.Form' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaxswingJFramegetContentPane'" //UPGRADE_TODO: Method 'java.awt.Container.add' was converted to 'System.Windows.Forms.ContainerControl.Controls.Add' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtContaineradd_javaawtComponent_javalangObject'" ((System.Windows.Forms.ContainerControl) this).Controls.Add(canvas); canvas.Dock = System.Windows.Forms.DockStyle.Right; canvas.BringToFront(); System.String decodedString = null; try { decodedString = new String(decoder.decode(new J2SEImage(this, sourceImage))); } catch (DecodingFailedException e) { canvas.println(e.getMessage()); canvas.println("--------"); return; } decodedString = ContentConverter.convert(decodedString); canvas.println("\nDecode result:"); canvas.println(decodedString); canvas.println("--------"); if (decodedText != null) { //UPGRADE_TODO: Method 'javax.swing.JFrame.getContentPane' was converted to 'System.Windows.Forms.Form' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaxswingJFramegetContentPane'" ((System.Windows.Forms.ContainerControl) this).Controls.Remove(decodedText); } System.Windows.Forms.TextBox temp_TextBox; temp_TextBox = new System.Windows.Forms.TextBox(); temp_TextBox.Multiline = true; temp_TextBox.WordWrap = false; temp_TextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both; temp_TextBox.Text = decodedString; decodedText = temp_TextBox; decodedText.WordWrap = true; //UPGRADE_ISSUE: Method 'javax.swing.JTextArea.setRows' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaxswingJTextAreasetRows_int'" decodedText.setRows(decodedString.Length / 20 + 1); if (decodedString.Length < 20) { //UPGRADE_ISSUE: Method 'javax.swing.JTextArea.setColumns' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaxswingJTextAreasetColumns_int'" decodedText.setColumns(decodedString.Length); } else { //UPGRADE_ISSUE: Method 'javax.swing.JTextArea.setColumns' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaxswingJTextAreasetColumns_int'" decodedText.setColumns(20); } //decodedText.setSize(sourceImageLabel.getSize().width,100); //UPGRADE_TODO: Method 'javax.swing.JFrame.getContentPane' was converted to 'System.Windows.Forms.Form' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaxswingJFramegetContentPane'" //UPGRADE_TODO: Method 'java.awt.Container.add' was converted to 'System.Windows.Forms.ContainerControl.Controls.Add' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtContaineradd_javaawtComponent_javalangObject'" ((System.Windows.Forms.ContainerControl) this).Controls.Add(decodedText); decodedText.Dock = System.Windows.Forms.DockStyle.Bottom; decodedText.SendToBack(); //UPGRADE_ISSUE: Method 'java.awt.Window.pack' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaawtWindowpack'" pack(); }
public ContentConversion(HBaseContext hBase, ContentConverter converter) { _hBase = hBase; _converter = converter; }
public Xml(HBaseContext hBase, ResourceContext resources, ContentConverter converter) { _hBase = hBase; _resources = resources; _converter = converter; }
public Task <IEnumerable <UnicastCommentMessage> > GetUnicastCommentMessages(Signature signature, AgreementPrivateKey agreementPrivateKey, int messageCountUpperLimit, IEnumerable <MessageCondition> conditions) { if (signature == null) { throw new ArgumentNullException(nameof(signature)); } if (agreementPrivateKey == null) { throw new ArgumentNullException(nameof(agreementPrivateKey)); } return(Task.Run(() => { try { var filter = new Dictionary <Signature, HashSet <DateTime> >(); { foreach (var item in conditions) { filter.GetOrAdd(item.AuthorSignature, (_) => new HashSet <DateTime>()).Add(item.CreationTime); } } var trustedMetadatas = new List <UnicastClue>(); { foreach (var UnicastClue in _coreManager.GetUnicastClues(signature, "MailMessage")) { if (!_searchSignatures.Contains(UnicastClue.Certificate.GetSignature())) { continue; } trustedMetadatas.Add(UnicastClue); } trustedMetadatas.Sort((x, y) => y.CreationTime.CompareTo(x.CreationTime)); } var results = new List <UnicastCommentMessage>(); foreach (var UnicastClue in trustedMetadatas.Take(messageCountUpperLimit)) { if (filter.TryGetValue(UnicastClue.Certificate.GetSignature(), out var hashSet) && hashSet.Contains(UnicastClue.CreationTime)) { continue; } var stream = _coreManager.VolatileGetStream(UnicastClue.Metadata, 1024 * 1024 * 1); if (stream == null) { continue; } var result = new UnicastCommentMessage( UnicastClue.Signature, UnicastClue.Certificate.GetSignature(), UnicastClue.CreationTime, ContentConverter.FromCryptoStream <CommentContent>(stream, agreementPrivateKey, 0)); if (result.Value == null) { continue; } results.Add(result); } return (IEnumerable <UnicastCommentMessage>)results.ToArray(); } catch (Exception e) { Log.Error(e); } return Array.Empty <UnicastCommentMessage>(); })); }