コード例 #1
0
        public T Annotation <T> () where T : class
        {
            object         annotations = this.annotations;
            AnnotationList list        = annotations as AnnotationList;

            if (list != null)
            {
                lock (list)
                {
                    foreach (object obj in list)
                    {
                        T t = obj as T;
                        if (t != null)
                        {
                            return(t);
                        }
                    }
                    return(null);
                }
            }
            else
            {
                return(annotations as T);
            }
        }
コード例 #2
0
ファイル: AstNode.cs プロジェクト: thild/monodevelop
        public IEnumerable <T> Annotations <T>() where T : class
        {
            object         annotations = this.annotations;
            AnnotationList list        = annotations as AnnotationList;

            if (list != null)
            {
                List <T> result = new List <T>();
                lock (list) {
                    foreach (object obj in list)
                    {
                        T t = obj as T;
                        if (t != null)
                        {
                            result.Add(t);
                        }
                    }
                }
                return(result);
            }
            else
            {
                T t = annotations as T;
                if (t != null)
                {
                    return new T[] { t }
                }
                ;
                else
                {
                    return(Enumerable.Empty <T>());
                }
            }
        }
コード例 #3
0
        public void UpdateTableViewDataByBookID(int bookID)
        {
            if (AnnotationList == null)
            {
                AnnotationList = new List <Annotation> ();
            }
            else
            {
                AnnotationList.Clear();
            }

            var annotationList = AnnotationUtil.Instance.GetAnnotations();

            if (annotationList != null)
            {
                var sameTitleList = annotationList.FindAll((item) => item.BookId == bookID);
                AnnotationList.AddRange(sameTitleList);
            }

            if (AnnotationList == null || AnnotationList.Count == 0)
            {
                InfoView.Hidden = false;
                AnnotationTableView.EnclosingScrollView.Hidden = true;
            }
            else
            {
                InfoView.Hidden = true;
                AnnotationTableView.EnclosingScrollView.Hidden = false;

                AnnotationTableView.ReloadData();
            }
        }
コード例 #4
0
ファイル: IAnnotatable.cs プロジェクト: wwh1004/NRefactory
        public T?AnnotationVT <T> () where T : struct
        {
            object         annotations = this.annotations;
            AnnotationList list        = annotations as AnnotationList;

            if (list != null)
            {
                lock (list) {
                    foreach (object obj in list)
                    {
                        if (obj is T)
                        {
                            return((T)obj);
                        }
                    }
                    return(null);
                }
            }
            else
            {
                if (annotations is T)
                {
                    return((T)annotations);
                }
                return(null);
            }
        }
コード例 #5
0
        public object Annotation(Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            object         annotations = this.annotations;
            AnnotationList list        = annotations as AnnotationList;

            if (list != null)
            {
                lock (list) {
                    foreach (object obj in list)
                    {
                        if (type.IsInstanceOfType(obj))
                        {
                            return(obj);
                        }
                    }
                }
            }
            else
            {
                if (type.IsInstanceOfType(annotations))
                {
                    return(annotations);
                }
            }
            return(null);
        }
コード例 #6
0
ファイル: MainGui.cs プロジェクト: devna13/phis
        public void reloadDocument()
        {
            String selectedDocID = getCurrentDocId();

            if (selectedDocID != null)
            {
                FileInfo fileInfo = new FileInfo(Path.Combine(InputPath, selectedDocID));
                if (!fileInfo.Exists)
                {
                    return;
                }

                currentDoc = Document.getAnnotatedDocumentWS(InputPath, OutputPath, selectedDocID);

                if (currentDoc != null)
                {
                    textBoxPatientId.Text = currentDoc.patientId;
                    textArea.Text         = currentDoc.text;
                    annotationList        = new AnnotationList(currentDoc.annotations, this);

                    refreshAll();

                    textArea.Select(0, 0);
                    textArea.Focus();
                }
            }
            else
            {
                currentDoc = null;
            }
        }
コード例 #7
0
        public virtual void AddAnnotation(object annotation)
        {
            if (annotation == null)
            {
                throw new ArgumentNullException("annotation");
            }
retry:      // Retry until successful
            object oldAnnotation = Interlocked.CompareExchange(ref this.annotations, annotation, null);

            if (oldAnnotation == null)
            {
                return;                 // we successfully added a single annotation
            }
            AnnotationList list = oldAnnotation as AnnotationList;

            if (list == null)
            {
                // we need to transform the old annotation into a list
                list = new AnnotationList(4);
                list.Add(oldAnnotation);
                list.Add(annotation);
                if (Interlocked.CompareExchange(ref this.annotations, list, oldAnnotation) != oldAnnotation)
                {
                    // the transformation failed (some other thread wrote to this.annotations first)
                    goto retry;
                }
            }
            else
            {
                // once there's a list, use simple locking
                lock (list) {
                    list.Add(annotation);
                }
            }
        }
コード例 #8
0
        public void GetNodes()
        {
            var annList = new AnnotationList <int>(_spanFactory);

            annList.Add(1, 2, FeatureStruct.New().Value);
            annList.Add(9, 10, FeatureStruct.New().Value);
            annList.Add(24, 25, FeatureStruct.New().Value);
            annList.Add(49, 50, FeatureStruct.New().Value);
            annList.Add(99, 100, FeatureStruct.New().Value);
            annList.Add(new Annotation <int>(_spanFactory.Create(20, 70), FeatureStruct.New().Value), false);

            Assert.IsFalse(annList.GetNodes(0, 1).Any());

            Assert.IsFalse(annList.GetNodes(100, 101).Any());

            Annotation <int>[] anns = annList.GetNodes(8, 52).ToArray();
            Assert.AreEqual(3, anns.Length);
            Assert.AreEqual(annList.First.Next, anns[0]);
            Assert.AreEqual(annList.Last.Prev, anns[2]);

            anns = annList.GetNodes(9, 10).ToArray();
            Assert.AreEqual(1, anns.Length);
            Assert.AreEqual(annList.First.Next, anns[0]);

            anns = annList.GetNodes(0, 200).ToArray();
            Assert.AreEqual(6, anns.Length);
        }
コード例 #9
0
 public static AnnotationList Translate(List<ImageDoc.Annotation> annotations, float scale, ColourFormat colourFormat, PointF controlOffset, PointF imageOffset)
 {
     AnnotationList imagingAnnotations = new AnnotationList();
     foreach (ImageDoc.Annotation annotation in annotations) {
         imagingAnnotations.Add(Translate(annotation, scale, colourFormat, controlOffset, imageOffset));
     }
     return imagingAnnotations;
 }
コード例 #10
0
 public object Clone()
 {
     lock (this)
     {
         AnnotationList copy = new AnnotationList(this.Count);
         copy.AddRange(this);
         return(copy);
     }
 }
コード例 #11
0
        public void AnnotateCode_ClassKeyword_AddsNewAnnotationToAnnotationTable()
        {
            _annotator.AnnotateCode(ClassKeywordFile, ClassKeywordPhp, ClassKeywordTokens);

            var expected = new AnnotationList(ClassKeywordFile);
            expected.Add(new Annotation(0, 2, 0));

            Assert.AreEqual(expected, _annotator.AnnotationTable[ClassKeywordFile]);
        }
コード例 #12
0
ファイル: Session.cs プロジェクト: katadam/wockets
        public Session()
        {
            this.activityLists = new ConcurrentActivityLists();
            this.annotations = new AnnotationList();

            //check this part
            //this.output_file = FILEINFO_ELEMENT +"_copy"+ ".xml";
            //this.output_csv_file = FILEINFO_ELEMENT + "_copy" + ".csv";
        }
コード例 #13
0
        public void AnnotateCode_VariableVariable_AddsNewAnnotationToAnnotationTable()
        {
            _annotator.AnnotateCode(VariableVariableFile, VariableVariablePhp, VariableVariableTokens);

            var expected = new AnnotationList(VariableVariableFile);

            expected.Add(new Annotation(0, 5, 0));

            Assert.AreEqual(expected, _annotator.AnnotationTable[VariableVariableFile]);
        }
コード例 #14
0
        public void AnnotateCode_NoPhpCode_AddsNewAnnotationToAnnotationTable()
        {
            _annotator.AnnotateCode(NoPhpCodeFile, NoPhpCodePhp, NoPhpCodeTokens);

            var expected = new AnnotationList(NoPhpCodeFile);

            expected.Add(new Annotation(0, 6, 0));

            Assert.AreEqual(expected, _annotator.AnnotationTable[NoPhpCodeFile]);
        }
コード例 #15
0
        public void AnnotateCode_IfStatement_AddsNewAnnotationsToAnnotationTable()
        {
            _annotator.AnnotateCode(IfStatementFile, IfStatementPhp, IfStatementTokens);

            var expected = new AnnotationList(IfStatementFile);
            expected.Add(new Annotation(0, 22, 0));
            expected.Add(new Annotation(1, 2, 0));

            Assert.AreEqual(expected, _annotator.AnnotationTable[IfStatementFile]);
        }
コード例 #16
0
        public void AnnotateCode_ClassKeyword_AddsNewAnnotationToAnnotationTable()
        {
            _annotator.AnnotateCode(ClassKeywordFile, ClassKeywordPhp, ClassKeywordTokens);

            var expected = new AnnotationList(ClassKeywordFile);

            expected.Add(new Annotation(0, 2, 0));

            Assert.AreEqual(expected, _annotator.AnnotationTable[ClassKeywordFile]);
        }
コード例 #17
0
        public void AnnotateCode_IfStatement_AddsNewAnnotationsToAnnotationTable()
        {
            _annotator.AnnotateCode(IfStatementFile, IfStatementPhp, IfStatementTokens);

            var expected = new AnnotationList(IfStatementFile);

            expected.Add(new Annotation(0, 22, 0));
            expected.Add(new Annotation(1, 2, 0));

            Assert.AreEqual(expected, _annotator.AnnotationTable[IfStatementFile]);
        }
コード例 #18
0
 public object Clone()
 {
     lock (this) {
         AnnotationList copy = new AnnotationList(this.Count);
         for (int i = 0; i < this.Count; i++)
         {
             object obj = this [i];
             copy.Add(obj);
         }
         return(copy);
     }
 }
コード例 #19
0
        public void AnnotateCode_TryCatchStatement_AddsNewAnnotationsToAnnotationTable()
        {
            _annotator.AnnotateCode(TryCatchStatementFile, TryCatchStatementPhp, TryCatchStatementTokens);

            var expected = new AnnotationList(TryCatchStatementFile);

            expected.Add(new Annotation(0, 57, 0));
            expected.Add(new Annotation(1, 26, 0));
            expected.Add(new Annotation(2, 6, 0));
            expected.Add(new Annotation(3, 2, 0));

            Assert.AreEqual(expected, _annotator.AnnotationTable[TryCatchStatementFile]);
        }
