コード例 #1
0
        public ChatCollectService.IChatCollectService GetNewService(IChatCollectServiceCreationOption creationOption)
        {
            if (creationOption == null)
            {
                throw new ArgumentNullException(nameof(creationOption));
            }
            var option = creationOption as ChatCollectServiceCreationOption;

            if (option == null)
            {
                throw new ArgumentException($"Type of {nameof(creationOption)} must be {nameof(FileChatCollectServiceEntry)}.{nameof(ChatCollectServiceCreationOption)}", nameof(creationOption));
            }
            try
            {
                return(new ChatCollectService.FileChatCollectService(this, new StreamReader(option.FilePath), option.RelativeTime));
            }
            catch (ArgumentException e)
            {
                throw new ChatCollectServiceCreationException($"コメントファイルのパスが不正です: {option.FilePath}", e);
            }
            catch (FileNotFoundException e)
            {
                throw new ChatCollectServiceCreationException($"コメントファイルが見つかりません: {option.FilePath}", e);
            }
            catch (DirectoryNotFoundException e)
            {
                throw new ChatCollectServiceCreationException($"コメントファイルが見つかりません: {option.FilePath}", e);
            }
            catch (IOException e)
            {
                throw new ChatCollectServiceCreationException($"コメントファイルを開くときにIOエラーが発生しました: {option.FilePath}", e);
            }
        }
コード例 #2
0
        public ChatCollectService.IChatCollectService GetNewService(IChatCollectServiceCreationOption creationOption)
        {
            var threadSelector = new NichanUtils.AutoPastNichanThreadSelector(this.threadResolver, TimeSpan.FromSeconds(15), this.backTime.Value);

            return(new ChatCollectService.PastNichanChatCollectService(
                       this, threadSelector, TimeSpan.FromSeconds(15)
                       ));
        }
コード例 #3
0
 public ChatCollectService.IChatCollectService GetNewService(IChatCollectServiceCreationOption creationOption)
 {
     if (creationOption != null && !(creationOption is ChatCollectServiceCreationOption))
     {
         throw new ArgumentException($"Type of {nameof(creationOption)} must be {nameof(NiconicoChatCollectServiceEntry)}.{nameof(ChatCollectServiceCreationOption)}", nameof(creationOption));
     }
     return(new ChatCollectService.NiconicoChatCollectService(this, jkIdResolver, session.Value));
 }
コード例 #4
0
        public ChatCollectService.IChatCollectService GetNewService(IChatCollectServiceCreationOption creationOption)
        {
            var boardSelector = new NichanUtils.AutoNichanBoardSelector(this.threadResolver);

            return(new ChatCollectService.PastNichanChatCollectService(
                       this, boardSelector, this.backTime.Value
                       ));
        }
コード例 #5
0
        public ChatCollectService.IChatCollectService GetNewService(IChatCollectServiceCreationOption creationOption)
        {
            if (creationOption != null && !(creationOption is ChatCollectServiceCreationOption))
            {
                throw new ArgumentException($"Type of {nameof(creationOption)} must be {nameof(NewNiconicoJikkyouChatCollectServiceEntry)}.{nameof(ChatCollectServiceCreationOption)}", nameof(creationOption));
            }
            var session = this.session.Value;

            if (session == null)
            {
                throw new ChatCollectServiceCreationException("ニコニコ生放送にはニコニコへのログインが必要です");
            }
            return(new ChatCollectService.NewNiconicoJikkyouChatCollectService(this, this.liveIdResolver, session));
        }
コード例 #6
0
        public ChatCollectService.IChatCollectService GetNewService(IChatCollectServiceCreationOption creationOption)
        {
            if (creationOption == null || !(creationOption is ChatCollectServiceCreationOption co))
            {
                throw new ArgumentException($"Type of {nameof(creationOption)} must be {nameof(NiconicoLiveChatCollectServiceEntry)}.{nameof(ChatCollectServiceCreationOption)}", nameof(creationOption));
            }
            var session = this.session.Value;

            if (session == null)
            {
                throw new ChatCollectServiceCreationException("ニコニコ生放送にはニコニコへのログインが必要です");
            }
            return(new ChatCollectService.NiconicoLiveChatCollectService(this, co.LiveId, this.session.Value));
        }
コード例 #7
0
        public ChatCollectService.IChatCollectService GetNewService(IChatCollectServiceCreationOption creationOption)
        {
            if (creationOption != null && !(creationOption is ChatCollectServiceCreationOption))
            {
                throw new ArgumentException($"Type of {nameof(creationOption)} must be {nameof(NiconicoLogChatCollectServiceEntry)}.{nameof(ChatCollectServiceCreationOption)}", nameof(creationOption));
            }

            if (session.Value == null || !session.Value.IsLoggedin)
            {
                throw new ChatCollectServiceCreationException("ニコニコ動画にログインしていないためニコニコ実況過去ログは使えません");
            }

            return(new ChatCollectService.NiconicoLogChatCollectService(this, jkIdResolver, session.Value));
        }
コード例 #8
0
        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));
        }
コード例 #9
0
        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));
        }
コード例 #10
0
 public ChatCollectService.IChatCollectService GetNewService(IChatCollectServiceCreationOption creationOption)
 {
     return(new ChatCollectService.TsukumijimaJikkyoApiChatCollectService(this, this.jkIdResolver));
 }