/// <summary> /// Initializes a new instance of <see cref="BlockElementAttributes"/> class /// with a given set of attributes. /// </summary> /// <param name="cssClass">Element CSS class.</param> /// <param name="id">Element ID.</param> /// <param name="style">Inline element style.</param> /// <param name="language">Element language specification.</param> /// <param name="alignment">Element alignment.</param> /// <param name="leftIndent">Element left indent (in <c>em</c>s).</param> /// <param name="rightIndent">Element right indent (in <c>em</c>s).</param> public BlockElementAttributes(string cssClass, string id, string style, string language, BlockElementAlignment alignment, Int32 leftIndent, Int32 rightIndent) : base(cssClass, id, style, language) { this.alignment = alignment; this.leftIndent = leftIndent; this.rightIndent = rightIndent; }
/// <summary> /// Creates an instance of <see cref="BlockElementAttributes"/> class from the /// given <paramref name="match"/>, provided that <paramref name="match"/> /// has required groups (<c>CssClass</c>, <c>ID</c>, <c>Style</c>, <c>Language</c>, /// <c>Alignment</c>, <c>LeftIndent</c> and <c>RightIndent</c>). /// </summary> /// <param name="match"></param> /// <returns></returns> protected static BlockElementAttributes CreateBlockElementAttributes(Match match) { InlineElementAttributes inlineElementAttributes = CreateInlineElementAttributes(match); // // Fetching values String alignment = match.Groups["Alignment"].Value; String leftIndent = match.Groups["LeftIndent"].Captures.Count > 0 ? match.Groups["LeftIndent"].Captures[0].Value : match.Groups["LeftIndent"].Value; String rightIndent = match.Groups["RightIndent"].Captures.Count > 0 ? match.Groups["RightIndent"].Captures[0].Value : match.Groups["RightIndent"].Value; // // Determining block element alignment BlockElementAlignment elementAlignment = BlockElementAlignment.Unknown; if (!IsNullOrEmpty(alignment)) { switch (alignment.ToUpper()) { case "<": elementAlignment = BlockElementAlignment.Left; break; case ">": elementAlignment = BlockElementAlignment.Right; break; case "=": elementAlignment = BlockElementAlignment.Center; break; case "<>": elementAlignment = BlockElementAlignment.Justify; break; } // switch } // if // // Determining indentation values Int32 leftIndentValue = 0; Int32 rightIndentValue = 0; // // Left indent. if (!IsNullOrEmpty(leftIndent)) { leftIndentValue = leftIndent.Length; } // // Right indent. if (!IsNullOrEmpty(rightIndent)) { rightIndentValue = rightIndent.Length; } return(new BlockElementAttributes(inlineElementAttributes.CssClass, inlineElementAttributes.ID, inlineElementAttributes.Style, inlineElementAttributes.Language, elementAlignment, leftIndentValue, rightIndentValue)); }