当前位置: 首页>>代码示例>>C#>>正文


C# StringBuilder.AppendFormat方法代码示例

本文整理汇总了C#中StringBuilder.AppendFormat方法的典型用法代码示例。如果您正苦于以下问题:C# StringBuilder.AppendFormat方法的具体用法?C# StringBuilder.AppendFormat怎么用?C# StringBuilder.AppendFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringBuilder的用法示例。


在下文中一共展示了StringBuilder.AppendFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestEmail

    string TestEmail(Settings settings)
    {
        string email = settings.Email;
        string smtpServer = settings.SmtpServer;
        string smtpServerPort = settings.SmtpServerPort.ToString();
        string smtpUserName = settings.SmtpUserName;
        string smtpPassword = settings.SmtpPassword;
        string enableSsl = settings.EnableSsl.ToString();

        var mail = new MailMessage
        {
            From = new MailAddress(email, smtpUserName),
            Subject = string.Format("Test mail from {0}", smtpUserName),
            IsBodyHtml = true
        };
        mail.To.Add(mail.From);
        var body = new StringBuilder();
        body.Append("<div style=\"font: 11px verdana, arial\">");
        body.Append("Success");
        if (HttpContext.Current != null)
        {
            body.Append(
                "<br /><br />_______________________________________________________________________________<br /><br />");
            body.AppendFormat("<strong>IP address:</strong> {0}<br />", Utils.GetClientIP());
            body.AppendFormat("<strong>User-agent:</strong> {0}", HttpContext.Current.Request.UserAgent);
        }

        body.Append("</div>");
        mail.Body = body.ToString();

        return Utils.SendMailMessage(mail, smtpServer, smtpServerPort, smtpUserName, smtpPassword, enableSsl.ToString());
    }
开发者ID:aelagawy,项目名称:BlogEngine.NET,代码行数:32,代码来源:SettingsController.cs

示例2: ToString

    public override string ToString()
    {
        var arguments = new StringBuilder();

        arguments.AppendFormat("\"{0}\"", workingDirectory);

        if (!string.IsNullOrWhiteSpace(exec))
        {
            arguments.AppendFormat(" /exec \"{0}\"", exec);
        }

        if (!string.IsNullOrWhiteSpace(execArgs))
        {
            arguments.AppendFormat(" /execArgs \"{0}\"", execArgs);
        }

        if (!string.IsNullOrWhiteSpace(projectFile))
        {
            arguments.AppendFormat(" /proj \"{0}\"", projectFile);
        }

        if (!string.IsNullOrWhiteSpace(projectArgs))
        {
            arguments.AppendFormat(" /projargs \"{0}\"", projectArgs);
        }

        arguments.Append(additionalArguments);

        if (!string.IsNullOrWhiteSpace(logFile))
        {
            arguments.AppendFormat(" /l \"{0}\"", logFile);
        }

        return arguments.ToString();
    }
开发者ID:Wikell,项目名称:GitVersion,代码行数:35,代码来源:ArgumentBuilder.cs

示例3: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (CustomTableItem != null)
        {
            DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(CustomTableItem.CustomTableClassName);
            if (dci != null)
            {
                // Get class form definition
                FormInfo fi = FormHelper.GetFormInfo(dci.ClassName, false);

                string fieldCaption;
                FormFieldInfo ffi;
                IDataContainer item = CustomTableItem;

                StringBuilder sb = new StringBuilder();
                sb.Append("<table class=\"table table-hover\">");
                // Table header
                sb.AppendFormat("<thead><tr class=\"unigrid-head\"><th>{0}</th><th class=\"main-column-100\">{1}</th></tr></thead><tbody>", GetString("customtable.data.nametitle"), GetString("customtable.data.namevalue"));

                // Get macro resolver
                MacroResolver resolver = MacroResolverStorage.GetRegisteredResolver(FormHelper.FORM_PREFIX + dci.ClassName);

                // Go through the columns
                foreach (string columnName in item.ColumnNames)
                {
                    // Get field caption
                    ffi = fi.GetFormField(columnName);
                    if (ffi == null)
                    {
                        fieldCaption = columnName;
                    }
                    else
                    {
                        string caption = ffi.GetPropertyValue(FormFieldPropertyEnum.FieldCaption, resolver);
                        if (string.IsNullOrEmpty(caption))
                        {
                            fieldCaption = columnName;
                        }
                        else
                        {
                            fieldCaption = ResHelper.LocalizeString(caption);
                        }
                    }

                    sb.AppendFormat("<tr><td><strong>{0}</strong></td><td class=\"wrap-normal\">{1}</td></tr>", fieldCaption, HTMLHelper.HTMLEncode(ValidationHelper.GetString(item.GetValue(columnName), String.Empty)));
                }
                sb.Append("</tbody></table>");

                ltlContent.Text = sb.ToString();
            }
            else
            {
                ltlContent.Text = GetString("editedobject.notexists");
            }
        }
        else
        {
            ltlContent.Text = GetString("editedobject.notexists");
        }
    }
