Ai
1 Star 7 Fork 3

baihongbin/SqlFormat

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
BaseFormatterState.cs 2.52 KB
一键复制 编辑 原始数据 按行查看 历史
baihongbin 提交于 2019-11-01 17:26 +08:00 . 更新
/*
Poor Man's T-SQL Formatter - a small free Transact-SQL formatting
library for .Net 2.0 and JS, written in C#.
Copyright (C) 2011-2017 Tao Klerks
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Text;
namespace BaiSqlFormatLib
{
internal class BaseFormatterState
{
public BaseFormatterState(bool htmlOutput)
{
HtmlOutput = htmlOutput;
}
protected bool HtmlOutput { get; set; }
protected StringBuilder _outBuilder = new StringBuilder();
public virtual void AddOutputContent(string content)
{
AddOutputContent(content, null);
}
public virtual void AddOutputContent(string content, string htmlClassName)
{
if (HtmlOutput)
{
if (!string.IsNullOrEmpty(htmlClassName))
_outBuilder.Append(@"<span class=""" + htmlClassName + @""">");
_outBuilder.Append(Utils.HtmlEncode(content));
if (!string.IsNullOrEmpty(htmlClassName))
_outBuilder.Append("</span>");
}
else
_outBuilder.Append(content);
}
public virtual void OpenClass(string htmlClassName)
{
if (htmlClassName == null)
throw new ArgumentNullException("htmlClassName");
if (HtmlOutput)
_outBuilder.Append(@"<span class=""" + htmlClassName + @""">");
}
public virtual void CloseClass()
{
if (HtmlOutput)
_outBuilder.Append(@"</span>");
}
public virtual void AddOutputContentRaw(string content)
{
_outBuilder.Append(content);
}
public virtual void AddOutputLineBreak()
{
_outBuilder.Append(Environment.NewLine);
}
public string DumpOutput()
{
return _outBuilder.ToString();
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/baihongbin/SqlFormat.git
git@gitee.com:baihongbin/SqlFormat.git
baihongbin
SqlFormat
SqlFormat
master

搜索帮助