示例#1
0
        public static AbstractTextElement CreateTextElement(TextElementType textElementType, string value = "")
        {
            switch (textElementType)
            {
            case TextElementType.TextUnit:
                return(new TextUnit(value));

            case TextElementType.TextElementCollection:
                return(new TextElementCollection());

            case TextElementType.Paragraph:
                if (value.Length == 0)
                {
                    return(new Paragraph());
                }
                else
                {
                    var paragraph = new Paragraph();
                    paragraph.AddTextElement(new TextUnit(value));
                    return(paragraph);
                }

            default:
                //here can not be executed.
                return(null);
            }
        }