开发者ID:dlnuckolls,项目名称:pfh-paypalintegration,代码行数:60,代码来源:CustomTableViewItem.ascx.cs

示例4: ButtonChart_Click

		public void ButtonChart_Click(object sender, System.EventArgs e)
		{
			//We first request the data from the form (Default.aspx)
			string soups, salads, sandwiches, beverages, desserts;
            soups = TextBoxSoups.Text;
			salads = TextboxSalads.Text;
			sandwiches = TextboxSandwiches.Text;
			beverages = TextboxBeverages.Text;
			desserts   = TextboxDesserts.Text;
	
			//In this example, we're directly showing this data back on chart.
			//In your apps, you can do the required processing and then show the 
			//relevant data only.
	
			//Now that we've the data in variables, we need to convert this into XML.
			//The simplest method to convert data into XML is using string concatenation.	
            StringBuilder xmlData = new StringBuilder();
			//Initialize <chart> element
			xmlData.Append("<chart caption='Sales by Product Category' subCaption='For this week' showPercentValues='1' pieSliceDepth='30' showBorder='1'>");
			//Add all data
			xmlData.AppendFormat("<set label='Soups' value='{0}' />",soups);
			xmlData.AppendFormat("<set label='Salads' value='{0}' />",salads);
			xmlData.AppendFormat("<set label='Sandwiches' value='{0}' />", sandwiches);
            xmlData.AppendFormat("<set label='Beverages' value='{0}' />", beverages);
			xmlData.AppendFormat("<set label='Desserts' value='{0}' />",desserts);
			//Close <chart> element
			xmlData.Append("</chart>");
                        
			//Create the chart - Pie 3D Chart with data from xmlData
            LiteralChart.Text = FusionCharts.RenderChart("../FusionCharts/Pie3D.swf", "", xmlData.ToString(), "Sales", "500", "300", false, false);
		}
开发者ID:pawelniewie,项目名称:5groszy.pl,代码行数:31,代码来源:Default.aspx.cs

示例5: BindGroups

    private void BindGroups()
    {
        string sql = "select * from [group] where [g_tags] like '%" + tag + "%'";
        DataTable dt = DB.GetTable(sql);

        int cnt = dt != null ? dt.Rows.Count : 0;

        if (cnt == 0) return;

        pageCount = cnt / pageSize;
        if (cnt % pageSize > 0) pageCount++;
        pageIndex = Math.Max(0, pageIndex);
        pageIndex = Math.Min(pageCount - 1, pageIndex);

        StringBuilder sb = new StringBuilder();
        foreach (DataRow row in dt.Rows)
        {
            sb.Append("<div style='margin-top:16px;margin-left:14px;'>");
            sb.AppendFormat("<div class='ileft'><a href='/{0}{1}' title='{0}' target=_blank><img src='/upload/photo/{0}-s.jpg' {2} /></a></div>", row["g_id"], Settings.Ext, Strings.GroupSmallImageError);
            sb.AppendFormat("<div class='iright'><a class='bold' href='/group/{0}{1}' target=_blank>{2}</a>", row["g_id"], Settings.Ext, Tools.HtmlEncode(row["g_name"].ToString()));
            sb.AppendFormat("<p>{0}</p>", Tools.HtmlEncode(row["g_description"].ToString()));
            sb.AppendFormat("<span class='em'>标签:{0}</span></div>", TagTools.ToLinks(row["g_tags"].ToString(), true));
            sb.Append("<div class='clear'></div></div>");
        }
        lblGroupList.Text = sb.ToString();

        if (pageCount > 1)
        {
            string url = String.Format("/group/tag/{0}/{1}{2}", tag, "{0}", Settings.Ext);
            lblPageList.Text = Tools.GetPager(pageIndex, pageCount, pageNumber, url);
        }
    }
开发者ID:sqzhuyi,项目名称:cnopenblog,代码行数:32,代码来源:Tag.aspx.cs

