コード例 #1
0
        public async Task <IndexedDocument> GetIndexedDocument(String fileName)
        {
            IndexedDocument result = null;

            if (indexedDocuments.ContainsKey(fileName))
            {
                // If we already created it in the past, just return it.
                result = indexedDocuments[fileName];
            }

            if (result == null)
            {
                string rawText = await GetFileContent(fileName);

                if (indexedDocuments.ContainsKey(fileName))
                {
                    result = indexedDocuments[fileName];
                }

                if (result == null)
                {
                    result = new IndexedDocument(fileName, rawText);
                    indexedDocuments.Add(fileName, result);
                }
            }
            return(result);
        }
コード例 #2
0
        public async Task <int> AddLearnedAnnotations(string learnedAnnotations)
        {
            string annotationsString = learnedAnnotations;

            List <Annotation> dsallAnnotations = JsonConvert.DeserializeObject <List <Annotation> >(annotationsString);
            int i = 0;

            if (dsallAnnotations != null)
            {
                for (i = 0; i < dsallAnnotations.Count; i++)
                {
                    // For some reason the iterator was not working well.. doing an old-fashioned for loop to debug.
                    Annotation annotation = dsallAnnotations[i];

                    // get the file -- or create a new one if it already exists.
                    IndexedDocument newDocument = await GetIndexedDocument(annotation.FileName);

                    annotation.AnnotationName = "Learned Date";

                    if (!newDocument.Annotations.ContainsKey(annotation.StartOffset))
                    {
                        newDocument.Annotations.Add(annotation.StartOffset, annotation);
                    }
                }
            }

            return(i);
        }
コード例 #3
0
        private async void FileSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count > 0)
            {
                string fileName = e.AddedItems[0].ToString();

                currentDocument = await fileManager.GetIndexedDocument(fileName);

                UpdateDocumentView();
            }
        }
コード例 #4
0
        public async void InitializeAnnotations()
        {
            string annotationsString = await GetFileContent("allAnnotations/allAnnotations.json");

            List <Annotation> dsallAnnotations = JsonConvert.DeserializeObject <List <Annotation> >(annotationsString);

            if (dsallAnnotations != null)
            {
                foreach (Annotation annotation in dsallAnnotations)
                {
                    // get the file -- or create a new one if it already exists.
                    IndexedDocument newDocument = await GetIndexedDocument(annotation.FileName);

                    newDocument.Annotations.Add(annotation.StartOffset, annotation);
                }
            }
        }