Replace() public method

public Replace ( char oldChar, char newChar ) : StringBuilder
oldChar char
newChar char
return StringBuilder
		public override string GetUpdateCommand()
		{
            var sb = new StringBuilder();
						sb.Append("UPDATE `" + TableName + "` SET ");
			if(position_x != null)
			{
				sb.AppendLine("`position_x`='" + ((Decimal)position_x.Value).ToString() + "'");
			}
			if(position_y != null)
			{
				sb.AppendLine("`position_y`='" + ((Decimal)position_y.Value).ToString() + "'");
			}
			if(position_z != null)
			{
				sb.AppendLine("`position_z`='" + ((Decimal)position_z.Value).ToString() + "'");
			}
			if(orientation != null)
			{
				sb.AppendLine("`orientation`='" + ((Decimal)orientation.Value).ToString() + "'");
			}
			if(spawntimesecs != null)
			{
				sb.AppendLine("`spawntimesecs`='" + spawntimesecs.Value.ToString() + "'");
			}
			if(comment != null)
			{
				sb.AppendLine("`comment`='" + comment.ToSQL() + "'");
			}
				sb = sb.Replace("\r\n", ", ");
				sb.Append(" WHERE `id`='" + id.Value.ToString() + "';");
				sb = sb.Replace(",  WHERE", " WHERE");

            return sb.ToString();
		}
Beispiel #2
0
        public async void WriteAsync(DataTable data, string outputFile)
        {
            StringBuilder fileContent = new StringBuilder();

            foreach (var col in data.Columns)
            {
                fileContent.Append("\"" + col.ToString() + "\";");
            }

            fileContent.Replace(";", System.Environment.NewLine, fileContent.Length - 1, 1);



            foreach (DataRow dr in data.Rows)
            {

                foreach (var column in dr.ItemArray)
                {
                    fileContent.Append("\"" + column.ToString() + "\";");
                }

                fileContent.Replace(";", System.Environment.NewLine, fileContent.Length - 1, 1);
            }

            await Task.Run(() => System.IO.File.WriteAllText(outputFile, fileContent.ToString(), Encoding.Unicode));

        }
        public static string ToCsv(this DataTable dataTable)
        {
            var sbData = new StringBuilder();

            // Only return Null if there is no structure.
            if (dataTable.Columns.Count == 0)
                return null;

            foreach (var col in dataTable.Columns)
            {
                if (col == null)
                    sbData.Append(",");
                else
                    sbData.Append("\"" + col.ToString().Replace("\"", "\"\"") + "\",");
            }

            sbData.Replace(",", System.Environment.NewLine, sbData.Length - 1, 1);

            foreach (DataRow dr in dataTable.Rows)
            {
                foreach (var column in dr.ItemArray)
                {
                    if (column == null)
                        sbData.Append(",");
                    else
                        sbData.Append("\"" + column.ToString().Replace("\"", "\"\"") + "\",");
                }
                sbData.Replace(",", System.Environment.NewLine, sbData.Length - 1, 1);
            }

            return sbData.ToString();
        }
        public override string GetUpdateCommand()
        {
            var sb = new StringBuilder();
                        sb.Append("UPDATE `" + TableName + "` SET ");
            if(path_rotation0 != null)
            {
                sb.AppendLine("`path_rotation0`='" + ((Decimal)path_rotation0.Value).ToString() + "'");
            }
            if(path_rotation1 != null)
            {
                sb.AppendLine("`path_rotation1`='" + ((Decimal)path_rotation1.Value).ToString() + "'");
            }
            if(path_rotation2 != null)
            {
                sb.AppendLine("`path_rotation2`='" + ((Decimal)path_rotation2.Value).ToString() + "'");
            }
            if(path_rotation3 != null)
            {
                sb.AppendLine("`path_rotation3`='" + ((Decimal)path_rotation3.Value).ToString() + "'");
            }
                sb = sb.Replace("\r\n", ", ");
                sb.Append(" WHERE `guid`='" + guid.Value.ToString() + "';");
                sb = sb.Replace(",  WHERE", " WHERE");

            return sb.ToString();
        }