示例6: BindData

    private void BindData()
    {
        string fields = "[_name],[fullname],[state],[city],[jianjie]";
        string where = "[hangye]='" + tag + "'";
        string sql = "select {0} from [users] where {1} order by [_name]";
        sql = String.Format(sql, fields, where);

        DataTable dt = DB.GetTable(sql);

        StringBuilder sb = new StringBuilder();

        foreach (DataRow row in dt.Rows)
        {
            sb.Append("<div style='margin-top:16px;margin-left:14px;'>");
            sb.AppendFormat("<div class='ileft'><a href='/{0}{1}' title='{0}' target=_blank><img src='/upload/photo/{0}-s.jpg' {2} /></a></div>", row["_name"], Settings.Ext, Strings.UserSmallImageError);
            sb.AppendFormat("<div class='iright'><a class='bold' href='/{0}{1}' target=_blank>{0}</a> ({2})", row["_name"], Settings.Ext, row["fullname"]);

            if (row["state"].ToString() != "")
            {
                if (row["state"].ToString().Substring(0, 2) == row["city"].ToString().Substring(0, 2))
                {
                    sb.AppendFormat(" <a href='/city/{0}{1}'>{0}</a>", row["city"], Settings.Ext);
                }
                else
                {
                    sb.AppendFormat(" <a href='/city/{0}{1}'>{0}</a>,<a href='/city/{2}{1}'>{2}</a>", row["state"], Settings.Ext, row["city"]);
                }
            }
            sb.AppendFormat("<p><span style='color:#888888;'>简介:</span>{0}</p>", Tools.HtmlEncode(Tools.CutString(row["jianjie"].ToString(), 126)));
            sb.Append("</div><div class='clear'></div></div>");
        }
        lblDataList.Text = sb.ToString();
    }
开发者ID:sqzhuyi,项目名称:cnopenblog,代码行数:33,代码来源:Industry.aspx.cs