コード例 #20
0
 public object Clone()
 {
     lock (this) {
         AnnotationList copy = new AnnotationList(this.Count);
         for (int i = 0; i < this.Count; i++)
         {
             object     obj = this [i];
             ICloneable c   = obj as ICloneable;
             copy.Add(c != null ? c.Clone() : obj);
         }
         return(copy);
     }
 }
コード例 #21
0
ファイル: MainGui.cs プロジェクト: devna13/phis
        public MainGui()
        {
            appConfig = AppConfig.Get();

            InitializeComponent();

            annotationList = new AnnotationList(this);

            //heading

            InititalzeVariable();
            new MainContextMenu(this);
        }
コード例 #22
0
        public void Find()
        {
            var annList = new AnnotationList <int>(_spanFactory);

            annList.Add(1, 2, FeatureStruct.New().Value);
            annList.Add(9, 10, FeatureStruct.New().Value);
            annList.Add(24, 25, FeatureStruct.New().Value);
            annList.Add(49, 50, FeatureStruct.New().Value);
            annList.Add(99, 100, FeatureStruct.New().Value);
            annList.Add(99, 100, FeatureStruct.New().Value);
            annList.Add(new Annotation <int>(_spanFactory.Create(20, 70), FeatureStruct.New().Value), false);

            Annotation <int> result;

            Assert.IsFalse(annList.Find(0, out result));
            Assert.AreSame(annList.Begin, result);

            Assert.IsTrue(annList.Find(1, out result));
            Assert.AreSame(annList.First, result);

            Assert.IsFalse(annList.Find(100, out result));
            Assert.AreSame(annList.Last, result);

            Assert.IsFalse(annList.Find(101, out result));
            Assert.AreSame(annList.Last, result);

            Assert.IsFalse(annList.Find(30, out result));
            Assert.AreSame(annList.ElementAt(3), result);

            Assert.IsTrue(annList.Find(9, out result));
            Assert.AreSame(annList.First.Next, result);

            Assert.IsFalse(annList.Find(101, Direction.RightToLeft, out result));
            Assert.AreSame(annList.End, result);

            Assert.IsTrue(annList.Find(100, Direction.RightToLeft, out result));
            Assert.AreSame(annList.Last, result);

            Assert.IsFalse(annList.Find(1, Direction.RightToLeft, out result));
            Assert.AreSame(annList.First, result);

            Assert.IsFalse(annList.Find(0, Direction.RightToLeft, out result));
            Assert.AreSame(annList.First, result);

            Assert.IsFalse(annList.Find(15, Direction.RightToLeft, out result));
            Assert.AreSame(annList.ElementAt(2), result);

            Assert.IsTrue(annList.Find(10, Direction.RightToLeft, out result));
            Assert.AreSame(annList.First.Next, result);
        }
コード例 #23
0
        public void FindDepthFirst()
        {
            var annList = new AnnotationList <int>(_spanFactory);

            annList.Add(1, 2, FeatureStruct.New().Value);
            annList.Add(9, 10, FeatureStruct.New().Value);
            annList.Add(49, 50, FeatureStruct.New().Value);
            annList.Add(69, 70, FeatureStruct.New().Value);
            annList.Add(99, 100, FeatureStruct.New().Value);
            annList.Add(1, 49, FeatureStruct.New().Value);
            annList.Add(51, 100, FeatureStruct.New().Value);

            Annotation <int> result;

            Assert.IsFalse(annList.FindDepthFirst(0, out result));
            Assert.AreEqual(annList.Begin, result);

            Assert.IsFalse(annList.FindDepthFirst(100, out result));
            Assert.AreEqual(annList.Last, result);

            Assert.IsTrue(annList.FindDepthFirst(1, out result));
            Assert.AreEqual(annList.First, result);

            Assert.IsFalse(annList.FindDepthFirst(8, out result));
            Assert.AreEqual(annList.First.Children.First, result);

            Assert.IsTrue(annList.FindDepthFirst(99, out result));
            Assert.AreEqual(annList.Last.Children.Last, result);

            Assert.IsTrue(annList.FindDepthFirst(49, out result));
            Assert.AreEqual(annList.First.Next, result);

            Assert.IsFalse(annList.FindDepthFirst(101, Direction.RightToLeft, out result));
            Assert.AreEqual(annList.End, result);

            Assert.IsFalse(annList.FindDepthFirst(1, Direction.RightToLeft, out result));
            Assert.AreEqual(annList.First, result);

            Assert.IsTrue(annList.FindDepthFirst(100, Direction.RightToLeft, out result));
            Assert.AreEqual(annList.Last, result);

            Assert.IsFalse(annList.FindDepthFirst(71, Direction.RightToLeft, out result));
            Assert.AreEqual(annList.Last.Children.Last, result);

            Assert.IsTrue(annList.FindDepthFirst(2, Direction.RightToLeft, out result));
            Assert.AreEqual(annList.First.Children.First, result);

            Assert.IsTrue(annList.FindDepthFirst(50, Direction.RightToLeft, out result));
            Assert.AreEqual(annList.Last.Prev, result);
        }
コード例 #24
0
        private AnnotationList LoadAnnotationListFromXmlPrivate(XDocument xml)
        {
            AnnotationList result = new AnnotationList();

            LoadAnnotationDeclarations(xml);
            ResolveAnnotationDeclarations();

            foreach (KeyValuePair <Guid, List <Annotation> > entry in annotationsTable)
            {
                foreach (Annotation annotation in entry.Value)
                {
                    result.Add(new Tuple <Guid, Annotation>(entry.Key, annotation));
                }
            }

            return(result);
        }
コード例 #25
0
        public void AddRangeTest()
        {
            // Arrange
            var source = new AnnotationList();

            source.AddAnnotation(4);

            var destination = new AnnotationList();

            destination.AddAnnotation(true);

            // Act
            destination.AddRange(source);

            // Assert
            Assert.IsFalse(destination.IsEmpty);
            Assert.IsFalse(destination.OfType(typeof(bool)).Any());
            Assert.IsTrue(destination.OfType(typeof(int)).Any());
            Assert.AreEqual(4, destination.Annotations(typeof(int)).FirstOrDefault());
        }
コード例 #26
0
        public void BasicAnnotationsTests()
        {
            // Arrange
            var list       = new AnnotationList();
            var annotation = new Object();

            // Add annotation
            Assert.IsTrue(list.IsEmpty);
            list.AddAnnotation(annotation);
            Assert.IsFalse(list.IsEmpty);

            // Get annontations of type
            var result = list.OfType(typeof(object));

            Assert.AreEqual(annotation, result.FirstOrDefault());

            // Remove annontations of type
            list.RemoveAnnotations(typeof(object));
            Assert.IsTrue(list.IsEmpty);
        }
コード例 #27
0
        public virtual void RemoveAnnotations <T> () where T : class
        {
retry:      // Retry until successful
            object oldAnnotations = this.annotations;
            AnnotationList list = oldAnnotations as AnnotationList;

            if (list != null)
            {
                lock (list)
                    list.RemoveAll(obj => obj is T);
            }
            else if (oldAnnotations is T)
            {
                if (Interlocked.CompareExchange(ref this.annotations, null, oldAnnotations) != oldAnnotations)
                {
                    // Operation failed (some other thread wrote to this.annotations first)
                    goto retry;
                }
            }
        }
コード例 #28
0
 private void AnnotationFilterAnno(NSNotification obj)
 {
     AnnotationList.Clear();
     if (AppDataUtil.Instance.AnnotationSegmentSelectedIndex == 0)               //all
     {
         AnnotationList = AnnotationUtil.Instance.GetAnnotations();
     }
     else if (AppDataUtil.Instance.AnnotationSegmentSelectedIndex == 1)                //highlight
     {
         AnnotationList = AnnotationUtil.Instance.GetAnnotations().FindAll(o => o.Type == AnnotationType.Highlight);
     }
     else if (AppDataUtil.Instance.AnnotationSegmentSelectedIndex == 2)                //Note
     {
         AnnotationList = AnnotationUtil.Instance.GetAnnotations().FindAll(o => o.Type == AnnotationType.StickyNote);
     }
     else if (AppDataUtil.Instance.AnnotationSegmentSelectedIndex == 3)
     {
         AnnotationList = AnnotationUtil.Instance.GetAnnotations().FindAll(o => o.Type == AnnotationType.Orphan);                 //Orphan
     }
     annoTableView.ReloadData();
 }
コード例 #29
0
        public void AddAnnotationTest()
        {
            // Arrange
            var list = new AnnotationList();

            list.AddAnnotation(1);
            list.AddAnnotation(2);
            list.AddAnnotation(false);
            list.AddAnnotation(new object());

            Assert.IsFalse(list.IsEmpty);
            Assert.AreEqual(2, list.OfType(typeof(int)).Count());
            Assert.AreEqual(1, list.OfType(typeof(bool)).Count());
            Assert.AreEqual(1, list.OfType(typeof(object)).Count());

            // Remove annontations of type
            list.RemoveAnnotations(typeof(bool));
            Assert.IsFalse(list.IsEmpty);
            Assert.AreEqual(0, list.OfType(typeof(bool)).Count());
            Assert.AreEqual(2, list.OfType(typeof(int)).Count());
            Assert.AreEqual(1, list.OfType(typeof(object)).Count());
        }
コード例 #30
0
        public PublicationAnnotationTableViewController(IntPtr handle) : base(handle)
        {
            AppDisplayUtil.Instance.publicationAnnotationVC = this;
            selectTagId     = new List <Guid>();
            getGuidList     = new List <AnnotationTag> ();
            SectionTitleArr = new List <string> ();
            AnnoListDict    = new Dictionary <string, List <Annotation> > ();
            AnnotationList  = AnnotationUtil.Instance.GetAnnotationsByBookId(AppDataUtil.Instance.GetCurrentPublication().BookId);            //Get all the list

            foreach (var annotation in AnnotationList)
            {
                if (SectionTitleArr.IndexOf(annotation.GuideCardName) == -1)
                {
                    SectionTitleArr.Add(annotation.GuideCardName);
                }
            }
            for (int i = 0; i < SectionTitleArr.Count; i++)
            {
                List <Annotation> annoList = AnnotationList.FindAll(o => o.GuideCardName == SectionTitleArr[i]);
                AnnoListDict [SectionTitleArr [i]] = annoList;
            }
        }