Beispiel #5
0
 internal static string Generate_SVC(string pServiceName, string prjName)
 {
     StringBuilder wClassContainer = new StringBuilder(_SVC_tt);
     wClassContainer.Replace(CommonConstants.CONST_SERVICE_NAME, pServiceName);
     wClassContainer.Replace(CommonConstants.CONST_FwkProject_NAME, prjName);
     return wClassContainer.ToString();
 }
Beispiel #6
0
        private static string GenMethodReturn(Table pTable, MethodActionType t)
        {
            StringBuilder wBuilderReturn = null;
            switch (t)
            {
                case MethodActionType.Insert:
                    {
                        Column pPK = FwkGeneratorHelper.GetPrimaryKey(pTable);
                        if (pPK != null)
                        {
                            wBuilderReturn = new StringBuilder(FwkGeneratorHelper.TemplateDocument.GetTemplate("InsertReturn").Content);
                            wBuilderReturn.Replace(CommonConstants.CONST_ENTITY_PROPERTY_NAME, pPK.Name);
                            wBuilderReturn.Replace(CommonConstants.CONST_TYPENAME, FwkGeneratorHelper.GetCSharpType(pPK));

                            return wBuilderReturn.ToString();
                        }
                        else
                            return "  wDataBase.ExecuteNonQuery(wCmd);";
                    }
                case MethodActionType.Update:
                    return "  wDataBase.ExecuteNonQuery(wCmd);";

                case MethodActionType.SearchByParam:

                    wBuilderReturn = new StringBuilder(FwkGeneratorHelper.TemplateDocument.GetTemplate("SearchReturn").Content);

                    return wBuilderReturn.ToString();
                case MethodActionType.Delete:
                    return  "  wDataBase.ExecuteNonQuery(wCmd);";

            }

            return string.Empty;

        }
        protected override void RegisterClientScripts()
        {
            base.RegisterClientScripts();

            //Style Sheet
            LiteralControl include = new LiteralControl("<link href='css/YUI/calendar.css' rel='stylesheet' type='text/css' />");
            this.Page.Header.Controls.Add(include);

            //scripts
            //RegisterIncludeScript("QueryBuilder", "Sage.SalesLogix.Client.GroupBuilder.jscript.querybuilder.js", true);
            RegisterIncludeScript("Yahoo_yahoo", "jscript/YUI/yahoo.js", false);
            RegisterIncludeScript("Yahoo_event", "jscript/YUI/event.js", false);
            RegisterIncludeScript("TimeObject", "jscript/timeobjs.js", false);

            if (!Page.ClientScript.IsClientScriptBlockRegistered("QBAddCondition"))
            {
                string vScript = ScriptHelper.UnpackEmbeddedResourceToString("jscript.QBAddCondition.js");
                StringBuilder vJS = new StringBuilder(vScript);

                vJS.Replace("@DateValueClientID", DateValue.ClientID + "_TXT");
                vJS.Replace("@DateValueFormat", DateValue.DateFormat);

                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "QBAddCondition", vJS.ToString(), true);
            }
        }
        /*	Write a program that replaces all occurrences of the sub-string start with the sub-string
        finish in a text file.
            Ensure it will work with large files (e.g. 100 MB).*/
        static void Main()
        {
            string path = "test.txt";
            StringBuilder builder = new StringBuilder();

            try
            {
                StreamReader reader = new StreamReader(path);

                using (reader)
                {
                    string line = reader.ReadLine();

                    while (line != null)
                    {
                        builder.AppendLine(line);
                        line = reader.ReadLine();
                    }

                    reader.Close();
                }

                builder = builder.Replace("start", "finish");
                builder = builder.Replace("Start", "Finish");

                WriteToFile(builder, path);

                Console.WriteLine(builder.ToString());
            }
            catch (Exception)
            {
                Console.WriteLine("Error! File can not be found!");
            }
        }
        /// <summary>
        /// 生成播放Flv格式文件的HTML代码
        /// </summary>
        /// <param name="url">Flv格式文件的URL</param>
        /// <param name="width">播放控件的显示宽度</param>
        /// <param name="height">播放控件的显示高度</param>
        /// <returns></returns>
        public static string MakeFlvHtml(string url, int width, int height)
        {
            string fileName = AppPath.CurrentAppPath() + "content\\FlashTemplate.txt";
            var objReader = new StreamReader(fileName);
            string sLine = "";
            var arrText = new ArrayList();
            while (sLine != null)
            {
                sLine = objReader.ReadLine();
                if (sLine != null)
                    arrText.Add(sLine);
            }
            objReader.Close();

            var buff = new StringBuilder();
            foreach (string sOutput in arrText)
            {
                buff.Append(sOutput);
                buff.Append(Environment.NewLine);
            }
            buff.Replace("{source}", url);
            buff.Replace("{width}", width + "");
            buff.Replace("{height}", height + "");

            return buff.ToString();
        }
        public string SanitizeHTML(string content)
        {
            // Check to see if the incoming contant contains <script> or </script>.
            // These are unsafe HTML tags.
            var tag1 = "<script>";
            var tag2 = "</script>";

            if (content.Contains(tag1) || content.Contains(tag2))
            {
                var sanitize = new StringBuilder(content);

                // The Replace() Method replaces within a substring of an instance all occurances of a specified character
                // with another character
                sanitize.Replace("<script>", "&lt;script&gt;");
                sanitize.Replace("</script>", "&lt/script&gt;");

                // The 'sanitize' is an object of the class Stringbuilder. In order to return a string to the
                // Main method, perform the ToString() method on the object 'sanitize'.
                var result = sanitize.ToString();

                //Assert Assumption that sanitize.ToString() in fact changed
                Debug.Assert(result is string, "The variable 'result' is not a string");
                return result;
            }

            // If the content does not contain any harmful HTML tags, return the content unchanged
            return content;
        }
