/// <summary> /// The the attribute value for a linkAttribute /// </summary> /// <param name="linkAttribute">The link attribute representation</param> /// <returns>The attribute value as a string</returns> public string GetAttributeValue(LinkReferenceWrapper linkAttribute) { // Remove leading and trailing quotes string pathAttributeValue = linkAttribute._outputPathAttributeValue.Trim(new char[] { '\'', '"' }); return(pathAttributeValue); }
/// <summary> /// Utility method to change a link attribute, by entering a new value. /// </summary> /// <param name="linkAttribute">The link reference representation to alter</param> /// <param name="replacementFormatString">The string-format to use in updating the value</param> /// <param name="replacementValue">The new value to enter into the document</param> private void InjectAttribute(LinkReferenceWrapper linkAttribute, string replacementFormatString, object replacementValue) { string attributeInjection = String.Format(replacementFormatString, linkAttribute._outputPathAttributeValue, // 0 replacementValue, // 1 linkAttribute._attributeName); // 2 Group linkPosition = linkAttribute._linkPosition; int linkEndPosition = linkPosition.Index + linkPosition.Length; _contentString = _contentString.Substring(0, linkPosition.Index) + attributeInjection + _contentString.Substring(linkEndPosition, _contentString.Length - linkEndPosition); }
/// <summary> /// Get an Iterator of all the link attribute values in the document. /// </summary> /// <param name="expressions">The regular expressions to execute on the text</param> /// <returns>An enumerator of link attribute matches.</returns> internal IEnumerable <LinkReferenceWrapper> GetLinkAttributes(Regex[] expressions) { string[] templateStringContainer = new string[] { _contentString };; foreach (Regex expression in expressions) { foreach (Match linkMatch in TemplateUtilities.GetRegexMatches(templateStringContainer, expression)) { LinkReferenceWrapper linkAttribute = new LinkReferenceWrapper(linkMatch); linkAttribute._linkPosition = linkMatch.Groups[MATCH_PATH_GROUP_NAME]; linkAttribute._attributeName = linkMatch.Groups[MATCH_NAME_GROUP_NAME].ToString(); linkAttribute._outputPathAttributeValue = _contentString.Substring (linkAttribute._linkPosition.Index, linkAttribute._linkPosition.Length); yield return(linkAttribute); templateStringContainer[0] = _contentString; } } }
/// <summary> /// Add link attributes for a target item to an existing attribute, /// or change URL to a TCM URI in a CSS url reference. /// </summary> /// <param name="linkAttribute">The link attribute representation</param> /// <param name="targetItemUri">The Tcm Uri of the target</param> public void ProcessLinkChange(LinkReferenceWrapper linkAttribute, TcmUri targetItemUri) { // Make distinction between import and other statements string replacementFormatString; if ((linkAttribute._attributeName.ToLower() == "import") || (linkAttribute._attributeName.ToLower() == "url")) { // CSS reference replacementFormatString = MULTIMEDIA_CSS_IMPORT_ATTRIBUTE_FORMAT; } else { // other link replacementFormatString = MULTIMEDIA_LINK_ATTRIBUTE_FORMAT; } InjectAttribute(linkAttribute, replacementFormatString, targetItemUri); }
/// <summary> /// Replace an existing link attribute value in a link reference. /// </summary> /// <param name="linkAttribute">The link to process</param> /// <param name="replacementValue">The new value to store</param> internal void ReplaceValue(LinkReferenceWrapper linkAttribute, string replacementValue) { InjectAttribute(linkAttribute, ATTRIBUTE_VALUE_REPLACEMENT_FORMAT, replacementValue); }
/// <summary> /// Get an Iterator of all the link attribute values in the document. /// </summary> /// <param name="expressions">The regular expressions to execute on the text</param> /// <returns>An enumerator of link attribute matches.</returns> internal IEnumerable<LinkReferenceWrapper> GetLinkAttributes(Regex[] expressions) { string[] templateStringContainer = new string[] { _contentString }; ; foreach (Regex expression in expressions) { foreach (Match linkMatch in TemplateUtilities.GetRegexMatches(templateStringContainer, expression)) { LinkReferenceWrapper linkAttribute = new LinkReferenceWrapper(linkMatch); linkAttribute._linkPosition = linkMatch.Groups[MATCH_PATH_GROUP_NAME]; linkAttribute._attributeName = linkMatch.Groups[MATCH_NAME_GROUP_NAME].ToString(); linkAttribute._outputPathAttributeValue = _contentString.Substring (linkAttribute._linkPosition.Index, linkAttribute._linkPosition.Length); yield return linkAttribute; templateStringContainer[0] = _contentString; } } }
/// <summary> /// The the attribute value for a linkAttribute /// </summary> /// <param name="linkAttribute">The link attribute representation</param> /// <returns>The attribute value as a string</returns> public string GetAttributeValue(LinkReferenceWrapper linkAttribute) { // Remove leading and trailing quotes string pathAttributeValue = linkAttribute._outputPathAttributeValue.Trim(new char[] { '\'', '"' }); return pathAttributeValue; }