コード例 #31
0
        public void Remove()
        {
            var annList = new AnnotationList <int>(_spanFactory);

            annList.Add(0, 1, FeatureStruct.New().Value);
            annList.Add(9, 10, FeatureStruct.New().Value);
            annList.Add(24, 25, FeatureStruct.New().Value);
            annList.Add(49, 50, FeatureStruct.New().Value);
            annList.Add(99, 100, FeatureStruct.New().Value);

            annList.Remove(annList.First);
            Assert.AreEqual(4, annList.Count);
            Assert.AreEqual(_spanFactory.Create(9, 10), annList.First.Span);

            annList.Remove(annList.Last);
            Assert.AreEqual(3, annList.Count);
            Assert.AreEqual(_spanFactory.Create(49, 50), annList.Last.Span);

            annList.Remove(annList.First.Next);
            Assert.AreEqual(2, annList.Count);
            annList.Remove(annList.First);
            Assert.AreEqual(1, annList.Count);
            annList.Remove(annList.First);
            Assert.AreEqual(0, annList.Count);

            annList.Add(0, 1, FeatureStruct.New().Value);
            annList.Add(9, 10, FeatureStruct.New().Value);
            annList.Add(49, 50, FeatureStruct.New().Value);
            annList.Add(69, 70, FeatureStruct.New().Value);
            annList.Add(99, 100, FeatureStruct.New().Value);
            annList.Add(0, 49, FeatureStruct.New().Value);
            annList.Add(51, 100, FeatureStruct.New().Value);

            annList.Remove(annList.First);
            Assert.AreEqual(4, annList.Count);
            annList.Remove(annList.Last, false);
            Assert.AreEqual(3, annList.Count);
        }
コード例 #32
0
        public override void ViewDidLoad()
        {
            ReloadAnnotationData();

            if (AnnotationList == null)
            {
                AnnotationList = new List <Annotation> ();
            }
            else
            {
                AnnotationList.Clear();
            }

            if (AnnotationUtil.Instance == null)
            {
                return;
            }

            AnnotationList.AddRange(AnnotationUtil.Instance.GetAnnotations());

            InfoLabelTF.StringValue = "No annotations match your search criteria.";
            PostInitialization();
            //
            AllButton.Cell.Bordered = false;
            AllButton.Cell.SetButtonType(NSButtonType.MomentaryChange);

            NotesButton.Cell.Bordered = false;
            NotesButton.Cell.SetButtonType(NSButtonType.MomentaryChange);

            HighlightsButton.Cell.Bordered = false;
            HighlightsButton.Cell.SetButtonType(NSButtonType.MomentaryChange);

            OrphansButton.Cell.Bordered = false;
            OrphansButton.Cell.SetButtonType(NSButtonType.MomentaryChange);

            AllButtonClick(AllButton);
        }
コード例 #33
0
ファイル: AstNode.cs プロジェクト: thild/monodevelop
        public IEnumerable <object> Annotations(Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            object         annotations = this.annotations;
            AnnotationList list        = annotations as AnnotationList;

            if (list != null)
            {
                List <object> result = new List <object>();
                lock (list) {
                    foreach (object obj in list)
                    {
                        if (type.IsInstanceOfType(obj))
                        {
                            result.Add(obj);
                        }
                    }
                }
                return(result);
            }
            else
            {
                if (type.IsInstanceOfType(annotations))
                {
                    return new object[] { annotations }
                }
                ;
                else
                {
                    return(Enumerable.Empty <object>());
                }
            }
        }
コード例 #34
0
        public virtual void RemoveAnnotations(Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
retry:      // Retry until successful
            object oldAnnotations = this.annotations;
            AnnotationList list = oldAnnotations as AnnotationList;

            if (list != null)
            {
                lock (list)
                    list.RemoveAll(type.IsInstanceOfType);
            }
            else if (type.IsInstanceOfType(oldAnnotations))
            {
                if (Interlocked.CompareExchange(ref this.annotations, null, oldAnnotations) != oldAnnotations)
                {
                    // Operation failed (some other thread wrote to this.annotations first)
                    goto retry;
                }
            }
        }
コード例 #35
0
ファイル: AnnotationTests.cs プロジェクト: sillsdev/machine
        public void Remove()
        {
            var annList = new AnnotationList<int>(_spanFactory);
            annList.Add(0, 1, FeatureStruct.New().Value);
            annList.Add(9, 10, FeatureStruct.New().Value);
            annList.Add(24, 25, FeatureStruct.New().Value);
            annList.Add(49, 50, FeatureStruct.New().Value);
            annList.Add(99, 100, FeatureStruct.New().Value);

            annList.Remove(annList.First);
            Assert.AreEqual(4, annList.Count);
            Assert.AreEqual(_spanFactory.Create(9, 10), annList.First.Span);

            annList.Remove(annList.Last);
            Assert.AreEqual(3, annList.Count);
            Assert.AreEqual(_spanFactory.Create(49, 50), annList.Last.Span);

            annList.Remove(annList.First.Next);
            Assert.AreEqual(2, annList.Count);
            annList.Remove(annList.First);
            Assert.AreEqual(1, annList.Count);
            annList.Remove(annList.First);
            Assert.AreEqual(0, annList.Count);

            annList.Add(0, 1, FeatureStruct.New().Value);
            annList.Add(9, 10, FeatureStruct.New().Value);
            annList.Add(49, 50, FeatureStruct.New().Value);
            annList.Add(69, 70, FeatureStruct.New().Value);
            annList.Add(99, 100, FeatureStruct.New().Value);
            annList.Add(0, 49, FeatureStruct.New().Value);
            annList.Add(51, 100, FeatureStruct.New().Value);

            annList.Remove(annList.First);
            Assert.AreEqual(4, annList.Count);
            annList.Remove(annList.Last, false);
            Assert.AreEqual(3, annList.Count);
        }
コード例 #36
0
 static string GetRelativeCodePath(AnnotationList list)
 {
     return list.Filename.Substring(Program.Config.WebRoot.Length + 1);
 }
コード例 #37
0
        private string CreateCommentedCode(AnnotationList annotations)
        {
            var file = annotations.Filename + ".phpvhbackup";

            if (!File.Exists(file))
            {
                Cli.WriteLine("Could not find ~Red~{0}~R~", file);
                return null;
            }

            var code = File.ReadAllText(file);

            var isPhpless = Regex.Matches(code, @"<\?[^=]").Count == 0;

            string commentedCode;

            if (isPhpless)
            {
                var annot = new Annotation() { HitCount = annotations.Items.First().HitCount };
                commentedCode = CreateComment(annot) + code;
            }
            else
            {
                commentedCode = annotations.Items
                    .OrderByDescending(z => z.Index)
                    .Select(z => new
                    {
                        Index = z.Index,
                        Comment = CreateComment(z)
                    })
                    .Where(z => z.Index < code.Length)
                    .Aggregate(
                        new StringBuilder(code),
                        (sb, z) => sb.Insert(z.Index, z.Comment))
                    .ToString();
            }

            return commentedCode;
        }
コード例 #38
0
        public void AnnotateCode_VariableVariable_AddsNewAnnotationToAnnotationTable()
        {
            _annotator.AnnotateCode(VariableVariableFile, VariableVariablePhp, VariableVariableTokens);

            var expected = new AnnotationList(VariableVariableFile);
            expected.Add(new Annotation(0, 5, 0));

            Assert.AreEqual(expected, _annotator.AnnotationTable[VariableVariableFile]);
        }
コード例 #39
0
        public void AnnotateCode_TryCatchStatement_AddsNewAnnotationsToAnnotationTable()
        {
            _annotator.AnnotateCode(TryCatchStatementFile, TryCatchStatementPhp, TryCatchStatementTokens);

            var expected = new AnnotationList(TryCatchStatementFile);
            expected.Add(new Annotation(0, 57, 0));
            expected.Add(new Annotation(1, 26, 0));
            expected.Add(new Annotation(2, 6, 0));
            expected.Add(new Annotation(3, 2, 0));

            Assert.AreEqual(expected, _annotator.AnnotationTable[TryCatchStatementFile]);
        }
コード例 #40
0
ファイル: AnnotationTests.cs プロジェクト: sillsdev/machine
        public void Find()
        {
            var annList = new AnnotationList<int>(_spanFactory);
            annList.Add(1, 2, FeatureStruct.New().Value);
            annList.Add(9, 10, FeatureStruct.New().Value);
            annList.Add(24, 25, FeatureStruct.New().Value);
            annList.Add(49, 50, FeatureStruct.New().Value);
            annList.Add(99, 100, FeatureStruct.New().Value);
            annList.Add(99, 100, FeatureStruct.New().Value);
            annList.Add(new Annotation<int>(_spanFactory.Create(20, 70), FeatureStruct.New().Value), false);

            Annotation<int> result;
            Assert.IsFalse(annList.Find(0, out result));
            Assert.AreSame(annList.Begin, result);

            Assert.IsTrue(annList.Find(1, out result));
            Assert.AreSame(annList.First, result);

            Assert.IsFalse(annList.Find(100, out result));
            Assert.AreSame(annList.Last, result);

            Assert.IsFalse(annList.Find(101, out result));
            Assert.AreSame(annList.Last, result);

            Assert.IsFalse(annList.Find(30, out result));
            Assert.AreSame(annList.ElementAt(3), result);

            Assert.IsTrue(annList.Find(9, out result));
            Assert.AreSame(annList.First.Next, result);

            Assert.IsFalse(annList.Find(101, Direction.RightToLeft, out result));
            Assert.AreSame(annList.End, result);

            Assert.IsTrue(annList.Find(100, Direction.RightToLeft, out result));
            Assert.AreSame(annList.Last, result);

            Assert.IsFalse(annList.Find(1, Direction.RightToLeft, out result));
            Assert.AreSame(annList.First, result);

            Assert.IsFalse(annList.Find(0, Direction.RightToLeft, out result));
            Assert.AreSame(annList.First, result);

            Assert.IsFalse(annList.Find(15, Direction.RightToLeft, out result));
            Assert.AreSame(annList.ElementAt(2), result);

            Assert.IsTrue(annList.Find(10, Direction.RightToLeft, out result));
            Assert.AreSame(annList.First.Next, result);
        }
コード例 #41
0
        public void AnnotateCode_NoPhpCode_AddsNewAnnotationToAnnotationTable()
        {
            _annotator.AnnotateCode(NoPhpCodeFile, NoPhpCodePhp, NoPhpCodeTokens);

            var expected = new AnnotationList(NoPhpCodeFile);
            expected.Add(new Annotation(0, 6, 0));

            Assert.AreEqual(expected, _annotator.AnnotationTable[NoPhpCodeFile]);
        }
