Append() public method

public Append ( bool value ) : StringBuilder
value bool
return StringBuilder
Example #1
2
		protected virtual string FormatCommentOn(string sql)
		{
			StringBuilder result = new StringBuilder(60).Append(Indent1);
			IEnumerator<string> tokens = (new StringTokenizer(sql, " '[]\"", true)).GetEnumerator();

			bool quoted = false;
			while (tokens.MoveNext())
			{
				string token = tokens.Current;
				result.Append(token);
				if (IsQuote(token))
				{
					quoted = !quoted;
				}
				else if (!quoted)
				{
					if ("is".Equals(token))
					{
						result.Append(Indent2);
					}
				}
			}

			return result.ToString();
		}
Example #2
1
		public string Replace (string str)
		{
			if (string.IsNullOrEmpty (str)) {
				return str;
			}

			System.Text.StringBuilder formatted = new System.Text.StringBuilder ();

			int lastMatch = 0;

			string variable;
			string replacement;
			foreach (System.Text.RegularExpressions.Match m in re.Matches(str)) {

				formatted.Append (str.Substring (lastMatch, m.Index - lastMatch));

				variable = m.Groups [1].Value;
				if (vars.TryGetValue (variable, out replacement))
					formatted.Append (this.Replace (replacement));
				else
                    throw new ObfuscarException("Unable to replace variable:  " + variable);

				lastMatch = m.Index + m.Length;
			}

			formatted.Append (str.Substring (lastMatch));

			return formatted.ToString ();
		}
