/// <summary> /// </summary> /// <param name="error"></param> /// <param name="el"></param> /// <param name="a"></param> /// <param name="e"></param> public PortableHtmlSchemaErorrDescription(PortableHtmlSchemaErorr error, XElement el, XAttribute a, Exception e) { Error = error; if (null != el) { Element = el; var eli = el as IXmlLineInfo; if (eli.HasLineInfo()) { Line = eli.LineNumber; Column = eli.LinePosition; } XPath = el.GetXPath(); } else if (null != a) { Attribute = a; Element = a.Parent; var eli = a.Parent as IXmlLineInfo; if (null != eli && eli.HasLineInfo()) { Line = eli.LineNumber; Column = eli.LinePosition; } XPath = a.GetXPath(); } Exception = e; }
/// <exclude /> public static LeafDisplayMode ParseDisplayMode(XAttribute attribute, Tree tree) { if (attribute != null) { LeafDisplayMode parsedValue; if (Enum.TryParse(attribute.Value, out parsedValue)) { return(parsedValue); } tree.AddValidationError(attribute.GetXPath(), "TreeValidationError.Common.WrongAttributeValue", attribute.Value); } return(LeafDisplayMode.Lazy); }
private static ElementAttachingProviderPosition GetPosition(Tree tree, XElement namedElement) { XAttribute positionAttribute = namedElement.Attribute("Position"); string position = positionAttribute.GetValueOrDefault("Top"); switch (position) { case "Top": return(ElementAttachingProviderPosition.Top); case "Bottom": return(ElementAttachingProviderPosition.Bottom); default: tree.AddValidationError(positionAttribute.GetXPath(), "TreeValidationError.AutoAttachments.UnknownAttachmentPosition", position); return(ElementAttachingProviderPosition.Top);; } }
private static IEnumerable <INamedAttachmentPoint> BuildNamedAttachmentPoints(Tree tree, XElement containerElement, Func <INamedAttachmentPoint> namedAttachmentPointFactory) { IEnumerable <XElement> namedElements = containerElement.Elements(TreeMarkupConstants.Namespace + "NamedParent"); foreach (XElement namedElement in namedElements) { XAttribute nameAttribute = namedElement.Attribute("Name"); if (nameAttribute == null) { tree.AddValidationError(namedElement.GetXPath(), "TreeValidationError.Common.MissingAttribute", "Name"); yield break; } AttachingPoint attachingPoint; switch (nameAttribute.Value) { case "PerspectivesRoot": attachingPoint = AttachingPoint.PerspectivesRoot; break; case "Content": attachingPoint = AttachingPoint.ContentPerspective; break; case "Content.WebsiteItems": attachingPoint = AttachingPoint.ContentPerspectiveWebsiteItems; break; case "Data": attachingPoint = AttachingPoint.DataPerspective; break; case "Layout": attachingPoint = AttachingPoint.DesignPerspective; break; case "Media": attachingPoint = AttachingPoint.MediaPerspective; break; case "Function": attachingPoint = AttachingPoint.FunctionPerspective; break; case "System": attachingPoint = AttachingPoint.SystemPerspective; break; case null: case "": tree.AddValidationError(nameAttribute.GetXPath(), "TreeValidationError.AutoAttachments.UnknownAttachmentPoint", nameAttribute.Value); attachingPoint = null; break; default: attachingPoint = AttachingPoint.VirtualElementAttachingPoint(nameAttribute.Value); break; } if (attachingPoint == null) { yield break; } INamedAttachmentPoint namedAttachmentPoint = namedAttachmentPointFactory(); namedAttachmentPoint.AttachingPoint = attachingPoint; namedAttachmentPoint.Position = GetPosition(tree, namedElement); yield return(namedAttachmentPoint); } }
public static DomPath GetDomPath(this XAttribute attribute, IFactory factory) { return(factory.GetOrCreateDomPath(attribute.GetXPath())); }