コード例 #42
0
ファイル: Session.cs プロジェクト: katadam/wockets
        public Session Merge(Session session_input)
        {
            Session a = this.copy();
            Session b = session_input.copy();

            AnnotationList aData = a.annotations;
            AnnotationList bData = b.annotations;

            Session output = this.copy();
            AnnotationList tempOutput = new AnnotationList();

            int aCounter = 0;
            int bCounter = 0;

            string unknown_label = "unknown";

            Annotation a_ann = null;
            Annotation b_ann = null;

            Annotation prev_a_ann = null;
            Annotation prev_b_ann = null;

            #region initialize previous annotations

            if (aData.Count > 0)
            {
                prev_a_ann = (Annotation)aData[0].copy();
                prev_a_ann._StartUnix = 0;
                prev_a_ann._EndUnix = 0;
            }

            if (bData.Count > 0)
            {
                prev_b_ann = (Annotation)bData[0].copy();
                prev_b_ann._StartUnix = 0;
                prev_b_ann._EndUnix = 0;
            }

            #endregion

            #region loop all the annotations until the shortest list finishes

            while ((aCounter < aData.Count && bCounter < bData.Count) &&
                    (aData.Count > 0 && bData.Count > 0))
            {
                a_ann = ((Annotation)aData[aCounter]).copy();
                b_ann = ((Annotation)bData[bCounter]).copy();

                double start1 = a_ann._StartUnix;
                double start2 = b_ann._StartUnix;

                double end1 = a_ann._EndUnix;
                double end2 = b_ann._EndUnix;

                //no intersection so add the first annotation
                if (end1 <= start2 || end2 <= start1)
                {

                    #region code
                    //check if annotation a happens first
                    if (a_ann._StartUnix < b_ann._StartUnix)
                    {

                        #region add record 1 ==> start1 < start2, Case 1
                        //------------ add record one ------------------

                        // the label overlaps since the begining
                        if (start1 >= prev_b_ann._StartUnix)
                        {

                            #region

                            Annotation rec1 = a_ann.copy();

                            // add the intersection with the previous label
                            if (start1 < prev_b_ann._EndUnix)
                            {
                                // add the itersection with the previous label
                                foreach (Activity act in prev_b_ann.Activities)
                                { rec1.Activities.Add(act); }

                                if (prev_b_ann._EndUnix < end1)
                                {
                                    rec1._EndDate = prev_b_ann._EndDate;
                                    rec1._EndHour = prev_b_ann._EndHour;
                                    rec1._EndMinute = prev_b_ann._EndMinute;
                                    rec1._EndSecond = prev_b_ann._EndSecond;
                                    rec1._EndMillisecond = prev_b_ann._EndMillisecond;
                                    rec1._EndUnix = prev_b_ann._EndUnix;
                                }

                                tempOutput.Add(rec1);

                                //check if there is a segment remaining to be synchronized
                                //if (prev_b_ann._EndUnix < b_ann._StartUnix)
                                if (prev_b_ann._EndUnix < end1)
                                {
                                    Annotation rec1_rm = a_ann.copy();

                                    rec1_rm._StartDate = prev_b_ann._EndDate;
                                    rec1_rm._StartHour = prev_b_ann._EndHour;
                                    rec1_rm._StartMinute = prev_b_ann._EndMinute;
                                    rec1_rm._StartSecond = prev_b_ann._EndSecond;
                                    rec1_rm._StartMillisecond = prev_b_ann._EndMillisecond;
                                    rec1_rm._StartUnix = prev_b_ann._EndUnix;

                                    rec1_rm.Activities.Add(new Activity(unknown_label, b_ann.Activities[0]._Category));

                                    tempOutput.Add(rec1_rm);

                                    #region update last record

                                    aData[aCounter]._StartDate = prev_b_ann._EndDate;
                                    aData[aCounter]._StartHour = prev_b_ann._EndHour;
                                    aData[aCounter]._StartMinute = prev_b_ann._EndMinute;
                                    aData[aCounter]._StartSecond = prev_b_ann._EndSecond;
                                    aData[aCounter]._StartMillisecond = prev_b_ann._EndMillisecond;
                                    aData[aCounter]._StartUnix = prev_b_ann._EndUnix;

                                    #endregion

                                }

                            }
                            else // the segment is not overlapping with prev_label, add unknown_label
                            {
                                rec1.Activities.Add(new Activity(unknown_label, b_ann.Activities[0]._Category));

                                tempOutput.Add(rec1);

                            }

                            #endregion

                        }
                        else   //(start1 < prev_b_ann._StartUnix)
                        {

                            #region

                            // case starts are different
                            Annotation rec1 = a_ann.copy();

                            //the segment is not overlapping with the first part of the prev_label, add unknown_label
                            //*** I need to check if it is not necessary to come back another register back
                            //*** to check for overlaps
                            rec1.Activities.Add(new Activity(unknown_label, b_ann.Activities[0]._Category));

                            if (end1 > prev_b_ann._StartUnix)
                            {
                                rec1._EndDate = prev_b_ann._StartDate;
                                rec1._EndHour = prev_b_ann._StartHour;
                                rec1._EndMinute = prev_b_ann._StartMinute;
                                rec1._EndSecond = prev_b_ann._StartSecond;
                                rec1._EndMillisecond = prev_b_ann._StartMillisecond;
                                rec1._EndUnix = prev_b_ann._StartUnix;
                            }

                            tempOutput.Add(rec1);

                            if (end1 > prev_b_ann._StartUnix)
                            {
                                // Now add the segment intersecting with previous_b_label
                                Annotation rec2 = a_ann.copy();

                                // add the intersection with the previous label
                                if (end1 <= prev_b_ann._EndUnix)
                                {

                                    rec2._StartDate = prev_b_ann._StartDate;
                                    rec2._StartHour = prev_b_ann._StartHour;
                                    rec2._StartMinute = prev_b_ann._StartMinute;
                                    rec2._StartSecond = prev_b_ann._StartSecond;
                                    rec2._StartMillisecond = prev_b_ann._StartMillisecond;
                                    rec2._StartUnix = prev_b_ann._StartUnix;

                                    // add the itersection with the previous label
                                    foreach (Activity act in prev_b_ann.Activities)
                                    { rec2.Activities.Add(act); }

                                    tempOutput.Add(rec2);

                                    #region update last record

                                    aData[aCounter]._StartDate = prev_b_ann._StartDate;
                                    aData[aCounter]._StartHour = prev_b_ann._StartHour;
                                    aData[aCounter]._StartMinute = prev_b_ann._StartMinute;
                                    aData[aCounter]._StartSecond = prev_b_ann._StartSecond;
                                    aData[aCounter]._StartMillisecond = prev_b_ann._StartMillisecond;
                                    aData[aCounter]._StartUnix = prev_b_ann._StartUnix;

                                    #endregion

                                }
                                else if (end1 > prev_b_ann._EndUnix)
                                {
                                    rec2._StartDate = prev_b_ann._StartDate;
                                    rec2._StartHour = prev_b_ann._StartHour;
                                    rec2._StartMinute = prev_b_ann._StartMinute;
                                    rec2._StartSecond = prev_b_ann._StartSecond;
                                    rec2._StartMillisecond = prev_b_ann._StartMillisecond;
                                    rec2._StartUnix = prev_b_ann._StartUnix;

                                    rec2._EndDate = prev_b_ann._EndDate;
                                    rec2._EndHour = prev_b_ann._EndHour;
                                    rec2._EndMinute = prev_b_ann._EndMinute;
                                    rec2._EndSecond = prev_b_ann._EndSecond;
                                    rec2._EndMillisecond = prev_b_ann._EndMillisecond;
                                    rec2._EndUnix = prev_b_ann._EndUnix;

                                    // add the itersection with the previous label
                                    foreach (Activity act in prev_b_ann.Activities)
                                    { rec2.Activities.Add(act); }

                                    tempOutput.Add(rec2);

                                    // add the remaining from a_label
                                    Annotation rec1_rm = a_ann.copy();

                                    rec1_rm._StartDate = prev_b_ann._EndDate;
                                    rec1_rm._StartHour = prev_b_ann._EndHour;
                                    rec1_rm._StartMinute = prev_b_ann._EndMinute;
                                    rec1_rm._StartSecond = prev_b_ann._EndSecond;
                                    rec1_rm._StartMillisecond = prev_b_ann._EndMillisecond;
                                    rec1_rm._StartUnix = prev_b_ann._EndUnix;

                                    rec1_rm.Activities.Add(new Activity(unknown_label, b_ann.Activities[0]._Category));

                                    tempOutput.Add(rec1_rm);

                                    #region update last record

                                    aData[aCounter]._StartDate = prev_b_ann._EndDate;
                                    aData[aCounter]._StartHour = prev_b_ann._EndHour;
                                    aData[aCounter]._StartMinute = prev_b_ann._EndMinute;
                                    aData[aCounter]._StartSecond = prev_b_ann._EndSecond;
                                    aData[aCounter]._StartMillisecond = prev_b_ann._EndMillisecond;
                                    aData[aCounter]._StartUnix = prev_b_ann._EndUnix;

                                    #endregion

                                }
                            }

                            #endregion

                        }

                        #endregion

                        //prev_a_ann = a_ann;
                        prev_a_ann = (Annotation)aData[aCounter];
                        aCounter++;

                    }
                    else
                    {

                        #region add record 1 ==> start2 < start1, Case 1
                        //------------ add record one ------------------

                        // the label overlaps since the begining
                        if (start2 >= prev_a_ann._StartUnix)
                        {

                            #region

                            Annotation rec1 = b_ann.copy();
                            rec1.Activities.Clear();

                            // add the intersection with the previous label
                            if (start2 < prev_a_ann._EndUnix)
                            {
                                // add the itersection with the previous label
                                foreach (Activity act in prev_a_ann.Activities)
                                { rec1.Activities.Add(act); }

                                // add the label activities
                                foreach (Activity act in b_ann.Activities)
                                { rec1.Activities.Add(act); }

                                if (prev_a_ann._EndUnix < end2)
                                {
                                    rec1._EndDate = prev_a_ann._EndDate;
                                    rec1._EndHour = prev_a_ann._EndHour;
                                    rec1._EndMinute = prev_a_ann._EndMinute;
                                    rec1._EndSecond = prev_a_ann._EndSecond;
                                    rec1._EndMillisecond = prev_a_ann._EndMillisecond;
                                    rec1._EndUnix = prev_a_ann._EndUnix;
                                }

                                tempOutput.Add(rec1);

                                //check if there is a segment remaining to be synchronized
                                //if (prev_b_ann._EndUnix < b_ann._StartUnix)
                                if (prev_a_ann._EndUnix < end2)
                                {
                                    Annotation rec1_rm = b_ann.copy();
                                    rec1_rm.Activities.Clear();

                                    rec1_rm._StartDate = prev_a_ann._EndDate;
                                    rec1_rm._StartHour = prev_a_ann._EndHour;
                                    rec1_rm._StartMinute = prev_a_ann._EndMinute;
                                    rec1_rm._StartSecond = prev_a_ann._EndSecond;
                                    rec1_rm._StartMillisecond = prev_a_ann._EndMillisecond;
                                    rec1_rm._StartUnix = prev_a_ann._EndUnix;

                                    // indicate no intersection with previous label
                                    rec1_rm.Activities.Add(new Activity(unknown_label, a_ann.Activities[0]._Category));

                                    // add the label activities
                                    foreach (Activity act in b_ann.Activities)
                                    { rec1_rm.Activities.Add(act); }

                                    tempOutput.Add(rec1_rm);

                                    #region update last record

                                    bData[bCounter]._StartDate = prev_a_ann._EndDate;
                                    bData[bCounter]._StartHour = prev_a_ann._EndHour;
                                    bData[bCounter]._StartMinute = prev_a_ann._EndMinute;
                                    bData[bCounter]._StartSecond = prev_a_ann._EndSecond;
                                    bData[bCounter]._StartMillisecond = prev_a_ann._EndMillisecond;
                                    bData[bCounter]._StartUnix = prev_a_ann._EndUnix;

                                    #endregion

                                }

                            }
                            else // the segment is not overlapping with prev_label, add unknown_label
                            {
                                // indicate no intersection with previous label
                                rec1.Activities.Add(new Activity(unknown_label, a_ann.Activities[0]._Category));

                                // add the label activities
                                foreach (Activity act in b_ann.Activities)
                                { rec1.Activities.Add(act); }

                                tempOutput.Add(rec1);

                            }

                            #endregion

                        }
                        else   //(start2 < prev_a_ann._StartUnix)
                        {

                            #region

                            // case starts are different
                            Annotation rec1 = b_ann.copy();
                            rec1.Activities.Clear();

                            //the segment is not overlapping with the first part of the prev_label, add unknown_label
                            //*** I need to check if it is not necessary to come back another register back
                            //*** to check for overlaps
                            rec1.Activities.Add(new Activity(unknown_label, a_ann.Activities[0]._Category));

                            // add the label activities
                            foreach (Activity act in b_ann.Activities)
                            { rec1.Activities.Add(act); }

                            if (end2 > prev_a_ann._StartUnix)
                            {
                                rec1._EndDate = prev_a_ann._StartDate;
                                rec1._EndHour = prev_a_ann._StartHour;
                                rec1._EndMinute = prev_a_ann._StartMinute;
                                rec1._EndSecond = prev_a_ann._StartSecond;
                                rec1._EndMillisecond = prev_a_ann._StartMillisecond;
                                rec1._EndUnix = prev_a_ann._StartUnix;
                            }

                            tempOutput.Add(rec1);

                            if (end2 > prev_a_ann._StartUnix)
                            {

                                // Add the segment intersecting with previous_b_label
                                Annotation rec2 = b_ann.copy();
                                rec2.Activities.Clear();

                                // add the intersection with the previous label
                                if (end2 <= prev_a_ann._EndUnix)
                                {

                                    rec2._StartDate = prev_a_ann._StartDate;
                                    rec2._StartHour = prev_a_ann._StartHour;
                                    rec2._StartMinute = prev_a_ann._StartMinute;
                                    rec2._StartSecond = prev_a_ann._StartSecond;
                                    rec2._StartMillisecond = prev_a_ann._StartMillisecond;
                                    rec2._StartUnix = prev_a_ann._StartUnix;

                                    // add the intersection with the previous label
                                    foreach (Activity act in prev_a_ann.Activities)
                                    { rec2.Activities.Add(act); }

                                    // add the label activities
                                    foreach (Activity act in b_ann.Activities)
                                    { rec2.Activities.Add(act); }

                                    tempOutput.Add(rec2);

                                    #region update last record

                                    bData[bCounter]._StartDate = prev_a_ann._StartDate;
                                    bData[bCounter]._StartHour = prev_a_ann._StartHour;
                                    bData[bCounter]._StartMinute = prev_a_ann._StartMinute;
                                    bData[bCounter]._StartSecond = prev_a_ann._StartSecond;
                                    bData[bCounter]._StartMillisecond = prev_a_ann._StartMillisecond;
                                    bData[bCounter]._StartUnix = prev_a_ann._StartUnix;

                                    #endregion

                                }
                                else //(end2 > prev_a_ann._EndUnix)
                                {
                                    rec2._StartDate = prev_a_ann._StartDate;
                                    rec2._StartHour = prev_a_ann._StartHour;
                                    rec2._StartMinute = prev_a_ann._StartMinute;
                                    rec2._StartSecond = prev_a_ann._StartSecond;
                                    rec2._StartMillisecond = prev_a_ann._StartMillisecond;
                                    rec2._StartUnix = prev_a_ann._StartUnix;

                                    rec2._EndDate = prev_a_ann._EndDate;
                                    rec2._EndHour = prev_a_ann._EndHour;
                                    rec2._EndMinute = prev_a_ann._EndMinute;
                                    rec2._EndSecond = prev_a_ann._EndSecond;
                                    rec2._EndMillisecond = prev_a_ann._EndMillisecond;
                                    rec2._EndUnix = prev_a_ann._EndUnix;

                                    // add the intersection with the previous label
                                    foreach (Activity act in prev_a_ann.Activities)
                                    { rec2.Activities.Add(act); }

                                    // add the label activities
                                    foreach (Activity act in b_ann.Activities)
                                    { rec2.Activities.Add(act); }

                                    tempOutput.Add(rec2);

                                    // add the remaining from a_label
                                    Annotation rec1_rm = b_ann.copy();
                                    rec1_rm.Activities.Clear();

                                    rec1_rm._StartDate = prev_a_ann._EndDate;
                                    rec1_rm._StartHour = prev_a_ann._EndHour;
                                    rec1_rm._StartMinute = prev_a_ann._EndMinute;
                                    rec1_rm._StartSecond = prev_a_ann._EndSecond;
                                    rec1_rm._StartMillisecond = prev_a_ann._EndMillisecond;
                                    rec1_rm._StartUnix = prev_a_ann._EndUnix;

                                    // indicate no intersection with previous label
                                    rec1_rm.Activities.Add(new Activity(unknown_label, a_ann.Activities[0]._Category));

                                    // add the label activities
                                    foreach (Activity act in b_ann.Activities)
                                    { rec1_rm.Activities.Add(act); }

                                    tempOutput.Add(rec1_rm);

                                    #region update last record

                                    bData[bCounter]._StartDate = prev_a_ann._EndDate;
                                    bData[bCounter]._StartHour = prev_a_ann._EndHour;
                                    bData[bCounter]._StartMinute = prev_a_ann._EndMinute;
                                    bData[bCounter]._StartSecond = prev_a_ann._EndSecond;
                                    bData[bCounter]._StartMillisecond = prev_a_ann._EndMillisecond;
                                    bData[bCounter]._StartUnix = prev_a_ann._EndUnix;

                                    #endregion

                                }

                            }

                            #endregion

                        }

                        #endregion

                        //  prev_b_ann = b_ann;
                        prev_b_ann = (Annotation)bData[bCounter];
                        bCounter++;

                    }

                    #endregion

                }
                //else there is intersection
                else
                {

                    // perfect alignment
                    if (start1 == start2 && end1 == end2)
                    {
                        #region code

                        Annotation rec1 = a_ann.copy();

                        // add the itersection with the b_ann label
                        foreach (Activity act in b_ann.Activities)
                        { rec1.Activities.Add(act); }

                        tempOutput.Add(rec1);

                        //prev_a_ann = a_ann; //   prev_a_ann=(Annotation)aData[aCounter]
                        //prev_b_ann = b_ann; //   prev_b_ann=(Annotation)bData[bCounter]

                        prev_a_ann = (Annotation)aData[aCounter];
                        prev_b_ann = (Annotation)bData[bCounter];

                        aCounter++;
                        bCounter++;

                        #endregion

                    }
                    //if (start1 == end1 && start2 != end2) //use start2 and end2 as constraints
                    else if (start1 == start2 && end1 != end2)
                    {

                        #region code

                        if (end1 < end2)
                        {
                            //------------ add record one ------------------
                            Annotation rec1 = a_ann.copy();

                            // add the itersection with the b_ann label
                            foreach (Activity act in b_ann.Activities)
                            { rec1.Activities.Add(act); }

                            tempOutput.Add(rec1);

                            bData[bCounter]._StartDate = a_ann._EndDate;

                            bData[bCounter]._StartHour = a_ann._EndHour;
                            bData[bCounter]._StartMinute = a_ann._EndMinute;
                            bData[bCounter]._StartSecond = a_ann._EndSecond;
                            bData[bCounter]._StartMillisecond = a_ann._EndMillisecond;
                            bData[bCounter]._StartUnix = a_ann._EndUnix;

                            //------- increase counters -----------------
                            //prev_a_ann = a_ann;
                            prev_a_ann = (Annotation)aData[aCounter];

                            aCounter++;

                        }
                        else if (end1 > end2)
                        {
                            //------------ add record one ------------------

                            Annotation rec1 = a_ann.copy();

                            // add the itersection with the b_ann label
                            foreach (Activity act in b_ann.Activities)
                            { rec1.Activities.Add(act); }

                            rec1._EndDate = b_ann._EndDate;
                            rec1._EndHour = b_ann._EndHour;
                            rec1._EndMinute = b_ann._EndMinute;
                            rec1._EndSecond = b_ann._EndSecond;
                            rec1._EndMillisecond = b_ann._EndMillisecond;
                            rec1._EndUnix = b_ann._EndUnix;

                            tempOutput.Add(rec1);

                            //----------- create "last" record -> open label -------------------

                            aData[aCounter]._StartDate = b_ann._EndDate;
                            aData[aCounter]._StartHour = b_ann._EndHour;
                            aData[aCounter]._StartMinute = b_ann._EndMinute;
                            aData[aCounter]._StartSecond = b_ann._EndSecond;
                            aData[aCounter]._StartMillisecond = b_ann._EndMillisecond;
                            aData[aCounter]._StartUnix = b_ann._EndUnix;

                            //------- increase counters -----------------

                            //prev_b_ann = b_ann;
                            prev_b_ann = (Annotation)bData[bCounter];

                            bCounter++;
                        }

                        #endregion

                    }
                    // else if (start1 != end1 && start2 == end2)  //use start1 and end1 as constraints
                    else if (start1 != start2 && end1 == end2)  //use start1 and end1 as constraints
                    {

                        #region Code

                        if (start1 < start2)
                        {

                            #region add record 1 ==> start1< start2, Case 1

                            //------------ add record one ------------------
                            Annotation rec1 = a_ann.copy();

                            // add the intersection with the prevoius label
                            if (start1 < prev_b_ann._EndUnix)
                            {

                                rec1._EndDate = prev_b_ann._EndDate;

                                rec1._EndHour = prev_b_ann._EndHour;
                                rec1._EndMinute = prev_b_ann._EndMinute;
                                rec1._EndSecond = prev_b_ann._EndSecond;
                                rec1._EndMillisecond = prev_b_ann._EndMillisecond;
                                rec1._EndUnix = prev_b_ann._EndUnix;

                                // add the itersection with the previous label
                                foreach (Activity act in prev_b_ann.Activities)
                                { rec1.Activities.Add(act); }

                                tempOutput.Add(rec1);

                                //check if there is a segment remaining to be synchronized
                                if (prev_b_ann._EndUnix < b_ann._StartUnix)
                                {
                                    Annotation rec1_rm = a_ann.copy();

                                    rec1_rm._StartDate = prev_b_ann._EndDate;
                                    rec1_rm._StartHour = prev_b_ann._EndHour;
                                    rec1_rm._StartMinute = prev_b_ann._EndMinute;
                                    rec1_rm._StartSecond = prev_b_ann._EndSecond;
                                    rec1_rm._StartMillisecond = prev_b_ann._EndMillisecond;
                                    rec1_rm._StartUnix = prev_b_ann._EndUnix;

                                    rec1_rm._EndDate = b_ann._StartDate;
                                    rec1_rm._EndHour = b_ann._StartHour;
                                    rec1_rm._EndMinute = b_ann._StartMinute;
                                    rec1_rm._EndSecond = b_ann._StartSecond;
                                    rec1_rm._EndMillisecond = b_ann._StartMillisecond;
                                    rec1_rm._EndUnix = b_ann._StartUnix;

                                    rec1_rm.Activities.Add(new Activity(unknown_label, b_ann.Activities[0]._Category));

                                    tempOutput.Add(rec1_rm);

                                }

                            }
                            else // the segment is not overlapping with prev_label, add unknown_label
                            {
                                rec1.Activities.Add(new Activity(unknown_label, b_ann.Activities[0]._Category));

                                rec1._EndDate = b_ann._StartDate;
                                rec1._EndHour = b_ann._StartHour;
                                rec1._EndMinute = b_ann._StartMinute;
                                rec1._EndSecond = b_ann._StartSecond;
                                rec1._EndMillisecond = b_ann._StartMillisecond;
                                rec1._EndUnix = b_ann._StartUnix;

                                tempOutput.Add(rec1);
                            }

                            #endregion

                            #region  add record two

                            //----------- add record 2 -------------------

                            Annotation rec2 = a_ann.copy();

                            // add the itersection with the b_ann label
                            foreach (Activity act in b_ann.Activities)
                            { rec2.Activities.Add(act); }

                            rec2._StartDate = b_ann._StartDate;
                            rec2._StartHour = b_ann._StartHour;
                            rec2._StartMinute = b_ann._StartMinute;
                            rec2._StartSecond = b_ann._StartSecond;
                            rec2._StartMillisecond = b_ann._StartMillisecond;
                            rec2._StartUnix = b_ann._StartUnix;

                            tempOutput.Add(rec2);

                            #endregion

                            #region update changes

                            aData[aCounter]._StartDate = b_ann._StartDate;
                            aData[aCounter]._StartHour = b_ann._StartHour;
                            aData[aCounter]._StartMinute = b_ann._StartMinute;
                            aData[aCounter]._StartSecond = b_ann._StartSecond;
                            aData[aCounter]._StartMillisecond = b_ann._StartMillisecond;
                            aData[aCounter]._StartUnix = b_ann._StartUnix;

                            #endregion

                        }
                        else if (start1 > start2)
                        {
                            #region add record 1 ==> start2 < start1, Case 1

                            //------------ add record one ------------------
                            Annotation rec1 = b_ann.copy();
                            rec1.Activities.Clear();

                            // add the intersection with the prevoius label
                            if (start2 < prev_a_ann._EndUnix)
                            {
                                rec1._EndDate = prev_a_ann._EndDate;
                                rec1._EndHour = prev_a_ann._EndHour;
                                rec1._EndMinute = prev_a_ann._EndMinute;
                                rec1._EndSecond = prev_a_ann._EndSecond;
                                rec1._EndMillisecond = prev_a_ann._EndMillisecond;
                                rec1._EndUnix = prev_a_ann._EndUnix;

                                // add the intersection with the previous label
                                foreach (Activity act in prev_a_ann.Activities)
                                { rec1.Activities.Add(act); }

                                // add the b labels in order
                                foreach (Activity act in b_ann.Activities)
                                { rec1.Activities.Add(act); }

                                tempOutput.Add(rec1);

                                //check if there is a segment remaining to be synchronized
                                if (prev_a_ann._EndUnix < a_ann._StartUnix)
                                {
                                    Annotation rec1_rm = b_ann.copy();
                                    rec1_rm.Activities.Clear();

                                    rec1_rm._StartDate = prev_a_ann._EndDate;
                                    rec1_rm._StartHour = prev_a_ann._EndHour;
                                    rec1_rm._StartMinute = prev_a_ann._EndMinute;
                                    rec1_rm._StartSecond = prev_a_ann._EndSecond;
                                    rec1_rm._StartMillisecond = prev_a_ann._EndMillisecond;
                                    rec1_rm._StartUnix = prev_a_ann._EndUnix;

                                    rec1_rm._EndDate = a_ann._StartDate;
                                    rec1_rm._EndHour = a_ann._StartHour;
                                    rec1_rm._EndMinute = a_ann._StartMinute;
                                    rec1_rm._EndSecond = a_ann._StartSecond;
                                    rec1_rm._EndMillisecond = a_ann._StartMillisecond;
                                    rec1_rm._EndUnix = a_ann._StartUnix;

                                    // add none, check order
                                    rec1_rm.Activities.Add(new Activity(unknown_label, a_ann.Activities[0]._Category));

                                    // add the b labels in order
                                    foreach (Activity act in b_ann.Activities)
                                    { rec1_rm.Activities.Add(act); }

                                    tempOutput.Add(rec1_rm);

                                }

                            }
                            else // the segment is not overlapping with prev_label, add unknown_label
                            {
                                // add none, check order
                                rec1.Activities.Add(new Activity(unknown_label, a_ann.Activities[0]._Category));

                                // add the b labels in order
                                foreach (Activity act in b_ann.Activities)
                                { rec1.Activities.Add(act); }

                                rec1._EndDate = a_ann._StartDate;
                                rec1._EndHour = a_ann._StartHour;
                                rec1._EndMinute = a_ann._StartMinute;
                                rec1._EndSecond = a_ann._StartSecond;
                                rec1._EndMillisecond = a_ann._StartMillisecond;
                                rec1._EndUnix = a_ann._StartUnix;

                                tempOutput.Add(rec1);
                            }

                            #endregion

                            #region  add record two

                            //----------- add record 2 -------------------

                            Annotation rec2 = a_ann.copy();

                            // add the itersection with the b_ann label
                            foreach (Activity act in b_ann.Activities)
                            { rec2.Activities.Add(act); }

                            tempOutput.Add(rec2);

                            #endregion

                            #region update changes

                            bData[bCounter]._StartDate = a_ann._StartDate;
                            bData[bCounter]._StartHour = a_ann._StartHour;
                            bData[bCounter]._StartMinute = a_ann._StartMinute;
                            bData[bCounter]._StartSecond = a_ann._StartSecond;
                            bData[bCounter]._StartMillisecond = a_ann._StartMillisecond;
                            bData[bCounter]._StartUnix = a_ann._StartUnix;

                            #endregion
                        }

                        //------- increase counters -----------------

                        //prev_a_ann = a_ann;
                        //prev_b_ann = b_ann;

                        prev_a_ann = (Annotation)aData[aCounter];
                        prev_b_ann = (Annotation)bData[bCounter];

                        aCounter++;
                        bCounter++;

                        #endregion

                    }
                    else if (start1 != start2 && end1 != end2)//use both start1 & end1, start2 & end2
                    {

                        #region code

                        if (start1 < start2)
                        {

                            #region add record 1

                            //------------ add record one ------------------
                            Annotation rec1 = a_ann.copy();

                            // add the intersection with the prevoius label
                            if (start1 < prev_b_ann._EndUnix)
                            {

                                rec1._EndDate = prev_b_ann._EndDate;

                                rec1._EndHour = prev_b_ann._EndHour;
                                rec1._EndMinute = prev_b_ann._EndMinute;
                                rec1._EndSecond = prev_b_ann._EndSecond;
                                rec1._EndMillisecond = prev_b_ann._EndMillisecond;
                                rec1._EndUnix = prev_b_ann._EndUnix;

                                // add the itersection with the previous label
                                foreach (Activity act in prev_b_ann.Activities)
                                { rec1.Activities.Add(act); }

                                tempOutput.Add(rec1);

                                //check if there is a segment remaining to be synchronized
                                if (prev_b_ann._EndUnix < b_ann._StartUnix)
                                {
                                    Annotation rec1_rm = a_ann.copy();

                                    rec1_rm._StartDate = prev_b_ann._EndDate;
                                    rec1_rm._StartHour = prev_b_ann._EndHour;
                                    rec1_rm._StartMinute = prev_b_ann._EndMinute;
                                    rec1_rm._StartSecond = prev_b_ann._EndSecond;
                                    rec1_rm._StartMillisecond = prev_b_ann._EndMillisecond;
                                    rec1_rm._StartUnix = prev_b_ann._EndUnix;

                                    rec1_rm._EndDate = b_ann._StartDate;
                                    rec1_rm._EndHour = b_ann._StartHour;
                                    rec1_rm._EndMinute = b_ann._StartMinute;
                                    rec1_rm._EndSecond = b_ann._StartSecond;
                                    rec1_rm._EndMillisecond = b_ann._StartMillisecond;
                                    rec1_rm._EndUnix = b_ann._StartUnix;

                                    rec1_rm.Activities.Add(new Activity(unknown_label, b_ann.Activities[0]._Category));

                                    tempOutput.Add(rec1_rm);

                                }

                            }
                            else // the segment is not overlapping with prev_label, add unknown_label
                            {
                                rec1.Activities.Add(new Activity(unknown_label, b_ann.Activities[0]._Category));

                                rec1._EndDate = b_ann._StartDate;
                                rec1._EndHour = b_ann._StartHour;
                                rec1._EndMinute = b_ann._StartMinute;
                                rec1._EndSecond = b_ann._StartSecond;
                                rec1._EndMillisecond = b_ann._StartMillisecond;
                                rec1._EndUnix = b_ann._StartUnix;

                                tempOutput.Add(rec1);
                            }

                            #endregion

                            #region add record 2

                            //----------- add record 2 -------------------
                            if (end1 < end2)
                            {

                                if (end1 > start2)
                                {
                                    Annotation rec2 = a_ann.copy();

                                    // add the itersection with the b_ann label
                                    //rec2.Activities.Add(new Activity(b_ann.Activities[0]._Name, b_ann.Activities[0]._Category));

                                    // add the itersection with the b_ann label
                                    foreach (Activity act in b_ann.Activities)
                                    { rec2.Activities.Add(act); }

                                    rec2._StartDate = b_ann._StartDate;
                                    rec2._StartHour = b_ann._StartHour;
                                    rec2._StartMinute = b_ann._StartMinute;
                                    rec2._StartSecond = b_ann._StartSecond;
                                    rec2._StartMillisecond = b_ann._StartMillisecond;
                                    rec2._StartUnix = b_ann._StartUnix;

                                    tempOutput.Add(rec2);

                                    //----------- create "last" record -> open label -------------------
                                    //last_ann = b_ann.copy();

                                    //b_ann._StartHour = a_ann._EndHour;
                                    //b_ann._StartMinute = a_ann._EndMinute;
                                    //b_ann._StartSecond = a_ann._EndSecond;
                                    //b_ann._StartMillisecond = a_ann._EndMillisecond;
                                    //b_ann._StartUnix = a_ann._EndUnix;

                                    bData[bCounter]._StartDate = a_ann._EndDate;
                                    bData[bCounter]._StartHour = a_ann._EndHour;
                                    bData[bCounter]._StartMinute = a_ann._EndMinute;
                                    bData[bCounter]._StartSecond = a_ann._EndSecond;
                                    bData[bCounter]._StartMillisecond = a_ann._EndMillisecond;
                                    bData[bCounter]._StartUnix = a_ann._EndUnix;
                                }

                                //------- increase counters -----------------
                                //prev_a_ann = a_ann;    //prev_a_ann=(Annotation)aData[aCounter]
                                prev_a_ann = (Annotation)aData[aCounter];

                                aCounter++;
                                //bCounter++;

                            }
                            else if (end1 > end2)
                            {
                                //Annotation rec2 = b_ann.copy();
                                // add the itersection with the a_ann label
                                //rec2.Activities.Clear();
                                //rec2.Activities.Add(new Activity(a_ann.Activities[0]._Name, a_ann.Activities[0]._Category));
                                //rec2.Activities.Add(new Activity(b_ann.Activities[0]._Name, b_ann.Activities[0]._Category));

                                if (end2 > start1)
                                {
                                    Annotation rec2 = a_ann.copy();

                                    // add the itersection with the b_ann label
                                    foreach (Activity act in b_ann.Activities)
                                    { rec2.Activities.Add(act); }

                                    rec2._StartDate = b_ann._StartDate;
                                    rec2._StartHour = b_ann._StartHour;
                                    rec2._StartMinute = b_ann._StartMinute;
                                    rec2._StartSecond = b_ann._StartSecond;
                                    rec2._StartMillisecond = b_ann._StartMillisecond;
                                    rec2._StartUnix = b_ann._StartUnix;

                                    rec2._EndDate = b_ann._EndDate;
                                    rec2._EndHour = b_ann._EndHour;
                                    rec2._EndMinute = b_ann._EndMinute;
                                    rec2._EndSecond = b_ann._EndSecond;
                                    rec2._EndMillisecond = b_ann._EndMillisecond;
                                    rec2._EndUnix = b_ann._EndUnix;

                                    tempOutput.Add(rec2);

                                    //----------- create "last" record -> open label -------------------
                                    // a_ann._StartHour = b_ann._EndHour;
                                    // a_ann._StartMinute = b_ann._EndMinute;
                                    // a_ann._StartSecond = b_ann._EndSecond;
                                    // a_ann._StartMillisecond = b_ann._EndMillisecond;
                                    // a_ann._StartUnix = b_ann._EndUnix;

                                    aData[aCounter]._StartDate = b_ann._EndDate;
                                    aData[aCounter]._StartHour = b_ann._EndHour;
                                    aData[aCounter]._StartMinute = b_ann._EndMinute;
                                    aData[aCounter]._StartSecond = b_ann._EndSecond;
                                    aData[aCounter]._StartMillisecond = b_ann._EndMillisecond;
                                    aData[aCounter]._StartUnix = b_ann._EndUnix;
                                }

                                //------- increase counters -----------------
                                //prev_b_ann = b_ann;
                                prev_b_ann = (Annotation)bData[bCounter];

                                //aCounter++;
                                bCounter++;

                            }

                            #endregion

                        }
                        else if (start1 > start2)
                        {

                            #region add record 1

                            //------------ add record one ------------------
                            Annotation rec1 = b_ann.copy();
                            rec1.Activities.Clear();

                            // add the intersection with the prevoius label
                            if (start2 < prev_a_ann._EndUnix)
                            {
                                rec1._EndDate = prev_a_ann._EndDate;
                                rec1._EndHour = prev_a_ann._EndHour;
                                rec1._EndMinute = prev_a_ann._EndMinute;
                                rec1._EndSecond = prev_a_ann._EndSecond;
                                rec1._EndMillisecond = prev_a_ann._EndMillisecond;
                                rec1._EndUnix = prev_a_ann._EndUnix;

                                // add the intersection with the previous label
                                foreach (Activity act in prev_a_ann.Activities)
                                { rec1.Activities.Add(act); }

                                // add the b labels in order
                                foreach (Activity act in b_ann.Activities)
                                { rec1.Activities.Add(act); }

                                tempOutput.Add(rec1);

                                //check if there is a segment remaining to be synchronized
                                if (prev_a_ann._EndUnix < a_ann._StartUnix)
                                {
                                    Annotation rec1_rm = b_ann.copy();
                                    rec1_rm.Activities.Clear();

                                    rec1_rm._StartDate = prev_a_ann._EndDate;
                                    rec1_rm._StartHour = prev_a_ann._EndHour;
                                    rec1_rm._StartMinute = prev_a_ann._EndMinute;
                                    rec1_rm._StartSecond = prev_a_ann._EndSecond;
                                    rec1_rm._StartMillisecond = prev_a_ann._EndMillisecond;
                                    rec1_rm._StartUnix = prev_a_ann._EndUnix;

                                    rec1_rm._EndDate = a_ann._StartDate;
                                    rec1_rm._EndHour = a_ann._StartHour;
                                    rec1_rm._EndMinute = a_ann._StartMinute;
                                    rec1_rm._EndSecond = a_ann._StartSecond;
                                    rec1_rm._EndMillisecond = a_ann._StartMillisecond;
                                    rec1_rm._EndUnix = a_ann._StartUnix;

                                    // add none, in order
                                    rec1_rm.Activities.Add(new Activity(unknown_label, a_ann.Activities[0]._Category));

                                    // add the b labels in order
                                    foreach (Activity act in b_ann.Activities)
                                    { rec1_rm.Activities.Add(act); }

                                    tempOutput.Add(rec1_rm);

                                }

                            }
                            else // the segment is not overlapping with prev_label, add unknown_label
                            {
                                // add none, check order
                                rec1.Activities.Add(new Activity(unknown_label, a_ann.Activities[0]._Category));

                                // add the b labels in order
                                foreach (Activity act in b_ann.Activities)
                                { rec1.Activities.Add(act); }

                                rec1._EndDate = a_ann._StartDate;
                                rec1._EndHour = a_ann._StartHour;
                                rec1._EndMinute = a_ann._StartMinute;
                                rec1._EndSecond = a_ann._StartSecond;
                                rec1._EndMillisecond = a_ann._StartMillisecond;
                                rec1._EndUnix = a_ann._StartUnix;

                                tempOutput.Add(rec1);
                            }

                            #endregion

                            #region add record 2

                            //----------- add record 2 -------------------
                            if (end1 < end2)
                            {

                                if (end1 > start2)
                                {
                                    Annotation rec2 = a_ann.copy();

                                    // add the itersection with the b_ann label
                                    //rec2.Activities.Add(new Activity(b_ann.Activities[0]._Name, b_ann.Activities[0]._Category));

                                    // add the itersection with the b_ann label
                                    foreach (Activity act in b_ann.Activities)
                                    { rec2.Activities.Add(act); }

                                    tempOutput.Add(rec2);

                                    //----------- create "last" record -> open label -------------------
                                    //last_ann = b_ann.copy();

                                    //b_ann._StartHour = a_ann._EndHour;
                                    //b_ann._StartMinute = a_ann._EndMinute;
                                    //b_ann._StartSecond = a_ann._EndSecond;
                                    //b_ann._StartMillisecond = a_ann._EndMillisecond;
                                    //b_ann._StartUnix = a_ann._EndUnix;

                                    bData[bCounter]._StartDate = a_ann._EndDate;
                                    bData[bCounter]._StartHour = a_ann._EndHour;
                                    bData[bCounter]._StartMinute = a_ann._EndMinute;
                                    bData[bCounter]._StartSecond = a_ann._EndSecond;
                                    bData[bCounter]._StartMillisecond = a_ann._EndMillisecond;
                                    bData[bCounter]._StartUnix = a_ann._EndUnix;
                                }

                                //------- increase counters -----------------
                                //prev_a_ann = a_ann;    //prev_a_ann=(Annotation)aData[aCounter]
                                prev_a_ann = (Annotation)aData[aCounter];

                                aCounter++;
                                //bCounter++;

                            }
                            else if (end1 > end2)
                            {
                                //Annotation rec2 = b_ann.copy();
                                // add the itersection with the a_ann label
                                //rec2.Activities.Clear();
                                //rec2.Activities.Add(new Activity(a_ann.Activities[0]._Name, a_ann.Activities[0]._Category));
                                //rec2.Activities.Add(new Activity(b_ann.Activities[0]._Name, b_ann.Activities[0]._Category));

                                if (end2 > start1)
                                {
                                    Annotation rec2 = a_ann.copy();

                                    // add the itersection with the b_ann label
                                    foreach (Activity act in b_ann.Activities)
                                    { rec2.Activities.Add(act); }

                                    rec2._EndDate = b_ann._EndDate;
                                    rec2._EndHour = b_ann._EndHour;
                                    rec2._EndMinute = b_ann._EndMinute;
                                    rec2._EndSecond = b_ann._EndSecond;
                                    rec2._EndMillisecond = b_ann._EndMillisecond;
                                    rec2._EndUnix = b_ann._EndUnix;

                                    tempOutput.Add(rec2);

                                    //----------- create "last" record -> open label -------------------
                                    // a_ann._StartHour = b_ann._EndHour;
                                    // a_ann._StartMinute = b_ann._EndMinute;
                                    // a_ann._StartSecond = b_ann._EndSecond;
                                    // a_ann._StartMillisecond = b_ann._EndMillisecond;
                                    // a_ann._StartUnix = b_ann._EndUnix;

                                    aData[aCounter]._StartDate = b_ann._EndDate;
                                    aData[aCounter]._StartHour = b_ann._EndHour;
                                    aData[aCounter]._StartMinute = b_ann._EndMinute;
                                    aData[aCounter]._StartSecond = b_ann._EndSecond;
                                    aData[aCounter]._StartMillisecond = b_ann._EndMillisecond;
                                    aData[aCounter]._StartUnix = b_ann._EndUnix;

                                }

                                //------- increase counters -----------------
                                //prev_b_ann = b_ann; //prev_b_ann=(Annotation)bData[bCounter]
                                prev_b_ann = (Annotation)bData[bCounter];

                                //aCounter++;
                                bCounter++;

                            }

                            #endregion

                        }

                        #endregion

                    }

                }
            }

            #endregion loop all the annotations until one of the list finishes

            #region loop all the remaining annotations

            if (aCounter >= aData.Count && bCounter < bData.Count)
            {

                for (int b_elem = bCounter; b_elem < bData.Count; b_elem++)
                {
                    Annotation temp_rec = bData[b_elem].copy();
                    temp_rec.Activities.Clear();

                    temp_rec.Activities.Add(new Activity(unknown_label, aData[0].Activities[0]._Category));
                    temp_rec.Activities.Add(bData[b_elem].Activities[0]);

                    tempOutput.Add(temp_rec);

                }
            }
            else if (aCounter < aData.Count && bCounter >= bData.Count)
            {
                for (int a_elem = aCounter; a_elem < aData.Count; a_elem++)
                {
                    tempOutput.Add(aData[a_elem]);
                    tempOutput[tempOutput.Count - 1].Activities.Add(new Activity(unknown_label, bData[0].Activities[0]._Category));

                }
            }

            #endregion

            output.annotations.Clear();

            //copy results back to hte data field of the output Annotation object
            foreach (Annotation obj in tempOutput)
            { output.annotations.Add(obj); }

            return output;
        }
