protected XmlNodeViewModel(ElementViewModel parent, string name, string value, string namespaceName) { this.Parent = parent; this.Name = name; this.Value = value; this.NamespaceName = namespaceName; }
private List<ElementViewModel> GetOrderedAncestorsFromElementToRoot(ElementViewModel element) { var list = new List<ElementViewModel>(); var currentElement = element; while (currentElement.Parent != null) { list.Add(currentElement); currentElement = currentElement.Parent; } if (currentElement != null) list.Add(currentElement); return list; }
public ElementViewModel(XElement element, ElementViewModel parent) : base(parent, element.Name.LocalName, element.Value, element.Name.NamespaceName) { this.InnerText = (element.FirstNode as XText)?.Value; this.InternalElement = element; this.ChildElements = new List<ElementViewModel>(); this.Attributes = new List<AttributeViewModel>(); this.IsExpanded = true; this.CollapseAllOtherElementsCommand = new RelayCommand<ElementViewModel>(CollapseAllOtherElementsCommand_Execute); this.ExpandAllChildElementsCommand = new RelayCommand<ElementViewModel>(ExpandAllChildElementsCommand_Execute); this.BuildXPathFromRootCommand = new RelayCommand<ElementViewModel>(BuildXPathFromRootCommand_Execute); this.CopyXPathFromRootCommand = new RelayCommand<ElementViewModel>(CopyXPathFromRootCommand_Execute); this.SetStartXPathCommand = new RelayCommand<ElementViewModel>(SetStartXPathCommand_Execute); this.BuildXPathFromStartCommand = new RelayCommand<ElementViewModel>(BuildXPathFromStartCommand_Execute); this.CopyXPathFromStartCommand = new RelayCommand<ElementViewModel>(CopyXPathFromStartCommand_Execute); Populate(); }
private void SetStartXPathCommand_Execute(ElementViewModel element) { this.MessengerInstance.Send(new SetStartElementForXPathMessage(element)); }
private void ExpandAllChildElementsCommand_Execute(ElementViewModel element) { this.MessengerInstance.Send(new ExpandAllChildElementsMessage(element)); }
private void CopyXPathFromStartCommand_Execute(ElementViewModel element) { this.MessengerInstance.Send(new BuildXPathFromStartMessage(element, OutputTarget.Clipboard)); }
private void CollapseAllOtherElementsCommand_Execute(ElementViewModel element) { this.MessengerInstance.Send(new CollapseAllOtherElementsMessage(element)); }
private void HandleSetStartElementForXPathMessage(SetStartElementForXPathMessage message) { this.StartOfXPath = message.Element; }
public void CollapseAllChildElementsExcept(ElementViewModel elementToExclude) { if (this == elementToExclude) return; foreach (var child in this.ChildElements) { child.IsExpanded = false; child.CollapseAllChildElementsExcept(elementToExclude); } }
public AttributeViewModel(XAttribute xmlAttribute, ElementViewModel parent) : base(parent, xmlAttribute.Name.LocalName, xmlAttribute.Value, xmlAttribute.Name.NamespaceName) { this.InternalAttribute = xmlAttribute; }
private void ParseElement(XElement root) { this.Root = new ElementViewModel(root, null); //this.Root.Populate(); }
private void CopyXPathFromRootCommand_Execute(ElementViewModel element) { this.MessengerInstance.Send(new BuildXPathFromRootMessage(element, OutputTarget.Clipboard)); }
private void BuildXPathFromStartCommand_Execute(ElementViewModel element) { this.MessengerInstance.Send(new BuildXPathFromStartMessage(element, OutputTarget.XPathEditor)); }
//private static ElementViewModel FindRoot(ElementViewModel element) //{ // var currentElement = element; // while (currentElement.Parent != null) // { // currentElement = currentElement.Parent; // } // return currentElement; //} public void Populate() { foreach (var xmlAttribute in this.InternalElement.Attributes()) { var attribute = new AttributeViewModel(xmlAttribute, this); this.Attributes.Add(attribute); } foreach (var xmlElement in this.InternalElement.Elements()) { var element = new ElementViewModel(xmlElement, this); this.ChildElements.Add(element); //element.Populate(); } }
private List<ElementViewModel> GetOrderedAncestorsFromRootToElement(ElementViewModel element) { var list = GetOrderedAncestorsFromElementToRoot(element); list.Reverse(); return list; }
private void BuildXPathFromRootCommand_Execute(ElementViewModel element) { this.MessengerInstance.Send(new BuildXPathFromRootMessage(element, OutputTarget.XPathEditor)); }
private void HandleDocumentRefressMessage(DocumentRefreshCompleted message) { this.StartOfXPath = null; }