public Client(IPAddress address, UInt16 port) { this.address = address; this.port = port; fetcher = new ContentFetcher (address, port); ContentNode node = ContentParser.Parse (ContentCodeBag.Default, fetcher.Fetch ("/server-info")); serverInfo = ServerInfo.FromNode (node); }
public void AddFetcher <T>(ContentFetcher <T> fetcher) where T : IContent { _fetcherByContentType.Add(typeof(T), fetcher); fetcher.ContentAdded += Fetcher_ContentAdded; if (fetcher is ICacher cacher) { if (!_cacheManifestByFetcherName.ContainsKey(fetcher.Name)) { var filePath = Path.Combine(_cachePath, fetcher.Name + "." + CacheManifest.FILE_EXTENSION); _cacheManifestByFetcherName.Add(fetcher.Name, new CacheManifest(filePath)); } cacher.ContentCached += Cacher_ContentCached; } }
public void Dispose() { updateRunning = false; if (fetcher != null) { fetcher.Dispose (); fetcher = null; } }
protected int SaveSubject(QuestionInputModel subject) { SubjectBll bll = new SubjectBll(); //题目信息 Yw_Subject subjectEntity = null; Action <Yw_Subject> saveSubjectMethod = SubjectFetcher.Fetch(subject, bll, CurrentUserID, out subjectEntity); //题目内容 Yw_SubjectContent content = null; ContentFetcher fetcher = GetContentFetcher(); Action <Yw_SubjectContent> saveContentMethod = fetcher.Fetch( subject, bll, CurrentUserID, out content); //要删除的关键词 IList <int> keywordIdsToDelete = null; //要添加的关键词 IList <Yw_SubjectIndex> keywordsToAdd = KeywordFetcher.Fetch( subject, bll, CurrentUserID, out keywordIdsToDelete); //主知识点 Yw_SubjectKnowledge mainKnowledgeEntity = null; Action <Yw_SubjectKnowledge> saveKnowledgeMethod = MainKnowledgeFetcher.Fetch( subject, bll, CurrentUserID, out mainKnowledgeEntity); //次级知识点 //需要删除的次级知识点 IEnumerable <int> idsOfknowledgeToDelete = null; //需要添加的次级知识点 IEnumerable <Yw_SubjectKnowledge> knowledgesToAdd = SecondaryKnowledgeFetcher.Fetch( subject, bll, CurrentUserID, out idsOfknowledgeToDelete); Yw_SubjectProcess process = null; if (subject.Button == FormSubmitButton.Submit) { process = bll.GetNextProcess( subject.Id, CurrentUserID, subject.NextStatus, SubjectActionEnum.提交); subjectEntity.Ysj_Status = process.Ysp_Status; } return(bll.SaveSubject(saveSubjectMethod, subjectEntity, saveContentMethod, content, saveKnowledgeMethod, mainKnowledgeEntity, keywordsToAdd, keywordIdsToDelete, knowledgesToAdd, idsOfknowledgeToDelete, process, subject.Button)); }