コード例 #43
0
 static string GetPageFilename(AnnotationList list)
 {
     var md5 = new MD5CryptoServiceProvider();
     return md5.ComputeHash(list.Filename) + ".html";
 }
コード例 #44
0
ファイル: AnnotationTests.cs プロジェクト: sillsdev/machine
        public void GetNodes()
        {
            var annList = new AnnotationList<int>(_spanFactory);
            annList.Add(1, 2, FeatureStruct.New().Value);
            annList.Add(9, 10, FeatureStruct.New().Value);
            annList.Add(24, 25, FeatureStruct.New().Value);
            annList.Add(49, 50, FeatureStruct.New().Value);
            annList.Add(99, 100, FeatureStruct.New().Value);
            annList.Add(new Annotation<int>(_spanFactory.Create(20, 70), FeatureStruct.New().Value), false);

            Assert.IsFalse(annList.GetNodes(0, 1).Any());

            Assert.IsFalse(annList.GetNodes(100, 101).Any());

            Annotation<int>[] anns = annList.GetNodes(8, 52).ToArray();
            Assert.AreEqual(3, anns.Length);
            Assert.AreEqual(annList.First.Next, anns[0]);
            Assert.AreEqual(annList.Last.Prev, anns[2]);

            anns = annList.GetNodes(9, 10).ToArray();
            Assert.AreEqual(1, anns.Length);
            Assert.AreEqual(annList.First.Next, anns[0]);

            anns = annList.GetNodes(0, 200).ToArray();
            Assert.AreEqual(6, anns.Length);
        }
