/// <summary> /// Does the location represent a place where an attribute value can be created or replaced by a completion? /// </summary> /// <param name="location"> /// The XML location. /// </param> /// <param name="targetAttribute"> /// The attribute (if any) whose value will be replaced by the completion. /// </param> /// <param name="onElementWithPath"> /// If specified, attribute's element must have the specified path. /// </param> /// <param name="forAttributeNamed"> /// If specified, the attribute must have one of the specified names. /// </param> /// <returns> /// <c>true</c>, if the location represents an attribute whose value can be replaced by a completion; otherwise, <c>false</c>. /// </returns> public static bool CanCompleteAttributeValue(this XmlLocation location, out XSAttribute targetAttribute, XSPath onElementWithPath = null, params string[] forAttributeNamed) { if (location == null) { throw new ArgumentNullException(nameof(location)); } targetAttribute = null; XSAttribute attribute; if (!location.IsAttributeValue(out attribute)) { return(false); } if (onElementWithPath != null && !attribute.HasParentPath(onElementWithPath)) { return(false); } if (forAttributeNamed.Length > 0 && Array.IndexOf(forAttributeNamed, attribute.Name) == -1) { return(false); } targetAttribute = attribute; return(true); }
/// <summary> /// Does the location represent an attribute's value? /// </summary> /// <param name="location"> /// The XML location. /// </param> /// <param name="attribute"> /// Receives the attribute whose value is represented by the location. /// </param> /// <returns> /// <c>true</c>, if the location represents an attribute's name; otherwise, <c>false</c>. /// </returns> public static bool IsAttributeValue(this XmlLocation location, out XSAttribute attribute) { if (location.IsAttributeValue()) { attribute = (XSAttribute)location.Node; return(true); } attribute = null; return(false); }