using System;
using System.Text;

namespace US.Browser.IE
{
    /// <summary>
    /// 通用区域
    /// </summary>
    public class Utitiy
    {

        #region 字符串优化

        /// <summary>
        /// 自定义字符串操作类 等同与从写了StringBuilder
        /// </summary>
        public class StringJoiner
        {
            protected StringBuilder Builder;

            public StringJoiner()
            {
                Builder = new StringBuilder();
            }


            /// <summary>
            /// StringJoiner 类型转换运算符的目标类型。 value 类型转换运算符的输入类型。
            /// </summary>
            /// <param name="value"></param>
            /// <returns></returns>
            public static implicit operator StringJoiner(string value)
            {
                StringJoiner text = new StringJoiner();
                text.Builder.Append(value);
                return text;
            }

            /// <summary>
            /// StringJoiner 运算符的结果类型。 self+value
            /// </summary>
            /// <param name="self"></param>
            /// <param name="value"></param>
            /// <returns></returns>
            public static StringJoiner operator +(StringJoiner self, string value)
            {
                self.Builder.Append(value);
                return self;
            }

            /// <summary>
            /// StringJoiner 类型的值转化成 string
            /// </summary>
            /// <param name="value"></param>
            /// <returns></returns>
            public static implicit operator string(StringJoiner value)
            {
                return value.ToString();
            }

            /// <summary>
            /// 修改StringJoiner类ToString继承方法
            /// </summary>
            /// <returns></returns>
            public override string ToString()
            {
                return this.Builder.ToString();
            }
        }



        #endregion

    }
}