コード例 #45
0
ファイル: AnnotationTests.cs プロジェクト: sillsdev/machine
        public void Add()
        {
            var annList = new AnnotationList<int>(_spanFactory);
            // add without subsumption
            // add to empty list
            var a = new Annotation<int>(_spanFactory.Create(49, 50), FeatureStruct.New().Value);
            annList.Add(a, false);
            Assert.AreEqual(1, annList.Count);
            Assert.AreSame(a, annList.First);
            // add to beginning of list
            a = new Annotation<int>(_spanFactory.Create(0, 1), FeatureStruct.New().Value);
            annList.Add(a, false);
            Assert.AreEqual(2, annList.Count);
            Assert.AreSame(a, annList.First);
            // add to end of list
            a = new Annotation<int>(_spanFactory.Create(99, 100), FeatureStruct.New().Value);
            annList.Add(a, false);
            Assert.AreEqual(3, annList.Count);
            Assert.AreSame(a, annList.Last);
            // add to middle of list
            a = new Annotation<int>(_spanFactory.Create(24, 25), FeatureStruct.New().Value);
            annList.Add(a, false);
            Assert.AreEqual(4, annList.Count);
            Assert.AreSame(a, annList.ElementAt(1));
            // add containing annotation
            a = new Annotation<int>(_spanFactory.Create(0, 100), FeatureStruct.New().Value);
            annList.Add(a, false);
            Assert.AreEqual(5, annList.Count);
            Assert.AreSame(a, annList.First());
            // add contained annotation
            a = new Annotation<int>(_spanFactory.Create(9, 10), FeatureStruct.New().Value);
            annList.Add(a, false);
            Assert.AreEqual(6, annList.Count);
            Assert.AreSame(a, annList.ElementAt(2));

            annList.Clear();

            // add with subsumption
            // add to empty list
            a = new Annotation<int>(_spanFactory.Create(49, 50), FeatureStruct.New().Value);
            annList.Add(a);
            Assert.AreEqual(1, annList.Count);
            Assert.AreSame(a, annList.First);
            // add to beginning of list
            a = new Annotation<int>(_spanFactory.Create(0, 1), FeatureStruct.New().Value);
            annList.Add(a);
            Assert.AreEqual(2, annList.Count);
            Assert.AreSame(a, annList.First);
            // add to end of list
            a = new Annotation<int>(_spanFactory.Create(99, 100), FeatureStruct.New().Value);
            annList.Add(a);
            Assert.AreEqual(3, annList.Count);
            Assert.AreSame(a, annList.Last);
            // add to middle of list
            a = new Annotation<int>(_spanFactory.Create(24, 25), FeatureStruct.New().Value);
            annList.Add(a);
            Assert.AreEqual(4, annList.Count);
            Assert.AreSame(a, annList.ElementAt(1));
            // add containing annotation
            a = new Annotation<int>(_spanFactory.Create(0, 100), FeatureStruct.New().Value);
            annList.Add(a);
            Assert.AreEqual(1, annList.Count);
            Assert.AreSame(a, annList.First());
            Assert.AreEqual(4, a.Children.Count);
            // add contained annotation
            a = new Annotation<int>(_spanFactory.Create(9, 10), FeatureStruct.New().Value);
            annList.Add(a);
            Assert.AreEqual(1, annList.Count);
            Assert.AreEqual(5, annList.First.Children.Count);
            Assert.AreSame(a, annList.First.Children.ElementAt(1));

            annList.Clear();

            annList.Add(0, 1, FeatureStruct.New().Value);
            annList.Add(1, 2, FeatureStruct.New().Value);
            annList.Add(2, 3, FeatureStruct.New().Value);
            annList.Add(3, 4, FeatureStruct.New().Value);
            annList.Add(4, 5, FeatureStruct.New().Value);
            annList.Add(5, 6, FeatureStruct.New().Value);
            Assert.AreEqual(6, annList.Count);
            a = new Annotation<int>(_spanFactory.Create(1, 5), FeatureStruct.New().Value);
            a.Children.Add(1, 3, FeatureStruct.New().Value);
            a.Children.Add(3, 5, FeatureStruct.New().Value);
            Assert.AreEqual(2, a.Children.Count);
            annList.Add(a);
            Assert.AreEqual(3, annList.Count);
            Assert.AreSame(a, annList.ElementAt(1));
            Assert.AreEqual(2, a.Children.Count);
            Assert.AreEqual(2, a.Children.First.Children.Count);
            Assert.AreEqual(2, a.Children.Last.Children.Count);
        }
