本文整理汇总了C#中System.Text.StringBuilder.AppendFormat方法的典型用法代码示例。如果您正苦于以下问题:C# System.Text.StringBuilder.AppendFormat方法的具体用法?C# System.Text.StringBuilder.AppendFormat怎么用?C# System.Text.StringBuilder.AppendFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.StringBuilder
的用法示例。
在下文中一共展示了System.Text.StringBuilder.AppendFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Format
private static string Format(object o)
{
if (o == null) {
return "null";
} else if (o is string) {
return '"' + ((string)o) + '"';
} else if (o is Amf3Object) {
var sb = new System.Text.StringBuilder();
var ao = (Amf3Object)o;
sb.AppendFormat("[{0} ", ao.ClassDef.Name);
foreach (var prop in ao.Properties) {
sb.AppendFormat("{0}:{1} ", prop.Key, Format(prop.Value));
}
sb.AppendFormat("]");
return sb.ToString();
} else if (o is _root.Vector<int>){
var a = o as _root.Vector<int>;
return "(int)[" + o.ToString() + "]";
} else if (o is _root.Vector<uint>){
var a = o as _root.Vector<uint>;
return "(uint)[" + o.ToString() + "]";
} else if (o is _root.Vector<double>){
var a = o as _root.Vector<double>;
return "(number)[" + o.ToString() + "]";
} else if (o is double){
return "(number)" + o.ToString();
} else {
return o.ToString();
}
}
示例2: GetSelectModel
public SelectModel GetSelectModel(int pageIndex, int pageSize, string orderStr, int masterId, bool isHas = false, string clauseText = "")
{
NFMT.Common.SelectModel select = new NFMT.Common.SelectModel();
int status = (int)NFMT.Common.StatusEnum.已生效;
select.PageIndex = pageIndex;
select.PageSize = pageSize;
if (string.IsNullOrEmpty(orderStr))
select.OrderStr = "cc.ClauseId desc";
else
select.OrderStr = orderStr;
select.ColumnName = " cc.ClauseText,cc.ClauseEnText,ccr.RefId,cc.ClauseId,ccr.Sort,ccr.IsChose ";
System.Text.StringBuilder sb = new System.Text.StringBuilder();
if (isHas)
{
select.TableName = " dbo.ClauseContract_Ref ccr left join dbo.ContractClause cc on cc.ClauseId = ccr.ClauseId left join dbo.ContractMaster cm on cm.MasterId = ccr.MasterId ";
sb.AppendFormat(" ccr.RefStatus ={0} and cc.ClauseStatus = {0} ", status);
sb.AppendFormat(" and ccr.MasterId = {0} ", masterId);
}
else
{
select.TableName = string.Format(" dbo.ContractClause cc left join dbo.ClauseContract_Ref ccr on ccr.ClauseId = cc.ClauseId and MasterId = {0} and RefStatus = {1} left join dbo.ContractMaster cm on cm.MasterId = ccr.MasterId ", masterId, status);
sb.AppendFormat(" ccr.ClauseId is null and cc.ClauseStatus = {0}", status);
if (!string.IsNullOrEmpty(clauseText))
sb.AppendFormat(" and cc.ClauseText like '%{0}%' ", clauseText);
}
select.WhereStr = sb.ToString();
return select;
}
示例3: ListApplications
string ListApplications(ApplicationInstance applicationInstance)
{
System.Text.StringBuilder output = new System.Text.StringBuilder();
WriteCSS();
if (_authenticated)
{
output.AppendFormat("<form method=post action=''>");
}
output.Append("<table >\n");
output.AppendFormat("<tr><td><a href='Tarantino.WebManagement.Application.axd'>Back</a></td><td></td></tr>");
output.AppendFormat("<tr><td>Machine Name</td><td>{0}</td></tr>", applicationInstance.MachineName);
output.AppendFormat("<tr><td>Version</td><td>{0}</td></tr>", applicationInstance.Version);
output.AppendFormat("<tr><td>Unique Hostname</td><td><input type=\"text\" name=\"hostname\" value=\"{0}\"></td></tr>", applicationInstance.UniqueHostHeader);
output.AppendFormat("<tr><td>Shared Hostname</td><td>{0}</td></tr>", applicationInstance.MaintenanceHostHeader);
output.AppendFormat("<tr><td>Load balanaced</td><td>{0}</td></tr>", applicationInstance.AvailableForLoadBalancing ? "Online" : "Offline");
output.AppendFormat("<tr><td>Maintenance Mode</td><td>{0}</td></tr>", applicationInstance.DownForMaintenance ? "Down" : "Online");
output.Append("</table>\n");
if (_authenticated)
{
output.AppendFormat("<input type=submit value='Submit' />");
output.AppendFormat("</form>");
}
return output.ToString();
}
示例4: QueryCount
/// <summary>
/// 查询条数
/// </summary>
/// <param name="wheres">查询条件</param>
/// <returns>条数</returns>
public int QueryCount(object wheres)
{
var parameters = new List<SqlParameter>();
var whereBuilder = new System.Text.StringBuilder();
if (wheres != null)
{
var props = wheres.GetType().GetProperties();
foreach (var prop in props)
{
if (prop.Name.Equals("__o", StringComparison.InvariantCultureIgnoreCase))
{
// 操作符
whereBuilder.AppendFormat(" {0} ", prop.GetValue(wheres, null).ToString());
}
else
{
var val = prop.GetValue(wheres, null).ToString();
whereBuilder.AppendFormat(" [{0}] = @{0} ", prop.Name);
parameters.Add(new SqlParameter("@" + prop.Name, val));
}
}
}
var sql = SqlHelper.GenerateQuerySql("PictureCollect", new[] { "COUNT(1)" }, whereBuilder.ToString(), string.Empty);
var res = SqlHelper.ExecuteScalar(sql, parameters.ToArray());
return res == null ? 0 : Convert.ToInt32(res);
}
示例5: GetExpectationToString
//=========================================================================================
/// <summary>Получить текстовое описание ожидаемых литералов.</summary>
internal string GetExpectationToString()
{
if (_ExpectationString == null)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder("Expected ");
if (this.Entries.Count == 0)
{
if (this.ElseState != null)
sb.AppendFormat("'{0}'", this.ElseState.Name);
else
throw new NullReferenceException("Links for " + this.Name);
}
bool bFirst = true;
foreach (var oKey in this.Entries.Keys)
{
if (bFirst)
bFirst = false;
else
sb.Append(" or ");
sb.AppendFormat("'{0}'", oKey);
}
this._ExpectationString = sb.ToString();
}
return this._ExpectationString;
}
示例6: ToString
/// <summary>
/// Ausgeben der Werte als Pseudo-CSV
/// </summary>
public override string ToString()
{
System.Text.StringBuilder builder = new System.Text.StringBuilder();
builder.AppendFormat("{0};", this.listIndex);
foreach (object value in objectArray)
{
if (value == null || value == DBNull.Value)
{
builder.AppendFormat("<NULL>");
}
else if (value.GetType() == typeof(string))
{
builder.AppendFormat("\"{0}\"", (string)value);
}
else if (value is IFormattable)
{
builder.AppendFormat("{0}", ((IFormattable)value).ToString("g", System.Globalization.CultureInfo.InvariantCulture));
}
else
{
builder.AppendFormat("[{0}]", value.ToString());
}
builder.Append(';');
}
return builder.ToString();
}
示例7: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
footer = Sitecore.Context.Database.GetItem(footerItemPath);
//Main Menu items
List<PageSummaryItem> items = footer.Mainlinks.ListItems.ConvertAll(x => new PageSummaryItem(x));
System.Text.StringBuilder markupBuilder = new System.Text.StringBuilder();
int childcounter = 0;
foreach (PageSummaryItem child in items)
{
if (!string.IsNullOrEmpty(child.NavigationTitle.Text))
{
markupBuilder.AppendFormat(@"<li{2}><a href=""{0}"">{1}</a></li>", child.Url, child.NavigationTitle.Rendered, childcounter == 0 ? @" class=""first""" : "");
childcounter++;
}
}
if (markupBuilder.Length > 0)
{
markupBuilder.Insert(0, "<ul>");
markupBuilder.Insert(0, "<nav>");
markupBuilder.AppendFormat(@"<li><a href=""{0}"" class=""external"" target=""_blank"">{1}</a></li>", Settings.CareersLink, Translate.Text("Careers"));
markupBuilder.Append("</ul>");
markupBuilder.Append("</nav>");
markup = markupBuilder.ToString();
}
//Submenu items
List<PageSummaryItem> subitems = footer.Sublinks.ListItems.ConvertAll(x => new PageSummaryItem(x));
System.Text.StringBuilder markupBuilderSub = new System.Text.StringBuilder();
childcounter = 0;
//Set Link to Mobile Site -if we are using a Mobile device.
if (SitecoreHelper.GetDeviceFromCookie().Equals(Settings.MobileDevice, StringComparison.OrdinalIgnoreCase))
{
string startPath = Sitecore.Context.Site.StartPath.ToString();
var homeItem = Sitecore.Context.Database.GetItem(startPath);
var options = new UrlOptions { AlwaysIncludeServerUrl = true, AddAspxExtension = false, LanguageEmbedding = LanguageEmbedding.Never };
var homeUrl = LinkManager.GetItemUrl(homeItem, options);
//Set return to main site link
markupBuilderSub.AppendFormat(@"<li><a href=""{0}"">{1}</a></li>", homeUrl + "?sc_device=mobile&persisted=true", Translate.Text("Mobile Site"));
childcounter++;
}
foreach (PageSummaryItem child in subitems)
{
if (!string.IsNullOrEmpty(child.NavigationTitle.Text))
{
string url = Sitecore.Links.LinkManager.GetItemUrl(child.InnerItem);
markupBuilderSub.AppendFormat(@"<li><a href=""{0}"">{1}</a></li>", url, child.NavigationTitle.Rendered);
childcounter++;
}
}
if (markupBuilderSub.Length > 0)
{
subMenuMarkup = markupBuilderSub.ToString();
}
}
示例8: ShowAlert
/// <summary>
/// ���JS��ʾ��Ϣ�Ի���
/// </summary>
/// <param name="context">ҳ��Context</param>
/// <param name="Msg">��Ϣ����</param>
/// <param name="Astate">���ģʽ * ö��</param>
/// <param name="ToUrl">��ʾ��Ҫת����URL</param>
public static void ShowAlert(HttpContext context, string Msg, AlertState Astate, string ToUrl)
{
System.Text.StringBuilder mySB = new System.Text.StringBuilder();
mySB.AppendFormat("<script type=\"text/javascript\">alert(\"{0}\");", Msg);
switch (Astate)
{
case AlertState.Back:
mySB.Append("history.go(-1);");
break;
case AlertState.CloseWindow:
mySB.Append("top.window.close();");
break;
case AlertState.OpenInParentWindow:
mySB.AppendFormat("top.location = '{0}';", ToUrl);
break;
case AlertState.OpenInThisWindow:
mySB.AppendFormat("window.location = '{0}';", ToUrl);
break;
case AlertState.Nothing:
break;
}
mySB.Append("</script>");
context.Response.Write(mySB.ToString());
}
示例9: GetHidimHeader
private static string GetHidimHeader(string filename, int height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("hidim is torrents!");
sb.AppendFormat("i{0}e", height);
sb.AppendFormat("{0}:{1}", Path.GetFileName(filename).Length, Path.GetFileName(filename));
try
{
using (FileStream fs = File.OpenRead(filename))
{
byte[] hash = new System.Security.Cryptography.SHA1Managed().ComputeHash(fs);
string sha1 = BitConverter.ToString(hash).Replace("-", "");
sb.AppendFormat("{0}:{1}", sha1.Length, sha1);
}
}
catch (Exception)
{
sb.AppendFormat("{0}:{1}", 40, "deadbeefdeadbeefdeadbeefdeadbeebadcoffee");
}
sb.AppendFormat("i{0}e", new FileInfo(filename).Length);
return sb.ToString();
}
示例10: GetSelectModel
public SelectModel GetSelectModel(int pageIndex, int pageSize, string orderStr, int status, string key, int bankeStatus, int capitalType, string bankEname)
{
NFMT.Common.SelectModel select = new NFMT.Common.SelectModel();
select.PageIndex = pageIndex;
select.PageSize = pageSize;
if (string.IsNullOrEmpty(orderStr))
select.OrderStr = "BankId desc";
else
select.OrderStr = orderStr;
select.ColumnName = " B.BankId,B.BankName,B.BankEname,B.BankFullName,B.BankShort,B.CapitalType,B.BankStatus,bd.StatusName,sd.DetailName,bt.BankName as ParentBankName,B.ParentId,case ISNULL(B.SwitchBack,0) when 0 then '否' when 1 then '是' end as SwitchBack ";
select.TableName = " dbo.Bank B left join dbo.BDStatusDetail bd on B.BankStatus = bd.DetailId left join dbo.BDStyleDetail sd on sd.StyleDetailId=B.CapitalType left join Bank bt on bt.BankId=B.ParentId ";
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(" bd.StatusId = 1 ");
if (status > 0)
sb.AppendFormat(" and B.BankStatus = {0}", status);
if (!string.IsNullOrEmpty(key))
sb.AppendFormat(" and B.BankFullName like '%{0}%'", key);
if (capitalType > 0)
sb.AppendFormat(" and B.CapitalType = {0}", capitalType);
if (!string.IsNullOrEmpty(bankEname))
sb.AppendFormat(" and B.BankEname like '%{0}%'", bankEname);
select.WhereStr = sb.ToString();
return select;
}
示例11: ToString
public override string ToString()
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("I2CVMUserProgram \n");
sb.Append(" Program\n");
sb.AppendFormat(" : {0} \n", Program[0]);
sb.AppendFormat(" : {0} \n", Program[1]);
sb.AppendFormat(" : {0} \n", Program[2]);
sb.AppendFormat(" : {0} \n", Program[3]);
sb.AppendFormat(" : {0} \n", Program[4]);
sb.AppendFormat(" : {0} \n", Program[5]);
sb.AppendFormat(" : {0} \n", Program[6]);
sb.AppendFormat(" : {0} \n", Program[7]);
sb.AppendFormat(" : {0} \n", Program[8]);
sb.AppendFormat(" : {0} \n", Program[9]);
sb.AppendFormat(" : {0} \n", Program[10]);
sb.AppendFormat(" : {0} \n", Program[11]);
sb.AppendFormat(" : {0} \n", Program[12]);
sb.AppendFormat(" : {0} \n", Program[13]);
sb.AppendFormat(" : {0} \n", Program[14]);
sb.AppendFormat(" : {0} \n", Program[15]);
sb.AppendFormat(" : {0} \n", Program[16]);
sb.AppendFormat(" : {0} \n", Program[17]);
sb.AppendFormat(" : {0} \n", Program[18]);
sb.AppendFormat(" : {0} \n", Program[19]);
return sb.ToString();
}
示例12: sendButton_Click
protected void sendButton_Click(object sender, EventArgs e)
{
if (!Page.IsValid)
return;
string subject = string.Format("ezLooker: {0}", this.emailInput.Text);
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.AppendLine();
sb.AppendFormat("IP: {0}", Request.UserHostAddress).AppendLine();
sb.AppendFormat("UserAgent: {0}", Request.UserAgent).AppendLine();
sb.AppendFormat("Name: {0}", this.nameInput.Text).AppendLine();
sb.AppendFormat("Email: {0}", this.emailInput.Text).AppendLine();
sb.AppendLine("Comment:");
sb.AppendFormat("{0}", this.commentInput.Text).AppendLine();
try
{
using (MailMessage mailMessage = new MailMessage("[email protected]", "[email protected]", subject, sb.ToString()))
{
using (SmtpClient smtpClient = new SmtpClient() { Host = "smtp.gmail.com", Credentials = new NetworkCredential("[email protected]", "ihateHTML!"), EnableSsl = true })
{
smtpClient.Send(mailMessage);
}
}
}
catch
{
// TODO: Log Exeption
}
this.contact.ActiveViewIndex = 1;
}
示例13: BindZhiFuBao
/// <summary>
/// 支付宝绑定
/// </summary>
/// <param name="OrderId"></param>
/// <param name="obj"></param>
/// <returns></returns>
protected string BindZhiFuBao(string orderId, object status, object zhifu, object xiafei)
{
System.Text.StringBuilder zhifubao = new System.Text.StringBuilder();
Eyousoft_yhq.Model.OrderState OrderStatus = (Eyousoft_yhq.Model.OrderState)status;
Eyousoft_yhq.Model.PaymentState PayStatus = (Eyousoft_yhq.Model.PaymentState)zhifu;
Eyousoft_yhq.Model.ConSumState ConSumState = (Eyousoft_yhq.Model.ConSumState)xiafei;
if (Eyousoft_yhq.Model.OrderState.待付款 == OrderStatus || Eyousoft_yhq.Model.OrderState.已成交 == OrderStatus)
{
if (PayStatus == Eyousoft_yhq.Model.PaymentState.已支付)
{
zhifubao.Append("<span class=\"yifu\">" + ConSumState.ToString() + "</span>");
}
else
{
zhifubao.AppendFormat("<a data-id=\"{0}\" class=\"yueZF\" href=\"javascript:;\"><span class=\"daifu\">账户支付</span></a>", orderId);
zhifubao.AppendFormat("<a href=\"http://{1}/AppPage/weixin/GoPay.aspx?OrderId={0}\"><span class=\"daifu\">支付宝支付</span></a>", orderId, HttpContext.Current.Request.Url.Host);
}
}
else
{
zhifubao.AppendFormat("<span class=\"daifu\">{0}</span>", OrderStatus.ToString());
}
return zhifubao.ToString();
}
示例14:
void IGeneratedSourcePolicy.GenerateSource(
GeneratedSourceModule sender,
Bam.Core.ExecutionContext context,
Bam.Core.ICommandLineTool compiler,
Bam.Core.TokenizedString generatedFilePath)
{
var encapsulating = sender.GetEncapsulatingReferencedModule();
var workspace = Bam.Core.Graph.Instance.MetaData as XcodeBuilder.WorkspaceMeta;
var target = workspace.EnsureTargetExists(encapsulating);
var configuration = target.GetConfiguration(encapsulating);
var command = new System.Text.StringBuilder();
// recode the executable path for Xcode
var xcodePath = encapsulating.CreateTokenizedString("$(packagebuilddir)/$(config)").Parse();
xcodePath += "/" + System.IO.Path.GetFileName(compiler.Executable.Parse());
command.AppendFormat(xcodePath);
// TODO: change this to a configuration directory really
command.AppendFormat(" {0}", Bam.Core.TokenizedString.Create("$(buildroot)", null).Parse());
command.AppendFormat(" {0}", "Generated");
var commands = new Bam.Core.StringArray();
commands.Add(command.ToString());
target.AddPreBuildCommands(commands, configuration);
var compilerTarget = workspace.EnsureTargetExists(compiler as Bam.Core.Module);
target.Requires(compilerTarget);
}
示例15: logon
public static void logon(contentManagerService1 cmService,
string userName, string userPassword, string userNamespace)
{
try
{
System.Text.StringBuilder credentialXML = new System.Text.StringBuilder("<credential>" );
credentialXML.AppendFormat( "<namespace>{0}</namespace>", userNamespace );
credentialXML.AppendFormat( "<username>{0}</username>", userName );
credentialXML.AppendFormat( "<password>{0}</password>", userPassword );
credentialXML.Append( "</credential>" );
//TODO - encode this, don't just toString it.
string encodedCredentials = credentialXML.ToString ();
xmlEncodedXML xmlEncodedCredentials = new xmlEncodedXML();
xmlEncodedCredentials.Value = encodedCredentials;
cmService.logon(xmlEncodedCredentials, null);
}
catch( SoapException ex )
{
displayException(ex);
}
catch (System.Exception ex)
{
displayException(ex);
}
}