Example #3
1
        /// <exception cref="MyException"></exception>
        public void Inserir(ICliente cliente, ILog log)
        {
            var sql = new StringBuilder();
            var tblLog = new TblClientesLog();

            sql.AppendFormat(" INSERT INTO {0} ({1},{2},{3}", tblLog.NomeTabela, tblLog.Clientes_Id, tblLog.Clientes_Nome, tblLog.Clientes_Status_Id);
            sql.AppendFormat(",{0},{1},{2})", tblLog.Usuarios_Id, tblLog.Operacao_Id, tblLog.DataHora);
            sql.Append(" VALUES (@id,@nome,@status_id");
            sql.Append(",@usuarios_id,@operacao_id,@datahora);");

            using (var dal = new DalHelperSqlServer())
            {
                try
                {
                    dal.CriarParametroDeEntrada("id", SqlDbType.Int, cliente.Id);
                    dal.CriarParametroDeEntrada("nome", SqlDbType.Char, cliente.Nome);
                    dal.CriarParametroDeEntrada("status_id", SqlDbType.SmallInt, cliente.Status.GetHashCode());
                    dal.CriarParametroDeEntrada("usuarios_id", SqlDbType.Int, log.Usuario.Id);
                    dal.CriarParametroDeEntrada("operacao_id", SqlDbType.SmallInt, log.Operacao.GetHashCode());
                    dal.CriarParametroDeEntrada("datahora", SqlDbType.DateTime, log.DataHora);

                    dal.ExecuteNonQuery(sql.ToString());
                }
                catch (SqlException) { throw new MyException("Operação não realizada, por favor, tente novamente!"); }
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        ReciboBE reciboBE;

        //if (Session["ReciboBE"] != null)
        //{
        reciboBE = Session["ReciboBE"] as ReciboBE;
        //}

        CarregaProfissional(Convert.ToInt32(reciboBE.RefProfissionalBE.id));
        lblReciboNumero.Text = Convert.ToString(reciboBE.id);
        lblValorTotalCabecalho.Text = String.Format("{0:C2}", reciboBE.ValorTotal);
        lblValorTotal.Text = String.Format("{0:C2}", reciboBE.ValorTotal);
        lblSessoesQtd.Text = Convert.ToString(reciboBE.RefReciboAgendamentoSessoesBE.Count.ToString("00"));
        lblPacienteNome.Text = Convert.ToString(reciboBE.PacienteNome);
        //Pego a possicao zero da lista de sessooes
        lblValorSessao.Text = String.Format("{0:C2}", reciboBE.RefReciboAgendamentoSessoesBE[0].Valor);

        StringBuilder sb = new System.Text.StringBuilder();
        for (int i = 0; i < reciboBE.RefReciboAgendamentoSessoesBE.Count; i++)
        {
            if (i > 0)
                sb.Append(", ");

            sb.Append(reciboBE.RefReciboAgendamentoSessoesBE[i].Data.ToString("dd/MM/yyyy"));
        }

        lblDatas.Text = Convert.ToString(sb);

        DataExtenso();
    }
 public override void AsText(StringBuilder b, int pad)
 {
     b.Append(' ', pad);
     b.AppendLine("JewelerDataInitialMessage:");
     b.Append(' ', pad++);
     b.Append(CrafterData.ToString());
 }
        internal override StringBuilder AsEsql(StringBuilder builder, bool isTopLevel, int indentLevel)
        {
            // The SELECT/DISTINCT part.
            StringUtil.IndentNewLine(builder, indentLevel);
            builder.Append("SELECT ");
            if (m_selectDistinct == CellQuery.SelectDistinct.Yes)
            {
                builder.Append("DISTINCT ");
            }
            GenerateProjectionEsql(builder, m_nodeTableAlias, true, indentLevel, isTopLevel);

            // Get the FROM part.
            builder.Append("FROM ");
            CqlWriter.AppendEscapedQualifiedName(builder, m_extent.EntityContainer.Name, m_extent.Name);
            builder.Append(" AS ").Append(m_nodeTableAlias);

            // Get the WHERE part only when the expression is not simply TRUE.
            if (!BoolExpression.EqualityComparer.Equals(WhereClause, BoolExpression.True))
            {
                StringUtil.IndentNewLine(builder, indentLevel);
                builder.Append("WHERE ");
                WhereClause.AsEsql(builder, m_nodeTableAlias);
            }

            return builder;
        }
Example #7
1
 public static object MediaHelper(string image)
 {
     var sb = new StringBuilder();
     sb.Append(ConfigurationManager.AppSettings["MediaPath"]);
     sb.Append(image);
     return new MvcHtmlString(sb.ToString());
 }
Example #8
1
		protected virtual string FormatAlterTable(string sql)
		{
			StringBuilder result = new StringBuilder(60).Append(Indent1);
			IEnumerator<string> tokens = (new StringTokenizer(sql, " (,)'[]\"", true)).GetEnumerator();

			bool quoted = false;
			while (tokens.MoveNext())
			{
				string token = tokens.Current;
				if (IsQuote(token))
				{
					quoted = !quoted;
				}
				else if (!quoted)
				{
					if (IsBreak(token))
					{
						result.Append(Indent3);
					}
				}
				result.Append(token);
			}

			return result.ToString();
		}
Example #9
1
 internal override StringBuilder AsNegatedUserString(StringBuilder builder, string blockAlias, bool skipIsNotNull)
 {
     builder.Append("NOT(");
     builder = AsUserString(builder, blockAlias, skipIsNotNull);
     builder.Append(")");
     return builder;
 }
        /// <summary>
        /// Gets the method body without definition and curly braces.
        /// </summary>
        public string GetMethodBody()
        {
            StringBuilder buffer = new StringBuilder(512);

            var signature = MethodSignature.GetIndexSignature(_index);

            buffer.AppendLine("using (var connection = GetReadOnlyConnection())");
            buffer.AppendLine("{");
            buffer.AppendLine("connection.Open();");

            buffer.AppendFormat("return connection.Query<{0}>(\"SELECT * FROM {1} WHERE ",
                                _index.Table.EntityName,
                                _index.Table.FullName);
            buffer.Append(string.Join(" AND ", signature.Parameters.Select(p => p.Key + " = @" + p.Key)));
            buffer.Append("\", new { ");
            buffer.Append(string.Join(", ", signature.Parameters.Select(p => p.Key)));

            if (!_index.Unique)
                buffer.AppendLine(" });");
            else
                buffer.AppendLine(" }).FirstOrDefault();");

            buffer.AppendLine("}");

            return buffer.ToString();
        }
Example #11
0
        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 ToString() {
     if (invariant) {
         if (invariant_result)
             return "PivotsExpression.TrueExpression";
         else
             return "PivotsExpression.FalseExpression";
     }
     StringBuilder res = new StringBuilder();
     bool first_combination = true;
     foreach (var combination in matching_combinations) {
         if (!first_combination)
             res.Append("|");
         res.Append("(");
         bool first_value = true;
         foreach (var item in combination) {
             if (!first_value)
                 res.Append(",");
             res.Append(item);
             first_value = false;
         }
         res.Append(")");
         first_combination = false;
     }
     return res.ToString();
 }
Example #13
0
        public override void Write(StringBuilder builder, int index)
        {
            if (index > 0)
                builder.Append('.');

            builder.Append(property);
        }
Example #14
0
        public static string EvaluateRelativePath(string mainDirPath, string absoluteFilePath)
        {
            string first = mainDirPath.ToUpper().Substring(0, 2);
            if (first == "\\\\" || first != absoluteFilePath.ToUpper().Substring(0, 2))
                return absoluteFilePath;
            if (mainDirPath[mainDirPath.Length - 1] != '\\')
                mainDirPath += "\\";
            StringBuilder sb = new StringBuilder();
            while (mainDirPath.Length > 0) {
                if (!absoluteFilePath.ToUpper().StartsWith(mainDirPath.ToUpper())) {
                    sb.Append("..\\");
                    int i = mainDirPath.LastIndexOf("\\");
                    if (i == mainDirPath.Length - 1) {
                        mainDirPath = mainDirPath.Remove(i, 1);
                        i = mainDirPath.LastIndexOf("\\");
                    }
                    mainDirPath = mainDirPath.Remove(i + 1, mainDirPath.Length - i - 1);
                }
                else {
                    absoluteFilePath = absoluteFilePath.Remove(0, mainDirPath.Length);
                    mainDirPath = "";
                }
            }

            sb.Append(absoluteFilePath);
            return sb.ToString();
        }
        public string FormatHtml(object data)
        {
            const string keywordFormat = "<span style=\"color: #0000FF\">{0}</span>";
            const string typeFormat = "<span style=\"color: #2B91AF\">{0}</span>";

            var methodInfo = (MethodInfo)data;
            var sb = new StringBuilder();
            var declaringType = methodInfo.DeclaringType;
            sb.AppendFormat("{0} {1}.{2} {{ ",
                string.Format(keywordFormat, "class"),
                declaringType.Namespace,
                string.Format(typeFormat, declaringType.Name));

            AppendAccess(methodInfo, sb, keywordFormat);

            if (methodInfo.IsVirtual)
            {
                sb.AppendFormat(keywordFormat, "virtual");
                sb.Append(" ");
            }

            AppendMethodName(methodInfo, sb);
            sb.Append(" (...)");
            sb.Append("}}");

            return sb.ToString();
        }
		private static string Get2000()
		{
			StringBuilder sql = new StringBuilder();
			sql.Append("SELECT groupname as name, convert(int,groupid)  AS [ID],is_default=convert(bit,status & 16),is_read_only=convert(bit,status & 8),'FG' as type ");
			sql.Append("FROM sysfilegroups ORDER BY groupname");
			return sql.ToString();
		}
Example #17
0
		/// <summary>
		/// Generates the VPS Signature from the parameters of the POST.
		/// </summary>
		public virtual string GenerateSignature(string securityKey, string vendorName) {
			var builder = new StringBuilder();
			builder.Append(VPSTxId);
			builder.Append(VendorTxCode);
			builder.Append(Status.ToString().ToUpper());
			builder.Append(TxAuthNo);
			builder.Append(vendorName.ToLower());
			builder.Append(AVSCV2);
			builder.Append(securityKey);
			builder.Append(AddressResult);
			builder.Append(PostCodeResult);
			builder.Append(CV2Result);
			builder.Append(GiftAid);
			builder.Append(ThreeDSecureStatus);
			builder.Append(CAVV);
			builder.Append(AddressStatus);
			builder.Append(PayerStatus);
			builder.Append(CardType);
			builder.Append(Last4Digits);
			builder.Append(DeclineCode);
			builder.Append(ExpiryDate);
			builder.Append(FraudResponse);
			builder.Append(BankAuthCode);
			var hash = FormsAuthentication.HashPasswordForStoringInConfigFile(builder.ToString(), "MD5");
			return hash;
		}
Example #18
0
        public void AddTableEle(TableEle tableEle, params string[] cols)
        {
            if (cols != null && cols.Length > 0)
            {
                StringBuilder th = new StringBuilder("");

                ITableItemStrategy item = TableFactoryMethod.GetTableItem(tableEle);

                for (int i = 0; i < cols.Length; i++)
                {
                    //### commented in order to render the cell regardless of null or empty string
                    //if(!"".Equals(cols[i])){ 
                    th.Append("\n" + item.Middle.Replace("{value}", cols[i]));
                    //}
                }

                if (!"".Equals(th.ToString()))
                {
                    th.Insert(0, item.Top);
                    th.Append(item.Bottom);
                }

                string finalResult = SetUpRepeatTableHeaderOnEveryPage(th);

                _txt.Append(finalResult); //final result appended
            }
        }
Example #19
0
        //public static void WriteErrFile(Exception  es,string type)
        //{
        //    try
        //    {
        //        System.Text.StringBuilder sb = new System.Text.StringBuilder("");
        //        sb.Append("������Ϣ��");
        //        sb.Append(es.Message);
        //        sb.Append("\n\r");
        //        sb.Append("����ԭ��");
        //        sb.Append(es.Source);
        //        sb.Append("\n\r");
        //        sb.Append("����λ�ã�");
        //        sb.Append(es.StackTrace);
        //        sb.Append("\n\r");
        //        sb.Append("���������");
        //        sb.Append(es.TargetSite);
        //        sb.Append("\n\r");
        //        sb.Append("����ʱ�䣺");
        //        sb.Append(DateTime.Now);
        //        sb.Append("\n\r");
        //        //string content = "";
        //        //FileStream aFile = new FileStream(Util.GetMapPath("~") + @"\errinfo.txt", FileMode.OpenOrCreate);
        //        //StreamReader dd = new StreamReader(aFile);
        //        //content = dd.ReadToEnd();
        //        StreamWriter sw = new StreamWriter(Utils.GetMapPath("~") + @"\errinfo.txt", true);
        //        sw.Write(sb.ToString());
        //        sw.Flush();
        //        sw.Close();
        //        XYECOM.
        //        string url = "";
        //        if (type == "user")
        //        {
        //             url = wci.WebURL +"user/errinfo."+wci.Suffix+"?";
        //        }
        //        else if (type == "xyecom")
        //        {
        //            url = wci.WebURL + "xymanage/err.aspx?";
        //        }
        //        else if (type == "index")
        //        {
        //            url = wci.WebURL + "page404." + wci.Suffix + "?";
        //        }
        //        else if (type == "person")
        //        {
        //            url = wci.WebURL + "person/errinfo." + wci.Suffix + "?";
        //        }
        //        //�Դ�����Դ�����ж�
        //        if (es.Source.ToString().IndexOf(".Net SqlClient Data Provider") >= 0)
        //            url += "key=002";
        //        else
        //            url += "key=003";
        //      System.Web.HttpContext.Current.Response.Redirect(url,true );
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}
        public static void WriteErrFile(Exception es)
        {
            try
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder("");
                sb.Append("������Ϣ��");
                sb.Append(es.Message);
                sb.Append("\n\r");
                sb.Append("����ԭ��");
                sb.Append(es.Source);
                sb.Append("\n\r");
                sb.Append("����λ�ã�");
                sb.Append(es.StackTrace);
                sb.Append("\n\r");
                sb.Append("���������");
                sb.Append(es.TargetSite);
                sb.Append("\n\r");
                sb.Append("����ʱ�䣺");
                sb.Append(DateTime.Now);
                sb.Append("\n\r");
                //string content = "";
                //FileStream aFile = new FileStream(Util.GetMapPath("~") + @"\errinfo.txt", FileMode.OpenOrCreate);
                //StreamReader dd = new StreamReader(aFile);
                //content = dd.ReadToEnd();
                StreamWriter sw = new StreamWriter(Utils.GetMapPath("~") + @"\errinfo.txt", true);
                sw.Write(sb.ToString());
                sw.Flush();
                sw.Close();

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private static string PascalCaseToElement(string input)
        {
            if (string.IsNullOrEmpty(input))
            {
                return null;
            }

            var result = new StringBuilder();
            result.Append(char.ToLowerInvariant(input[0]));
            
            for (var i = 1; i < input.Length; i++)
            {
                if (char.IsLower(input[i]))
                {
                    result.Append(input[i]);
                }
                else
                {
                    result.Append("_");
                    result.Append(char.ToLowerInvariant(input[i]));
                }
            }

            return result.ToString();
        }
		private static string Get2008()
		{
			StringBuilder sql = new StringBuilder();
			sql.Append("SELECT name, data_space_id AS [ID], is_default, is_read_only, type ");
			sql.Append("FROM sys.filegroups ORDER BY name");
			return sql.ToString();
		}
Example #22
0
        public void CanReadCompleContent()
        {
            // Arrange
            var content = "This is";
            var sb = new StringBuilder();
            var sr = new StreamReader(content.ToStream());
            var lab = new CharBuffer(() =>
            {
                int read = sr.Read();
                return read != -1 ? new char?((char)read) : new char?();
            }, 3);

            // Act

            while (lab.HasNext())
            {
                sb.Append(lab.PeekAt(0));
                lab.Consume();
            }

            sb.Append(lab.PeekAt(0));

            // Assert
            sb.ToString().Should().Be(content);
        }
Example #23
0
 public static object MediaHelper(string image, int width, int height, bool forceFit)
 {
     var sb = new StringBuilder();
     sb.Append(MediaHelper(image));
     sb.Append(string.Format("?width={0}&height={1}&force={2}", width, height,forceFit));
     return sb.ToString();
 }
		private static string GetFilesInFileGroup2000(FileGroup filegroup)
		{
			StringBuilder sql = new StringBuilder();
			sql.Append("select convert(int,fileid) as file_id,type=convert(tinyint,(status&64)/64),name,filename as physical_name,size,maxsize as max_size,growth,convert(bit,0) as is_sparse,is_percent_growth =convert(bit,status & 1048576) ");
			sql.Append("FROM  sysfiles where groupid="+filegroup.Id.ToString());
			return sql.ToString();
		}
Example #25
0
 private string Postfix(string prefix)
 {
     var result = new StringBuilder(prefix);
     result.Append(TileDirectionUtil.GetChar(Direction));
     result.Append(TurnDirectionUtil.GetChar(Turn));
     return result.ToString();
 }
    public static string BuildSql([NotNull] this IEnumerable<SearchCondition> conditions, bool surroundWithParathesis)
    {
      var sb = new StringBuilder();

      conditions.ForEachFirst(
        (item, isFirst) =>
          {
            sb.Append(" ");
            if (!isFirst)
            {
              sb.Append(item.ConditionType.GetStringValue());
              sb.Append(" ");
            }

            if (surroundWithParathesis)
            {
              sb.AppendFormat("({0})", (object)item.Condition);
            }
            else
            {
              sb.Append((string)item.Condition);
            }
          });

      return sb.ToString();
    }
		private static string GetFilesInFileGroup2008(FileGroup filegroup)
		{
			StringBuilder sql = new StringBuilder();
			sql.Append("select file_id,type,name,physical_name,size,max_size,growth,is_sparse,is_percent_growth ");
			sql.Append("from sys.database_files WHERE data_space_id = " + filegroup.Id.ToString());
			return sql.ToString();
		}
Example #28
0
    /// <summary>
    /// Processes the specified arguments.
    /// </summary>
    /// <param name="args">The arguments.</param>
    public virtual void Process(PipelineArgs args)
    {
      Assert.ArgumentNotNull(args, "args");

      ShoppingCart shoppingCart = Context.Entity.GetInstance<ShoppingCart>();
      PaymentProvider paymentProvider = Context.Entity.Resolve<PaymentProvider>(shoppingCart.PaymentSystem.Code);

      PaymentUrlResolver paymentUrlResolver = new PaymentUrlResolver();
      PaymentArgs paymentArgs = new PaymentArgs
      {
        ShoppingCart = shoppingCart,
        PaymentUrls = paymentUrlResolver.Resolve(),
      };

      StringBuilder description = new StringBuilder();
      foreach (ShoppingCartLine shoppingCartLine in shoppingCart.ShoppingCartLines)
      {
        description.Append(shoppingCartLine.Product.Title);
        description.Append(", ");
      }

      paymentArgs.Description = description.ToString().Trim().TrimEnd(',');

      paymentProvider.Invoke(shoppingCart.PaymentSystem, paymentArgs);

      args.AbortPipeline();
    }
Example #29
0
 public string ReadNext(bool peek = false)
 {
     var isInQuote = false;
     var curToken = new StringBuilder();
     int i;
     for (i = 0; i < _cmd.Length; i++)
     {
         if (isInQuote && _cmd[i] == '"' && i < _cmd.Length - 1 && _cmd[i + 1] == '"')
         {
             curToken.Append('"');
             i++;
             continue;
         }
         if (isInQuote == false && _cmd[i] == '"')
             isInQuote = true;
         else if (isInQuote && _cmd[i] == '"')
         {
             i++;
             break;
         }
         else if (_cmd[i] == ' ' && isInQuote == false)
             break;
         else
             curToken.Append(_cmd[i]);
     }
     if (peek == false)
     {
         _cmd = _cmd.Substring(i);
         _cmd = _cmd.TrimStart();
     }
     return curToken.ToString();
 }
Example #30
0
        private static StringBuilder ParseRoute(IEnumerator<char> tokenizer, StringBuilder routePattern, IDictionary<string, string> routeParametersVsNamedGroup, IList<string> queryParameters)
        {
            char nextCharacterInRoute = tokenizer.Current;

            if (nextCharacterInRoute == '{')
            {
                tokenizer.MoveNext();
                return ParseRouteParameter(tokenizer, routePattern, routeParametersVsNamedGroup, queryParameters);
            }
            else if (nextCharacterInRoute == '?')
            {
                routePattern.Append(Regex.Escape(nextCharacterInRoute.ToString(CultureInfo.InvariantCulture)));
                tokenizer.MoveNext();
                return ParseQueryStringParameters(tokenizer, routePattern, queryParameters);
            }
            else
            {
                routePattern.Append(Regex.Escape(nextCharacterInRoute.ToString(CultureInfo.InvariantCulture)));
                if (tokenizer.MoveNext())
                    return ParseRoute(tokenizer, routePattern, routeParametersVsNamedGroup, queryParameters);
                else
                    return routePattern;

            }
        }