コード例 #46
0
ファイル: AnnotationTests.cs プロジェクト: sillsdev/machine
        public void FindDepthFirst()
        {
            var annList = new AnnotationList<int>(_spanFactory);
            annList.Add(1, 2, FeatureStruct.New().Value);
            annList.Add(9, 10, FeatureStruct.New().Value);
            annList.Add(49, 50, FeatureStruct.New().Value);
            annList.Add(69, 70, FeatureStruct.New().Value);
            annList.Add(99, 100, FeatureStruct.New().Value);
            annList.Add(1, 49, FeatureStruct.New().Value);
            annList.Add(51, 100, FeatureStruct.New().Value);

            Annotation<int> result;
            Assert.IsFalse(annList.FindDepthFirst(0, out result));
            Assert.AreEqual(annList.Begin, result);

            Assert.IsFalse(annList.FindDepthFirst(100, out result));
            Assert.AreEqual(annList.Last, result);

            Assert.IsTrue(annList.FindDepthFirst(1, out result));
            Assert.AreEqual(annList.First, result);

            Assert.IsFalse(annList.FindDepthFirst(8, out result));
            Assert.AreEqual(annList.First.Children.First, result);

            Assert.IsTrue(annList.FindDepthFirst(99, out result));
            Assert.AreEqual(annList.Last.Children.Last, result);

            Assert.IsTrue(annList.FindDepthFirst(49, out result));
            Assert.AreEqual(annList.First.Next, result);

            Assert.IsFalse(annList.FindDepthFirst(101, Direction.RightToLeft, out result));
            Assert.AreEqual(annList.End, result);

            Assert.IsFalse(annList.FindDepthFirst(1, Direction.RightToLeft, out result));
            Assert.AreEqual(annList.First, result);

            Assert.IsTrue(annList.FindDepthFirst(100, Direction.RightToLeft, out result));
            Assert.AreEqual(annList.Last, result);

            Assert.IsFalse(annList.FindDepthFirst(71, Direction.RightToLeft, out result));
            Assert.AreEqual(annList.Last.Children.Last, result);

            Assert.IsTrue(annList.FindDepthFirst(2, Direction.RightToLeft, out result));
            Assert.AreEqual(annList.First.Children.First, result);

            Assert.IsTrue(annList.FindDepthFirst(50, Direction.RightToLeft, out result));
            Assert.AreEqual(annList.Last.Prev, result);
        }