Beispiel #11
0
 public static byte[] GetBytes(string pkt)
 {
     var r = new StringReader(pkt);
     var sb = new StringBuilder();
     string str;
     while((str = r.ReadLine()) != null) {
         int i = 0;
         try {
             i = Convert.ToInt32(str.Substring(0, 4), 16);
         }
         catch {
         }
         if(i == 0) {
             if(sb.Length > 0) {
                 sb.Replace(" ", "").Replace("-", "").Replace("\r", "").Replace("|", "");
                 return HexToBytes(sb.ToString());
             }
             sb.Length = 0;
         }
         string[] strArr3 = str.Split(':');
         if(strArr3.Length > 2) {
             sb.Append(strArr3[1]);
         }
     }
     if(sb.Length > 0) {
         sb.Replace(" ", "").Replace("-", "").Replace("\r", "").Replace("|", "");
         return HexToBytes(sb.ToString());
     }
     return null;
 }
 static StringBuilder ReplaceHtmlEscapes(StringBuilder sb)
 {
     sb = sb.Replace("\"", "&quot;");
     sb = sb.Replace("<", "&lt;");
     sb = sb.Replace(">", "&gt;");
     return sb;
 }
		public override string GetUpdateCommand()
		{
            var sb = new StringBuilder();
						sb.Append("UPDATE `" + TableName + "` SET ");
			if(spell_id != null)
			{
				sb.AppendLine("`spell_id`='" + spell_id.Value.ToString() + "'");
			}
			if(quest_start != null)
			{
				sb.AppendLine("`quest_start`='" + quest_start.Value.ToString() + "'");
			}
			if(quest_start_active != null)
			{
				sb.AppendLine("`quest_start_active`='" + quest_start_active.Value.ToString() + "'");
			}
			if(quest_end != null)
			{
				sb.AppendLine("`quest_end`='" + quest_end.Value.ToString() + "'");
			}
			if(cast_flags != null)
			{
				sb.AppendLine("`cast_flags`='" + cast_flags.Value.ToString() + "'");
			}
				sb = sb.Replace("\r\n", ", ");
				sb.Append(" WHERE `npc_entry`='" + npc_entry.Value.ToString() + "';");
				sb = sb.Replace(",  WHERE", " WHERE");

            return sb.ToString();
		}
        public override string GetUpdateCommand()
        {
            var sb = new StringBuilder();
                        sb.Append("UPDATE `" + TableName + "` SET ");
            if(parent != null)
            {
                sb.AppendLine("`parent`='" + parent.Value.ToString() + "'");
            }
            if(levelmin != null)
            {
                sb.AppendLine("`levelmin`='" + levelmin.Value.ToString() + "'");
            }
            if(levelmax != null)
            {
                sb.AppendLine("`levelmax`='" + levelmax.Value.ToString() + "'");
            }
            if(scriptname != null)
            {
                sb.AppendLine("`scriptname`='" + scriptname.ToSQL() + "'");
            }
                sb = sb.Replace("\r\n", ", ");
                sb.Append(" WHERE `map`='" + map.Value.ToString() + "';");
                sb = sb.Replace(",  WHERE", " WHERE");

            return sb.ToString();
        }
        public override string GetUpdateCommand()
        {
            var sb = new StringBuilder();
                        sb.Append("UPDATE `" + TableName + "` SET ");
            if(prev_spell != null)
            {
                sb.AppendLine("`prev_spell`='" + prev_spell.Value.ToString() + "'");
            }
            if(first_spell != null)
            {
                sb.AppendLine("`first_spell`='" + first_spell.Value.ToString() + "'");
            }
            if(rank != null)
            {
                sb.AppendLine("`rank`='" + rank.Value.ToString() + "'");
            }
            if(req_spell != null)
            {
                sb.AppendLine("`req_spell`='" + req_spell.Value.ToString() + "'");
            }
                sb = sb.Replace("\r\n", ", ");
                sb.Append(" WHERE `spell_id`='" + spell_id.Value.ToString() + "';");
                sb = sb.Replace(",  WHERE", " WHERE");

            return sb.ToString();
        }
	public static void Main(){

		string line;
		string temptab = "      \"temp\" : \"";
		string datetab = "      \"date\" : \"";

		System.IO.StreamReader file = new System.IO.StreamReader("bedroom.json");
		int ctr = 0;
		while((line = file.ReadLine()) != null)
		{
			
			if (line.Contains("temp") || line.Contains("date")){


				StringBuilder b = new StringBuilder(line);
				b.Replace(temptab, "");
				b.Replace(datetab, "");
				b.Replace("\"", "").Replace(",", "");

				if (ctr % 2 ==0){
					Console.Write(b + ",");
				}else {
					Console.WriteLine(b);
				}
				ctr++;
			}	   
		}
		file.Close();
		}
