public static AnnotationEntity Create(string annotation) { XDocument doc = XDocument.Parse(annotation); var documentAnnotations = new List <AnnotationEntity>(); var annotationEntity = new AnnotationEntity ( annotation ); doc.Descendants("Container").ToList().ForEach(container => { container.Descendants("Object").ToList().ForEach(annotationObject => { var annotationObjectEntity = new AnnotationObjectEntity ( Guid.Parse(annotationObject.Element("Guid").Value.ToString()), Convert.ToInt32(container.Element("PageNumber").Value.ToString()), true ); annotationEntity.AddAnnotation(annotationObjectEntity); }); }); return(annotationEntity); }
public void AddAnnotation(AnnotationObjectEntity annotationObject) { if (!_annotationObjects.Any(x => x.Id == annotationObject.Id)) { var annotationObjectEntity = new AnnotationObjectEntity ( annotationObject.Id, annotationObject.PageNumber, annotationObject.AnnotationType ); _annotationObjects.Add(annotationObjectEntity); return; } var existingAnnotation = _annotationObjects.FirstOrDefault(x => x.Id.Equals(annotationObject.Id)); if (existingAnnotation != null) { existingAnnotation.Update(annotationObject); } }
public void Update(AnnotationObjectEntity annotationObject) { PageNumber = annotationObject.PageNumber; AnnotationType = annotationObject.AnnotationType; }