public PastNichanChatCollectService( ChatCollectServiceEntry.IChatCollectServiceEntry chatCollectServiceEntry, NichanUtils.INichanThreadSelector threadSelector, TimeSpan threadSelectionUpdateInterval ) : base(TimeSpan.FromSeconds(10)) { this.ServiceEntry = chatCollectServiceEntry; this.threadSelector = threadSelector; this.threadSelectionUpdateInterval = threadSelectionUpdateInterval; this.resCollectLoopTask = Task.Run(() => this.ResCollectLoop(this.resCollectLoopTaskCancellation.Token)); }
public ChatCollectService.IChatCollectService GetNewService(IChatCollectServiceCreationOption creationOption) { creationOption ??= new ChatCollectServiceCreationOption(ChatCollectServiceCreationOption.ThreadSelectMethod.Auto, null, null, null); if (creationOption is not ChatCollectServiceCreationOption co) { throw new ArgumentException($"Type of {nameof(creationOption)} must be {nameof(NichanChatCollectServiceEntry)}.{nameof(ChatCollectServiceCreationOption)}", nameof(creationOption)); } NichanUtils.INichanThreadSelector selector = co.Method switch { ChatCollectServiceCreationOption.ThreadSelectMethod.Fixed => new NichanUtils.FixedNichanThreadSelector(new string[] { co.Uri.ToString() }), ChatCollectServiceCreationOption.ThreadSelectMethod.Keyword => new NichanUtils.KeywordNichanThreadSelector(co.Uri.ToString(), co.Keywords), ChatCollectServiceCreationOption.ThreadSelectMethod.Fuzzy => new NichanUtils.FuzzyNichanThreadSelector(co.Uri.ToString(), co.Title), ChatCollectServiceCreationOption.ThreadSelectMethod.Auto => new NichanUtils.AutoNichanThreadSelector(threadResolver), _ => throw new ArgumentOutOfRangeException(nameof(creationOption), "((ChatCollectServiceCreationOption)creationOption).Method is out of range"), }; return(this.getNichanChatCollectService(selector)); }
public ChatCollectService.IChatCollectService GetNewService(IChatCollectServiceCreationOption creationOption) { creationOption = creationOption ?? new ChatCollectServiceCreationOption(ChatCollectServiceCreationOption.ThreadSelectMethod.Auto, null, null, null); ChatCollectServiceCreationOption co = creationOption as ChatCollectServiceCreationOption; if (co == null) { throw new ArgumentException($"Type of {nameof(creationOption)} must be {nameof(NichanChatCollectServiceEntry)}.{nameof(ChatCollectServiceCreationOption)}", nameof(creationOption)); } NichanUtils.INichanThreadSelector selector = null; if (co.Method == ChatCollectServiceCreationOption.ThreadSelectMethod.Fixed) { selector = new NichanUtils.FixedNichanThreadSelector(new string[1] { co.Uri.ToString() }); } else if (co.Method == ChatCollectServiceCreationOption.ThreadSelectMethod.Keyword) { selector = new NichanUtils.KeywordNichanThreadSelector(co.Uri, co.Keywords); } else if (co.Method == ChatCollectServiceCreationOption.ThreadSelectMethod.Fuzzy) { selector = new NichanUtils.FuzzyNichanThreadSelector(co.Uri, co.Title); } else if (co.Method == ChatCollectServiceCreationOption.ThreadSelectMethod.Auto) { selector = new NichanUtils.AutoNichanThreadSelector(threadResolver); } else { throw new ArgumentOutOfRangeException("((ChatCollectServiceCreationOption)creationOption).Method is out of range"); } return(this.getNichanChatCollectService(selector)); }
protected override ChatCollectService.IChatCollectService getNichanChatCollectService(NichanUtils.INichanThreadSelector threadSelector) { return(new ChatCollectService.DATNichanChatCollectService( this, this.resCollectInterval.Value, this.threadSearchInterval.Value, threadSelector, this.apiClient.Value )); }
protected abstract ChatCollectService.IChatCollectService getNichanChatCollectService( NichanUtils.INichanThreadSelector threadSelector );