Beispiel #17
0
        //does the formatting job
        private string FormatCode(string source, bool lineNumbers,
            bool alternate, bool embedStyleSheet, bool subCode)
        {
            //replace special characters
            StringBuilder sb = new StringBuilder(source);

            sb.Replace("&", "&amp;");
            sb.Replace("<", "&lt;");
            sb.Replace(">", "&gt;");
            sb.Replace("\t", string.Empty.PadRight(this.TabSpaces));

            source = sb.ToString();
            
            sb = new StringBuilder();

            if (embedStyleSheet)
            {
                sb.Append("<style type=\"text/css\">\n");
                sb.Append(GetCssString());
                sb.Append("</style>\n");
            }

            //have to use a <pre> because IE below ver 6 does not understand 
            //the "white-space: pre" CSS value
            if (!subCode)
                sb.Append("<pre class=\"csharpcode\">");
            sb.Append(source);
            if (!subCode)
                sb.Append("</pre>");

            return sb.ToString();
        }
Beispiel #18
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public static string SantiseWindowsPath (string path)
    {
      // 
      // Sanitise a Windows path.
      // 

      string expandedPath;

      if (path.Contains ("~"))
      {
        expandedPath = GetLongPathName (path);
      }
      else
      {
        expandedPath = path;
      }

      StringBuilder workingBuffer = new StringBuilder (expandedPath);

      workingBuffer.Replace (@"\\", "/");

      workingBuffer.Replace (@"\", "/");

      return QuoteIfNeeded (EscapePath (workingBuffer.ToString ()));
    }
        public ActionResult Create(Comment comment)
        {
            StringBuilder sbComments = new StringBuilder();

            // Encode the text that is coming from comments textbox
            sbComments.Append(HttpUtility.HtmlEncode(comment.Comments));

            // Only decode bold and underline tags
            sbComments.Replace("&lt;b&gt;", "<b>");
            sbComments.Replace("&lt;/b&gt;", "</b>");
            sbComments.Replace("&lt;u&gt;", "<u>");
            sbComments.Replace("&lt;/u&gt;", "</u>");
            comment.Comments = sbComments.ToString();

            // HTML encode the text that is coming from name textbox
            string strEncodedName = HttpUtility.HtmlEncode(comment.Name);
            comment.Name = strEncodedName;

            if (ModelState.IsValid)
            {
                db.Comments.Add(comment);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(comment);
        }
Beispiel #20
0
        //private static string GetHeaderInfo(string text)
        //{
        //    if (text.StartsWith(prefix))
        //    {
        //        int last = text.IndexOf(suffix);
        //        string info = text.Substring(prefix.Length, last);
        //        return info;
        //    }
        //    return string.Empty;
        //}
        public static void DocumentOpenedEvent(Document document)
        {
            //是新打开的文件
            if (newOpenDocNameList.Contains(document.Name))
            {
                //清除新打开的记录
                newOpenDocNameList.Remove(document.Name);

                //只对.cs结尾的文件添加
                if (document.FullName.ToLower().EndsWith(".cs")
                    || document.FullName.ToLower().EndsWith(".js")
                    || document.FullName.ToLower().EndsWith(".css")
                    )
                {

                    //添加文件头信息
                    StringBuilder templete = new StringBuilder(BaseUCSetting.SettingModel.AutoHeaderModel.AutoHeaderTemplete);
                    if (!string.IsNullOrEmpty(templete.ToString()))
                    {
                        templete = templete.Replace("[CurrentTime]", DateTime.Now.ToString());
                        templete = templete.Replace("[User]", Environment.UserName);
                        //templete.Insert(0, prefix + "\n");
                        //templete.Append("\n " + suffix + "\n");

                        VSDocument.Insert(document, 1, 1, templete.ToString());
                    }
                }
            }

            // VsOutput.ShowGeneralMessage(document.Name + " 打开了");
        }
Beispiel #21
0
 /// <summary>
 /// 安全中心发送验证手机短信
 /// </summary>
 /// <param name="to">接收手机</param>
 /// <param name="code">验证值</param>
 /// <returns></returns>
 public static bool SendSCVerifySMS(string to, string code)
 {
     StringBuilder body = new StringBuilder(_smsconfiginfo.SCVerifyBody);
     body.Replace("{mallname}", _mallconfiginfo.MallName);
     body.Replace("{code}", code);
     return _ismsstrategy.Send(to, body.ToString());
 }
Beispiel #22
0
        public string Compile(bool minify)
        {
            var js = jslastvalid;
            var html = htmllastvalid;

            // Merge fields
            var output = new StringBuilder(html);
            output.Replace("%resourcepath%", Program.BlobPathResource);
            output.Replace("%build%", Program.Config.Configuration.Build.ToString());
            output.Replace("%buildserial%", Program.Config.Configuration.BuildSerial.ToString());
            html = output.ToString();

            // Minify
            if (minify) {
                js = Minify.MinifyJS(js);
                html = Minify.MinifyHTML(html);
            }

            // Add JS
            var doc = new HtmlDocument();
            doc.LoadHtml(html);
            doc.GetElementbyId("_script_").AppendChild(doc.CreateComment(js));

            return doc.DocumentNode.OuterHtml;
        }
		public override string GetUpdateCommand()
		{
            var sb = new StringBuilder();
						sb.Append("UPDATE `" + TableName + "` SET ");
			if(entry_id != null)
			{
				sb.AppendLine("`entry_id`='" + entry_id.Value.ToString() + "'");
			}
			if(modelid != null)
			{
				sb.AppendLine("`modelid`='" + modelid.Value.ToString() + "'");
			}
			if(equipment_id != null)
			{
				sb.AppendLine("`equipment_id`='" + equipment_id.Value.ToString() + "'");
			}
			if(spell_start != null)
			{
				sb.AppendLine("`spell_start`='" + spell_start.Value.ToString() + "'");
			}
			if(spell_end != null)
			{
				sb.AppendLine("`spell_end`='" + spell_end.Value.ToString() + "'");
			}
			if(event_ != null)
			{
				sb.AppendLine("`event`='" + event_.Value.ToString() + "'");
			}
				sb = sb.Replace("\r\n", ", ");
				sb.Append(" WHERE `guid`='" + guid.Value.ToString() + "';");
				sb = sb.Replace(",  WHERE", " WHERE");

            return sb.ToString();
		}
        public static void UsingStringBuilder()
        {
            var greetingBuilder =
                new StringBuilder("Hello from all the guys at Wrox Press. ", 150);
            greetingBuilder.AppendFormat("We do hope you enjoy this book as much as we " +
                "enjoyed writing it");

            WriteLine("Not Encoded:\n" + greetingBuilder);

            for (int i = 'z'; i >= 'a'; i--)
            {
                char old1 = (char)i;
                char new1 = (char)(i + 1);
                greetingBuilder = greetingBuilder.Replace(old1, new1);
            }

            for (int i = 'Z'; i >= 'A'; i--)
            {
                char old1 = (char)i;
                char new1 = (char)(i + 1);
                greetingBuilder = greetingBuilder.Replace(old1, new1);
            }

            WriteLine("Encoded:\n" + greetingBuilder);

        }
        public override string GetUpdateCommand()
        {
            var sb = new StringBuilder();
                        sb.Append("UPDATE `" + TableName + "` SET ");
            if(x != null)
            {
                sb.AppendLine("`x`='" + ((Decimal)x.Value).ToString() + "'");
            }
            if(y != null)
            {
                sb.AppendLine("`y`='" + ((Decimal)y.Value).ToString() + "'");
            }
            if(icon != null)
            {
                sb.AppendLine("`icon`='" + icon.Value.ToString() + "'");
            }
            if(flags != null)
            {
                sb.AppendLine("`flags`='" + flags.Value.ToString() + "'");
            }
            if(data != null)
            {
                sb.AppendLine("`data`='" + data.Value.ToString() + "'");
            }
            if(icon_name != null)
            {
                sb.AppendLine("`icon_name`='" + icon_name.ToSQL() + "'");
            }
                sb = sb.Replace("\r\n", ", ");
                sb.Append(" WHERE `entry`='" + entry.Value.ToString() + "';");
                sb = sb.Replace(",  WHERE", " WHERE");

            return sb.ToString();
        }
Beispiel #26
0
        /// <summary>
        /// 发送电子邮件
        /// </summary>
        /// <param name="from">发件邮箱地址</param>
        /// <param name="password">邮箱密码</param>
        /// <param name="to">收件人地址</param>
        /// <param name="subject">邮件标题</param>
        /// <param name="body">邮件正文</param>
        /// <param name="smtpHost">SMTP服务器</param>
        /// <returns>发送邮件是否成功</returns>
        public static void SentMail(string from, string loginName, string password, string to, string subject, string body, string smtpHost, string toUser)
        {
            MailMessage message = new MailMessage();
            message.From = new MailAddress(from, "浩奇广告联盟", Encoding.GetEncoding("UTF-8"));

            message.Subject = subject;
            message.IsBodyHtml = true;
            message.BodyEncoding = System.Text.Encoding.UTF8;

            message.To.Add(new MailAddress(to));

            #region 读取模版
            StringBuilder sb = new StringBuilder();
            string t = Voodoo.IO.File.Read("~/Config/mail.htm", Voodoo.IO.File.EnCode.UTF8);
            if (string.IsNullOrEmpty(t))
            {
                t = "";
            }
            sb.Append(t);
            sb = sb.Replace("{Title}", subject);
            sb = sb.Replace("{Content}", body);
            sb = sb.Replace("{ToUser}", toUser);
            sb = sb.Replace("{Time}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            sb = sb.Replace("{ToMail}", to);
            message.Body = sb.ToString();
            #endregion

            //message.Body = body;

            SmtpClient client = new SmtpClient();
            client.Host = smtpHost;
            client.Credentials = new System.Net.NetworkCredential(loginName, password);
            client.Send(message);
        }
Beispiel #27
0
        protected void CombineIndex()
        {
            var rootPath = RootPath;

            //file table
            var viewList = new List<string>() { "/Views/Home.html", "/Views/Lobby.html",
                                                "/Views/Games.html", "/Views/Create.html",
                                                "/Views/Community.html", "/Views/Play.html" };

            StringBuilder indexTemplate = new StringBuilder(),
                viewCollection = new StringBuilder();

            //read template
            indexTemplate.Append(File.ReadAllText(rootPath + "/Views/Main.html"));

            foreach (var view in viewList)
            {
                viewCollection.Append(File.ReadAllText(rootPath + view));
            }

            indexTemplate.Replace("@view_placeholder", viewCollection.ToString());

            //dialogs fast hack
            indexTemplate.Replace("@additional_placeholder", File.ReadAllText(rootPath + "/Views/Dialogs.html"));

            using (StreamWriter index = new StreamWriter(rootPath + "/index.html", false))
            {
                index.Write(indexTemplate.ToString());
            }
        }
		public override string GetUpdateCommand()
		{
            var sb = new StringBuilder();
						sb.Append("UPDATE `" + TableName + "` SET ");
			if(racemask != null)
			{
				sb.AppendLine("`racemask`='" + racemask.Value.ToString() + "'");
			}
			if(quest != null)
			{
				sb.AppendLine("`quest`='" + quest.Value.ToString() + "'");
			}
			if(mailtemplateid != null)
			{
				sb.AppendLine("`mailtemplateid`='" + mailtemplateid.Value.ToString() + "'");
			}
			if(senderentry != null)
			{
				sb.AppendLine("`senderentry`='" + senderentry.Value.ToString() + "'");
			}
				sb = sb.Replace("\r\n", ", ");
				sb.Append(" WHERE `event`='" + event_.Value.ToString() + "';");
				sb = sb.Replace(",  WHERE", " WHERE");

            return sb.ToString();
		}
Beispiel #29
0
 /// <summary>
 /// 发送找回密码短信
 /// </summary>
 /// <param name="to">接收手机</param>
 /// <param name="code">验证值</param>
 /// <returns></returns>
 public static bool SendFindPwdMobile(string to, string code)
 {
     StringBuilder body = new StringBuilder(_smsconfiginfo.FindPwdBody);
     body.Replace("{shopname}", _shopconfiginfo.ShopName);
     body.Replace("{code}", code);
     return _ismsstrategy.Send(to, body.ToString());
 }
 static void Main(string[] args)
 {
     //We are given a string containing a list of forbidden words and a text containing
     //some of these words. Write a program that replaces the forbidden words with asterisks.Example:
     //Microsoft announced its next generation PHP compiler today.
     //It is based on .NET Framework 4.0 and is implemented as a dynamic language in CLR.
     //Words: "PHP, CLR, Microsoft"
     //The expected result:
     //********* announced its next generation *** compiler today.
     //It is based on .NET Framework 4.0 and is implemented as a dynamic language in ***.
     string text = "Microsoft announced its next generation PHP compiler today."+
         "It is based on .NET Framework 4.0 and is implemented as a dynamic language in CLR.";
     string wordOne = "Microsoft";
     StringBuilder b = new StringBuilder();
     for (int i = 0; i < wordOne.Length; i++)
         b.Append("*");
     string starsOne = b.ToString();
     b.Clear();
     string wordTwo = "PHP";
     for (int i = 0; i < wordTwo.Length; i++)
         b.Append("*");
     string starsTwo = b.ToString();
     b.Clear();
     string wordThree = "CLR";
     for (int i = 0; i < wordThree.Length; i++)
         b.Append("*");
     string starsThree = b.ToString();
     b.Clear();
     StringBuilder sb = new StringBuilder(text);
     sb.Replace(wordOne, starsOne);
     sb.Replace(wordTwo, starsTwo);
     sb.Replace(wordThree, starsThree);
     Console.WriteLine(sb.ToString());
     //text.IndexOf(wordOne);
 }