示例7: GetCharArrayInfo

        private string GetCharArrayInfo(char[] chars, int startIndex, int count)
        {
            StringBuilder sb = new StringBuilder();

            if (null == chars) return string.Empty;
            if (0 == chars.Length)
            {
                sb.Append("\nThe character array is zero-length array: {}");
            }
            else
            {
                sb.Append("\nThe character array is: {");
                for (int i = 0; i < chars.Length; ++i)
                {
                    if (0 == (i & 0xf)) sb.Append("\n");
                    sb.AppendFormat("\t\\u{0:X04}, ", (int)chars[i]);
                }
                sb.Append("}");
            }
            sb.AppendFormat("\nThe length of character array: {0}", chars.Length);
            sb.AppendFormat("\nStart index for encoding: {0}\nCount of character encoded: {1}",
                            startIndex, count);

            return sb.ToString();
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:25,代码来源:ASCIIEncodingGetByteCount2.cs

示例8: Include

    private static HtmlString Include(string path)
    {
        if (HttpRuntime.Cache[path] == null)
        {
            var absolute = HostingEnvironment.MapPath(path) ?? "";
            var ext = Path.GetExtension(absolute);
            var fmt = ext == ".js"
                ? "<script type=\"text/javascript\" src=\"{0}\"></script>\n"
                : "<link href=\"{0}\" rel=\"stylesheet\" />\n";
            var result = new StringBuilder();
#if DEBUG
            result.AppendFormat(fmt, path);
#else
            const string min = ".min";
            var dt = File.GetLastWriteTime(absolute);
            var f = Path.GetFileNameWithoutExtension(absolute);
            var d = path.Remove(path.LastIndexOf('/'));
            var t = $"v-{dt:yyMMddhhmmss}-";
            var minfile = $"{d}/{f}{min}{ext}";
            var p = File.Exists(HostingEnvironment.MapPath(minfile))
                ? $"{d}/{t}{f}{min}{ext}"
                : $"{d}/{t}{f}{ext}";
            result.AppendFormat(fmt, p);
#endif
            HttpRuntime.Cache.Insert(path, result.ToString(), new CacheDependency(absolute));
        }
        return new HtmlString(HttpRuntime.Cache[path] as string);
    }
开发者ID:stevesloka,项目名称:bvcms,代码行数:28,代码来源:Fingerprint.cs

示例9: LogGestures

    void LogGestures(BaseGesture[] gestures, long frameKey)
    {
        StringBuilder logLine = new StringBuilder();
        logLine.AppendFormat("Gestures frame: {0}, contains {1} gestures\n", frameKey, gestures.Length);

        int gestureCounter = 0;

        foreach (BaseGesture gesture in gestures)
        {
            string additionalGestureData = "";
            // Update messages for gesture

            switch (gesture.Type)
            {
            case BaseGesture.GestureType.HEAD_POSITION:
            {
                HeadPositionGesture headPositionGesture = gesture as HeadPositionGesture;
                additionalGestureData = " (" + headPositionGesture.RegionIndex+")";
                break;
            }
            case BaseGesture.GestureType.WINGS:
            {
                WingsGesture wingsGesture = gesture as WingsGesture;
                additionalGestureData = " (" + wingsGesture.ArmsAngle + ")";
                break;
            }
            default:
                break;
            }
            logLine.AppendFormat("{0}. Gesture id: {1} -  {2}{3}\n",gestureCounter, gesture.ID , gesture.Description, additionalGestureData);
            gestureCounter++;
        }
        Debug.Log(logLine);
    }
开发者ID:erikhansen418dev,项目名称:TrainingMotionApp,代码行数:34,代码来源:GesturesUpdate.cs

示例10: PolynomMultiplication

 static void PolynomMultiplication(int[] firstPol, int[] secondPol)
 {
     int[] multiPol = new int[firstPol.Length + secondPol.Length];
     int startPoint = 0;
     for (int i = 0; i < firstPol.Length; i++)
     {
         startPoint = i;
         for (int j = 0; j < secondPol.Length; j++)
         {
             multiPol[startPoint] = multiPol[startPoint] + (secondPol[j] * firstPol[i]);
             startPoint++;
         }
     }
     StringBuilder strMultiPol = new StringBuilder();
     if (multiPol[0] != 0)
     {
         strMultiPol.AppendFormat("{0} ", multiPol[0]);
     }
     for (int i = 1; i < multiPol.Length; i++)
     {
         if (multiPol[i] != 0 && multiPol[i] > 0)
         {
             strMultiPol.AppendFormat("+ {0}x^{1} ", multiPol[i], i);
         }
         if (multiPol[i] < 0)
         {
             strMultiPol.AppendFormat("{0}x^{1} ", multiPol[i], i);
         }
     }
     Console.WriteLine(strMultiPol.ToString());
 }
开发者ID:peterlambov,项目名称:CSharp,代码行数:31,代码来源:Extended.cs

示例11: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        string likeElementForSearchingDB = string.Empty;

        if (Request.QueryString.Count == 3)
        {
            likeElementForSearchingDB = Request.QueryString[2];

        }

        PatientInfoDAL objPat_Info = new PatientInfoDAL();

        objPat_Info = new PatientInfoDAL();

        DataTable Doc_Names = objPat_Info.get_DoctorNames(likeElementForSearchingDB);

        var sb = new StringBuilder();
        for (int i = 0; i < Doc_Names.Rows.Count; i++)
        {
            switch (i)
            {
                case 0:
                    sb.AppendFormat(keyValueFormater, Doc_Names.Rows[i][2], string.Format("{1}, {0} - {2}", Doc_Names.Rows[i][1], Doc_Names.Rows[i][0], Doc_Names.Rows[i][3]), "{", "}");
                    break;
                default:
                    sb.AppendFormat(keyValueFormaterIntermediatElement, Doc_Names.Rows[i][2], string.Format("{1}, {0} - {2}", Doc_Names.Rows[i][1], Doc_Names.Rows[i][0], Doc_Names.Rows[i][3]), "{", "}");
                    break;
            }
        }
        Response.Write(string.Format(jasonPacketFormater, sb.ToString()));
    }
开发者ID:aptivasoft,项目名称:Adio,代码行数:31,代码来源:AutoCompleteDoctors.aspx.cs

示例12: ConvertToMessage

    public string ConvertToMessage(AttributeData attributeData)
    {
        var stringBuilder = new StringBuilder();
        var message = attributeData.Message;
        if (message != null)
        {
            message = message.Trim();
            message = message.Trim('.');
            stringBuilder.AppendFormat("{0}. ", message);
        }

        if (attributeData.Replacement != null)
        {
            stringBuilder.AppendFormat(ReplacementFormat, attributeData.Replacement);
        }

        if (assemblyVersion < attributeData.TreatAsErrorFromVersion)
        {
            stringBuilder.AppendFormat(TreatAsErrorFormat, attributeData.TreatAsErrorFromVersion.ToSemVer());
        }
        if (attributeData.ThrowsNotImplemented)
        {
            stringBuilder.Append(ThrowsNotImplementedText);
        }
        stringBuilder.AppendFormat(RemoveInVersionFormat, attributeData.RemoveInVersion.ToSemVer());

        return stringBuilder.ToString().Trim();
    }
