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); }
/// <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)); }
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); }
protected virtual void SetElementLocator(ElementLocator objectReference) { Name = objectReference.Name; Index = ParseInt(objectReference.FindAttribute(ATTR_INDEX).Value); }
private bool Equals(ElementLocator other) { return(Equals(Parent, other.Parent) && string.Equals(Type, other.Type) && string.Equals(Name, other.Name) && Equals(Attributes, other.Attributes)); }
public ElementLocator GetElementLocator(IList <string> row) { return(ElementLocator.Parse(row[LocatorColumn.Value])); }
public static ElementRef FromObjectReference(ElementLocator objectReference) { var prototype = _prototypes[objectReference.Type]; return(prototype.ChangeElementLocator(objectReference)); }