Exemplo n.º 1
0
        public ElementRef ChangeElementLocator(ElementLocator objectReference)
        {
            var result = ChangeProp(ImClone(this), im => im.SetElementLocator(objectReference));

            if (result.Parent != null)
            {
                result = result.ChangeParent(result.Parent.ChangeElementLocator(objectReference.Parent));
            }
            return(result);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Returns an ElementLocator with the new parent.
 /// The parent's Type is changed to null, since only the child ElementLocator has a type. The type of its parent
 /// can be inferred from the type of the child.
 /// </summary>
 public ElementLocator ChangeParent(ElementLocator parent)
 {
     if (ReferenceEquals(Parent, parent))
     {
         return(this);
     }
     if (parent != null && parent.Type != null)
     {
         parent = parent.ChangeType(null);
     }
     return(ChangeProp(ImClone(this), im => im.Parent = parent));
 }
Exemplo n.º 3
0
        public SrmDocument ReadAllAnnotations(CancellationToken cancellationToken, DsvFileReader fileReader)
        {
            var document = Document;
            var columns  = new Columns(fileReader.FieldNames, Document.Settings.DataSettings.AnnotationDefs);

            string[] row;
            while ((row = fileReader.ReadLine()) != null)
            {
                cancellationToken.ThrowIfCancellationRequested();
                ElementLocator elementLocator = columns.GetElementLocator(row);
                var            elementRef     = ElementRefs.FromObjectReference(elementLocator);
                var            annotations    = GetAnnotations(document, elementRef);
                var            newAnnotations = columns.ReadAnnotations(CultureInfo, elementRef, annotations, row);
                if (!Equals(newAnnotations, annotations))
                {
                    document = ChangeAnnotations(document, elementRef, newAnnotations);
                }
            }
            return(document);
        }
Exemplo n.º 4
0
 protected virtual void SetElementLocator(ElementLocator objectReference)
 {
     Name  = objectReference.Name;
     Index = ParseInt(objectReference.FindAttribute(ATTR_INDEX).Value);
 }
Exemplo n.º 5
0
 private bool Equals(ElementLocator other)
 {
     return(Equals(Parent, other.Parent) && string.Equals(Type, other.Type) && string.Equals(Name, other.Name) && Equals(Attributes, other.Attributes));
 }
Exemplo n.º 6
0
 public ElementLocator GetElementLocator(IList <string> row)
 {
     return(ElementLocator.Parse(row[LocatorColumn.Value]));
 }
Exemplo n.º 7
0
        public static ElementRef FromObjectReference(ElementLocator objectReference)
        {
            var prototype = _prototypes[objectReference.Type];

            return(prototype.ChangeElementLocator(objectReference));
        }