开发者ID:Fody,项目名称:Obsolete,代码行数:28,代码来源:DataFormatter.cs

示例13: Create

    /// <summary>
    /// 定数を管理するクラスを自動生成する
    /// </summary>
    /// <param name="className">クラスの名前</param>
    /// <param name="classInfo">なんのクラスか説明するコメント文</param>
    /// <param name="variableDic">定数名とその値をセットで登録したDictionary</param>
    /// <typeparam name="T">定数の型、stringかintかfloat</typeparam>
    public static void Create(string className, string classInfo, string[] value)
    {
        //コメント文とクラス名を入力
        StringBuilder builder = new StringBuilder();

        builder.AppendLine("/// <summary>");
        builder.AppendFormat("/// {0}", classInfo).AppendLine();
        builder.AppendLine("/// </summary>");
        builder.AppendFormat("namespace {0}", className).AppendLine("{");
        builder.Append("\t").AppendFormat("public enum SceneName").AppendLine("{");
        for (int i = 0; i < value.Length; i++)
        {
            builder.Append("\t\t").AppendFormat("{0},", value[i]).AppendLine("");
        }

        builder.Append("\t").AppendLine("}");
        builder.AppendLine("}");

        //書き出し、ファイル名はクラス名.cs
        string exportPath = "Assets/Scripts/Scripts/Constants/AutoCreating/" + className + ".cs";

        //書き出し先のディレクトリが無ければ作成
        string directoryName = Path.GetDirectoryName(exportPath);
        if (!Directory.Exists(directoryName))
        {
            Directory.CreateDirectory(directoryName);
        }

        File.WriteAllText(exportPath, builder.ToString(), Encoding.UTF8);
        AssetDatabase.Refresh(ImportAssetOptions.ImportRecursive);

        Debug.Log(className+"の作成が完了しました");
    }
开发者ID:InagakiTatuya,项目名称:NKC_GlideRace,代码行数:40,代码来源:ConstantsClassCreator.cs

示例14: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        var sb = new StringBuilder();
        sb.AppendFormat(@"<ul class=""tin-view-navi-menus spa-view-navi-menus"">");
        sb.AppendFormat(@"<li>
        <a href=""/"" class=""tin-view-navi-menus-item home"">
        Trang chủ
        </a>
        </li>");
        sb.Append(
            @"<li><a class=""tin-view-navi-menus-item"" href=""/Spa-khuyen-mai/"">Spa khuyến mãi</a></li>");
        sb.AppendFormat(@"</ul>");
        txtPath = sb.ToString();

        this.Page.Header.Title = string.Format(Item.Ten + " Spa khuyến mãi, Spa giảm giá, spa voucher - Tạp chí spa");

        var meta = new HtmlMeta();
        meta.Name = "description";
        meta.Content = Item.MoTa;
        this.Page.Header.Controls.Add(meta);

        meta = new HtmlMeta();
        meta.Name = "og:description";
        meta.Content = Item.MoTa;
        this.Page.Header.Controls.Add(meta);

        meta = new HtmlMeta();
        meta.Name = "og:title";
        meta.Content = string.Format(Item.Ten + " Spa khuyến mãi, Spa giảm giá, spa voucher - Tạp chí spa");
        this.Page.Header.Controls.Add(meta);
    }
开发者ID:nhatkycon,项目名称:spav4,代码行数:31,代码来源:km_view.ascx.cs

示例15: Application_Error

    protected void Application_Error(Object sender, EventArgs e)
    {

        StringBuilder message = new StringBuilder();

        // String e1 = Context.Error.ToString();

        if (Request != null)
        {
            message.AppendFormat(uriFormat, Request.Path);
        }

        if (Server != null)
        {

            Exception ex;
            for (ex = Server.GetLastError(); ex != null; ex = ex.InnerException)
            {

                message.AppendFormat(exceptionFormat,
                    ex.GetType().Name,
                    ex.Message,
                    ex.StackTrace);
            }
        }

        Session["TheException"] = message.ToString();


    }
开发者ID:shukla2009,项目名称:Personal,代码行数:30,代码来源:Global.asax.cs


注:本文中的StringBuilder.AppendFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。