System.Text.StringBuilder.Append(char*, int)

Here are the examples of the csharp api System.Text.StringBuilder.Append(char*, int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

10841 Examples 7

19 View Source File : ChatCMDChannel.cs
License : MIT License
Project Creator : 0x0ade

public override void ParseAndRun(ChatCMDEnv env) {
            CelesteNetPlayerSession? session = env.Session;
            if (session == null)
                return;

            Channels channels = env.Server.Channels;

            Channel? c;

            if (int.TryParse(env.Text, out int page) ||
                string.IsNullOrWhiteSpace(env.Text)) {

                if (channels.All.Count == 0) {
                    env.Send($"No channels. See {Chat.Settings.CommandPrefix}{ID} on how to create one.");
                    return;
                }

                const int pageSize = 8;

                StringBuilder builder = new();

                page--;
                int pages = (int) Math.Ceiling(channels.All.Count / (float) pageSize);
                if (page < 0 || pages <= page)
                    throw new Exception("Page out of range.");

                if (page == 0)
                    builder
                        .Append("You're in ")
                        .Append(session.Channel.Name)
                        .AppendLine();

                for (int i = page * pageSize; i < (page + 1) * pageSize && i < channels.All.Count; i++) {
                    c = channels.All[i];
                    builder
                        .Append(c.PublicName)
                        .Append(" - ")
                        .Append(c.Players.Count)
                        .Append(" players")
                        .AppendLine();
                }

                builder
                    .Append("Page ")
                    .Append(page + 1)
                    .Append("/")
                    .Append(pages);

                env.Send(builder.ToString().Trim());

                return;
            }

            Tuple<Channel, Channel> tuple = channels.Move(session, env.Text);
            if (tuple.Item1 == tuple.Item2) {
                env.Send($"Already in {tuple.Item2.Name}");
            } else {
                env.Send($"Moved to {tuple.Item2.Name}");
            }
        }

19 View Source File : ChatCMDHelp.cs
License : MIT License
Project Creator : 0x0ade

public string GetCommandPage(ChatCMDEnv env, int page = 0) {
            const int pageSize = 8;

            string prefix = Chat.Settings.CommandPrefix;
            StringBuilder builder = new();

            int pages = (int) Math.Ceiling(Chat.Commands.All.Count / (float) pageSize);
            if (page < 0 || pages <= page)
                throw new Exception("Page out of range.");

            for (int i = page * pageSize; i < (page + 1) * pageSize && i < Chat.Commands.All.Count; i++) {
                ChatCMD cmd = Chat.Commands.All[i];
                builder
                    .Append(prefix)
                    .Append(cmd.ID)
                    .Append(" ")
                    .Append(cmd.Args)
                    .AppendLine();
            }

            builder
                .Append("Page ")
                .Append(page + 1)
                .Append("/")
                .Append(pages);

            return builder.ToString().Trim();
        }

19 View Source File : CelesteNetPlayerListComponent.cs
License : MIT License
Project Creator : 0x0ade

public void RebuildList() {
            if (MDraw.DefaultFont == null || Client == null || Channels == null)
                return;

            DataPlayerInfo[] all = Client.Data.GetRefs<DataPlayerInfo>();

            List<Blob> list = new() {
                new Blob {
                    Text = $"{all.Length} player{(all.Length == 1 ? "" : "s")}",
                    Color = ColorCountHeader
                }
            };

            StringBuilder builder = new();


            switch (Mode) {
                case ListMode.Clreplacedic:
                    foreach (DataPlayerInfo player in all.OrderBy(p => GetOrderKey(p))) {
                        if (string.IsNullOrWhiteSpace(player.DisplayName))
                            continue;

                        builder.Append(player.DisplayName);

                        DataChannelList.Channel channel = Channels.List.FirstOrDefault(c => c.Players.Contains(player.ID));
                        if (channel != null && !string.IsNullOrEmpty(channel.Name)) {
                            builder
                                .Append(" #")
                                .Append(channel.Name);
                        }

                        if (Client.Data.TryGetBoundRef(player, out DataPlayerState state))
                            AppendState(builder, state);

                        builder.AppendLine();
                    }

                    list.Add(new() {
                        Text = builder.ToString().Trim(),
                        ScaleFactor = 1f
                    });
                    break;

                case ListMode.Channels:
                    HashSet<DataPlayerInfo> listed = new();

                    DataChannelList.Channel own = Channels.List.FirstOrDefault(c => c.Players.Contains(Client.PlayerInfo.ID));

                    if (own != null) {
                        list.Add(new() {
                            Text = own.Name,
                            Color = ColorChannelHeaderOwn
                        });

                        builder.Clear();
                        foreach (DataPlayerInfo player in own.Players.Select(p => GetPlayerInfo(p)).OrderBy(p => GetOrderKey(p))) 
                            listed.Add(ListPlayerUnderChannel(builder, player));
                        list.Add(new() {
                            Text = builder.ToString().Trim(),
                            ScaleFactor = 0.5f
                        });
                    }

                    foreach (DataChannelList.Channel channel in Channels.List) {
                        if (channel == own)
                            continue;

                        list.Add(new() {
                            Text = channel.Name,
                            Color = ColorChannelHeader
                        });

                        builder.Clear();
                        foreach (DataPlayerInfo player in channel.Players.Select(p => GetPlayerInfo(p)).OrderBy(p => GetOrderKey(p)))
                            listed.Add(ListPlayerUnderChannel(builder, player));
                        list.Add(new() {
                            Text = builder.ToString().Trim(),
                            ScaleFactor = 1f
                        });
                    }

                    bool wrotePrivate = false;

                    builder.Clear();
                    foreach (DataPlayerInfo player in all.OrderBy(p => GetOrderKey(p))) {
                        if (listed.Contains(player) || string.IsNullOrWhiteSpace(player.DisplayName))
                            continue;

                        if (!wrotePrivate) {
                            wrotePrivate = true;
                            list.Add(new() {
                                Text = "!<private>",
                                Color = ColorChannelHeaderPrivate
                            });
                        }

                        builder.AppendLine(player.DisplayName);
                    }

                    if (wrotePrivate) {
                        list.Add(new() {
                            Text = builder.ToString().Trim(),
                            ScaleFactor = 1f
                        });
                    }
                    break;
            }

            List = list;
        }

19 View Source File : CelesteNetPlayerListComponent.cs
License : MIT License
Project Creator : 0x0ade

private DataPlayerInfo ListPlayerUnderChannel(StringBuilder builder, DataPlayerInfo player) {
            if (player != null) {
                builder
                    .Append(player.DisplayName);

                if (Client.Data.TryGetBoundRef(player, out DataPlayerState state))
                    AppendState(builder, state);

                builder.AppendLine();
                return player;

            } else {
                builder.AppendLine("?");
                return null;
            }
        }

19 View Source File : CelesteNetPlayerListComponent.cs
License : MIT License
Project Creator : 0x0ade

private void AppendState(StringBuilder builder, DataPlayerState state) {
            if (!string.IsNullOrWhiteSpace(state.SID))
                builder
                    .Append(" @ ")
                    .Append(AreaDataExt.Get(state.SID)?.Name?.DialogCleanOrNull(Dialog.Languages["english"]) ?? state.SID)
                    .Append(" ")
                    .Append((char) ('A' + (int) state.Mode))
                    .Append(" ")
                    .Append(state.Level);

            if (state.Idle)
                builder.Append(" :celestenet_idle:");
        }

19 View Source File : ChatCMDHelp.cs
License : MIT License
Project Creator : 0x0ade

public string Help_GetCommandSnippet(ChatCMDEnv env, ChatCMD cmd) {
            string prefix = Chat.Settings.CommandPrefix;
            StringBuilder builder = new();

            builder
                .Append(prefix)
                .Append(cmd.ID)
                .Append(" ")
                .Append(cmd.Args)
                .AppendLine()
                .AppendLine(cmd.Help);

            return builder.ToString().Trim();
        }

19 View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000

public bool VisitExprInt32Literal(ExprInt32Literal exprInt32Literal, IExpr? parent)
        {
            if (exprInt32Literal.Value == null)
            {
                this.AppendNull();
                return true;
            }

            this.Builder.Append(exprInt32Literal.Value.Value);

            return true;
        }

19 View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000

public bool VisitExprDateTimeLiteral(ExprDateTimeLiteral dateTimeLiteral, IExpr? parent)
        {
            if (!dateTimeLiteral.Value.HasValue)
            {
                this.AppendNull();
            }
            else
            {
                this.Builder.Append('\'');
                if (dateTimeLiteral.Value.Value.TimeOfDay != TimeSpan.Zero)
                {
                    this.Builder.Append(dateTimeLiteral.Value.Value.ToString("yyyy-MM-ddTHH:mm:ss.fff"));
                }
                else
                {
                    this.Builder.Append(dateTimeLiteral.Value.Value.ToString("yyyy-MM-dd"));
                }
                this.Builder.Append('\'');
            }

            return true;
        }

19 View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000

public bool VisitExprInt64Literal(ExprInt64Literal int64Literal, IExpr? parent)
        {
            if (int64Literal.Value.HasValue)
            {
                this.Builder.Append(int64Literal.Value.Value);
            }
            else
            {
                this.AppendNull();
            }

            return true;
        }

19 View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000

public bool VisitExprByteLiteral(ExprByteLiteral byteLiteral, IExpr? parent)
        {
            if (byteLiteral.Value.HasValue)
            {
                this.Builder.Append(byteLiteral.Value.Value);
            }
            else
            {
                this.AppendNull();
            }

            return true;
        }

19 View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000

public bool VisitExprInt16Literal(ExprInt16Literal int16Literal, IExpr? parent)
        {
            if (int16Literal.Value.HasValue)
            {
                this.Builder.Append(int16Literal.Value.Value);
            }
            else
            {
                this.AppendNull();
            }

            return true;
        }

19 View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000

public bool VisitExprDecimalLiteral(ExprDecimalLiteral decimalLiteral, IExpr? parent)
        {
            if (decimalLiteral.Value.HasValue)
            {
                this.Builder.Append(decimalLiteral.Value.Value.ToString(CultureInfo.InvariantCulture));
            }
            else
            {
                this.AppendNull();
            }

            return true;
        }

19 View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000

public bool VisitExprDoubleLiteral(ExprDoubleLiteral doubleLiteral, IExpr? parent)
        {
            if (doubleLiteral.Value.HasValue)
            {
                this.Builder.Append(doubleLiteral.Value.Value.ToString(CultureInfo.InvariantCulture));
            }
            else
            {
                this.AppendNull();
            }

            return true;
        }

19 View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000

public bool VisitExprUnsafeValue(ExprUnsafeValue exprUnsafeValue, IExpr? parent)
        {
            this.Builder.Append(exprUnsafeValue.UnsafeValue);
            return true;
        }

19 View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000

public bool VisitExprFunctionName(ExprFunctionName exprFunctionName, IExpr? parent)
        {
            if (exprFunctionName.BuiltIn)
            {
                SqlInjectionChecker.replacedertValidBuildInFunctionName(exprFunctionName.Name);
                this.Builder.Append(exprFunctionName.Name);
            }
            else
            {
                this.AppendName(exprFunctionName.Name);
            }
            return true;
        }

19 View Source File : SqlStatementBuilderBase.cs
License : MIT License
Project Creator : 0x1000000

private string BuildFkName(IExprTableFullName tableIn, IExprTableFullName foreignTableIn)
        {
            StringBuilder nameBuilder = new StringBuilder();

            ExprTableFullName table = tableIn.AsExprTableFullName();

            ExprTableFullName foreignTable = foreignTableIn.AsExprTableFullName();

            var schemaName = table.DbSchema != null ? this.Options.MapSchema(table.DbSchema.Schema.Name) + "_" : null;

            nameBuilder.Append("FK_");
            if (schemaName != null)
            {
                nameBuilder.Append(schemaName);
                nameBuilder.Append('_');
            }
            nameBuilder.Append(table.TableName.Name);
            nameBuilder.Append("_to_");
            if (schemaName != null)
            {
                nameBuilder.Append(schemaName);
                nameBuilder.Append('_');
            }
            nameBuilder.Append(foreignTable.TableName.Name);

            return nameBuilder.ToString();
        }

19 View Source File : SyntaxTreeOperationsTest.cs
License : MIT License
Project Creator : 0x1000000

[Test]
        public void WalkThroughTest()
        {
            var tUser = Tables.User();
            var tCustomer = Tables.Customer();

            var e = Select(tUser.UserId, tUser.FirstName, tCustomer.CustomerId)
                .From(tUser)
                .InnerJoin(tCustomer, on: tCustomer.UserId == tUser.UserId)
                .Done();

            string expected = "0ExprQuerySpecification,1Int32TableColumn,2ExprTableAlias,3ExprAliasGuid," +
                              "2ExprColumnName,1StringTableColumn,2ExprTableAlias,3ExprAliasGuid," +
                              "2ExprColumnName,1Int32TableColumn,2ExprTableAlias,3ExprAliasGuid,2ExprColumnName," +
                              "1ExprJoinedTable,2User,3ExprTableFullName,4ExprDbSchema,5ExprSchemaName," +
                              "4ExprTableName,3ExprTableAlias,4ExprAliasGuid,2Customer,3ExprTableFullName," +
                              "4ExprDbSchema,5ExprSchemaName,4ExprTableName,3ExprTableAlias,4ExprAliasGuid," +
                              "2ExprBooleanEq,3NullableInt32TableColumn,4ExprTableAlias,5ExprAliasGuid," +
                              "4ExprColumnName,3Int32TableColumn,4ExprTableAlias,5ExprAliasGuid,4ExprColumnName,";

            StringBuilder builder = new StringBuilder();

            e.SyntaxTree().WalkThrough((expr, tier) =>
            {
                builder.Append(tier);
                builder.Append(expr.GetType().Name);
                builder.Append(',');
                return VisitorResult<int>.Continue(tier+1);
            }, 0);

            replacedert.AreEqual(expected, builder.ToString());
        }

19 View Source File : ICachingKeyGenerator.Default.cs
License : MIT License
Project Creator : 1100100

public string GenerateKeyPlaceholder(string keyPrefix, int globalExpire, string route, MethodInfo methodInfo, CachingAttribute cachingAttribute = default)
        {
            var sb = new StringBuilder();
            if (!string.IsNullOrWhiteSpace(keyPrefix))
                sb.AppendFormat("{0}{1}", keyPrefix, LinkString);
            if (cachingAttribute == null || string.IsNullOrWhiteSpace(cachingAttribute.Key))
            {
                sb.AppendFormat("{0}", route);
                if (methodInfo.GetParameters().Length > 0)
                    sb.Append(LinkString + "{0}");
            }
            else
                sb.Append(cachingAttribute.Key);

            return sb.ToString();
        }

19 View Source File : DbQuery.cs
License : Apache License 2.0
Project Creator : 1448376744

private string ResovleBatchInsert(IEnumerable<T> enreplacedys)
        {
            var table = GetTableMetaInfo().TableName;
            var filters = new GroupExpressionResovle(_filterExpression).Resovle().Split(',');
            var columns = GetColumnMetaInfos()
                .Where(a => !a.IsComplexType).ToList();
            var intcolumns = columns
                .Where(a => !filters.Contains(a.ColumnName) && !a.IsNotMapped && !a.IsIdenreplacedy)
                .ToList();
            var columnNames = string.Join(",", intcolumns.Select(s => s.ColumnName));
            if (_context.DbContextType == DbContextType.Mysql)
            {
                var buffer = new StringBuilder();
                buffer.Append($"INSERT INTO {table}({columnNames}) VALUES ");
                var serializer = GlobalSettings.EnreplacedyMapperProvider.GetDeserializer(typeof(T));
                var list = enreplacedys.ToList();
                for (var i = 0; i < list.Count; i++)
                {
                    var item = list[i];
                    var values = serializer(item);
                    buffer.Append("(");
                    for (var j = 0; j < intcolumns.Count; j++)
                    {
                        var column = intcolumns[j];
                        var value = values[column.CsharpName];
                        if (value == null)
                        {
                            buffer.Append(column.IsDefault ? "DEFAULT" : "NULL");
                        }
                        else if (column.CsharpType == typeof(bool) || column.CsharpType == typeof(bool?))
                        {
                            buffer.Append(Convert.ToBoolean(value) == true ? 1 : 0);
                        }
                        else if (column.CsharpType == typeof(DateTime) || column.CsharpType == typeof(DateTime?))
                        {
                            buffer.Append($"'{value}'");
                        }
                        else if (column.CsharpType.IsValueType || (Nullable.GetUnderlyingType(column.CsharpType)?.IsValueType == true))
                        {
                            buffer.Append(value);
                        }
                        else
                        {
                            var str = SqlEncoding(value.ToString());
                            buffer.Append($"'{str}'");
                        }
                        if (j + 1 < intcolumns.Count)
                        {
                            buffer.Append(",");
                        }
                    }
                    buffer.Append(")");
                    if (i + 1 < list.Count)
                    {
                        buffer.Append(",");
                    }
                }
                return buffer.Remove(buffer.Length - 1, 0).ToString();
            }
            throw new NotImplementedException();
        }

19 View Source File : DbQuery.cs
License : Apache License 2.0
Project Creator : 1448376744

private string ResolveOrder()
        {
            var buffer = new StringBuilder();
            foreach (var item in _orderExpressions)
            {
                if (item == _orderExpressions.First())
                {
                    buffer.Append($" ORDER BY ");
                }
                var result = new OrderExpressionResovle(item.Expression, item.Asc).Resovle();
                buffer.Append(result);
                buffer.Append(",");
            }
            return buffer.ToString().Trim(',');
        }

19 View Source File : ExpressionResolver.cs
License : MIT License
Project Creator : 17MKH

private static void ResolveMemberInit(QueryBody queryBody, Expression exp, LambdaExpression fullLambda, StringBuilder sqlBuilder, IQueryParameters parameters)
    {
        if (exp == null || !(exp is MemberInitExpression initExp) || !initExp.Bindings.Any())
            return;

        for (var i = 0; i < initExp.Bindings.Count; i++)
        {
            if (initExp.Bindings[i] is Memberreplacedignment replacedignment)
            {
                var descriptor = queryBody.Joins.First(m => m.EnreplacedyDescriptor.EnreplacedyType == initExp.Type);
                var col = descriptor.EnreplacedyDescriptor.Columns.FirstOrDefault(m => m.PropertyInfo.Name.Equals(replacedignment.Member.Name));
                if (col != null)
                {
                    if (queryBody.Joins.Count < 2)
                        sqlBuilder.Append(queryBody.DbAdapter.AppendQuote(col.Name));
                    else
                        sqlBuilder.Append($"{queryBody.DbAdapter.AppendQuote(descriptor.Alias)}.{queryBody.DbAdapter.AppendQuote(col.Name)}");

                    sqlBuilder.Append(" = ");

                    Resolve(queryBody, replacedignment.Expression, fullLambda, sqlBuilder, parameters);

                    if (i < initExp.Bindings.Count - 1)
                        sqlBuilder.Append(",");
                }
            }
        }
    }

19 View Source File : ExpressionResolver.cs
License : MIT License
Project Creator : 17MKH

private static void ResolveMethodForContains(QueryBody queryBody, MethodCallExpression exp, StringBuilder sqlBuilder, IQueryParameters parameters)
    {
        if (exp.Object is MemberExpression objExp)
        {
            #region ==字符串类型的Contains方法==

            if (objExp.Type.IsString())
            {
                sqlBuilder.Append(queryBody.GetColumnName(objExp));

                string value;
                if (exp.Arguments[0] is ConstantExpression c)
                {
                    value = c.Value!.ToString();
                }
                else
                {
                    value = ResolveDynamicInvoke(exp.Arguments[0]).ToString();
                }

                sqlBuilder.Append(" LIKE ");

                AppendValue(queryBody, $"%{value}%", sqlBuilder, parameters);
                return;
            }

            #endregion

            if (objExp.Type.IsGenericType)
            {
                var columnName = queryBody.GetColumnName(exp.Arguments[0]);
                ResolveInForGeneric(sqlBuilder, columnName, objExp, (exp.Arguments[0] as MemberExpression)!.Type);
            }

            return;
        }

        #region ==数组、泛型类型的Contains方法==

        if (exp.Arguments[1] is MemberExpression argExp1)
        {
            var columnName = queryBody.GetColumnName(argExp1);
            ResolveInForGeneric(sqlBuilder, columnName, exp.Arguments[0], argExp1.Type);
        }

        #endregion
    }

19 View Source File : ExpressionResolver.cs
License : MIT License
Project Creator : 17MKH

public static void AppendValue(QueryBody queryBody, object value, StringBuilder sqlBuilder, IQueryParameters parameters)
    {
        if (value == null)
        {
            var len = sqlBuilder.Length;
            if (sqlBuilder[len - 1] == ' ' && sqlBuilder[len - 2] == '>' && sqlBuilder[len - 3] == '<')
            {
                sqlBuilder.Remove(len - 3, 3);
                sqlBuilder.Append("IS NOT NULL");
                return;
            }

            if (sqlBuilder[len - 1] == ' ' && sqlBuilder[len - 2] == '=')
            {
                sqlBuilder.Remove(len - 2, 2);
                sqlBuilder.Append("IS NULL");
            }

            return;
        }

        var dbAdapter = queryBody.DbAdapter;
        if (queryBody.UseParameters)
        {
            //使用参数化
            var pName = parameters.Add(value);
            sqlBuilder.Append(dbAdapter.AppendParameter(pName));
        }
        else
        {
            var type = value.GetType();
            //不使用参数化
            if (type.IsNullable())
            {
                type = Nullable.GetUnderlyingType(type);
            }

            if (type!.IsEnum)
            {
                sqlBuilder.AppendFormat("{0}", value.ToInt());
            }
            else if (type.IsBool())
            {
                sqlBuilder.AppendFormat("{0}", value.ToBool() ? dbAdapter.BooleanTrueValue : dbAdapter.BooleanFalseValue);
            }
            else if (type.IsDateTime())
            {
                sqlBuilder.AppendFormat("'{0:yyyy-MM-dd HH:mm:ss}'", value);
            }
            else if (type.IsString() || type.IsGuid())
            {
                sqlBuilder.AppendFormat("'{0}'", value);
            }
            else
            {
                sqlBuilder.AppendFormat("{0}", value);
            }
        }
    }

19 View Source File : ExpressionResolver.cs
License : MIT License
Project Creator : 17MKH

private static void ResolveMember(QueryBody queryBody, MemberExpression exp, LambdaExpression fullLambda, StringBuilder sqlBuilder, IQueryParameters parameters)
    {
        if (exp.Expression != null)
        {
            switch (exp.Expression.NodeType)
            {
                case ExpressionType.Parameter:
                    sqlBuilder.Append(queryBody.GetColumnName(exp));
                    break;
                case ExpressionType.Constant:
                    var val = ResolveDynamicInvoke(exp);
                    AppendValue(queryBody, val, sqlBuilder, parameters);
                    break;
                case ExpressionType.MemberAccess:
                    if (exp.Expression is MemberExpression subMemberExp && subMemberExp.Expression!.NodeType == ExpressionType.Constant)
                    {
                        val = ResolveDynamicInvoke(exp);
                        AppendValue(queryBody, val, sqlBuilder, parameters);
                    }
                    else if (exp.Expression.Type.IsString())
                    {
                        var columnName = queryBody.GetColumnName(exp.Expression);
                        sqlBuilder.AppendFormat("{0}", queryBody.DbAdapter.FunctionMapper(exp.Member.Name, columnName));
                    }
                    else if (DbConstants.ENreplacedY_INTERFACE_TYPE.IsImplementType(exp.Expression.Type))
                    {
                        //多表连接解析列信息,如:m.T1.Id
                        var columnName = queryBody.GetColumnName(exp);
                        sqlBuilder.Append(columnName);
                    }
                    break;
            }

            //针对简写方式的布尔类型解析 m => m.Deleted
            if (exp == fullLambda.Body && exp.NodeType == ExpressionType.MemberAccess && exp.Type == typeof(bool))
            {
                sqlBuilder.Append(" = ");
                AppendValue(queryBody, queryBody.DbAdapter.BooleanTrueValue, sqlBuilder, parameters);
            }
        }
    }

19 View Source File : ExpressionResolver.cs
License : MIT License
Project Creator : 17MKH

private static void ResolveMethodForEndsWith(QueryBody queryBody, MethodCallExpression exp, StringBuilder sqlBuilder, IQueryParameters parameters)
    {
        if (exp.Object is MemberExpression objExp)
        {
            sqlBuilder.Append(queryBody.GetColumnName(objExp));

            string value;
            if (exp.Arguments[0] is ConstantExpression c)
            {
                value = c.Value!.ToString();
            }
            else
            {
                value = ResolveDynamicInvoke(exp.Arguments[0]).ToString();
            }

            sqlBuilder.Append(" LIKE ");

            AppendValue(queryBody, $"%{value}", sqlBuilder, parameters);
        }
    }

19 View Source File : QueryableSqlBuilder.cs
License : MIT License
Project Creator : 17MKH

public string BuildFunctionSql(IQueryParameters parameters)
    {

        var sqlBuilder = new StringBuilder();
        sqlBuilder.Append("SELECT ");

        Expression memberExp;
        if (_queryBody.Select.FunctionExpression.Body.NodeType == ExpressionType.Convert)
        {
            memberExp = (_queryBody.Select.FunctionExpression.Body as UnaryExpression)!.Operand;
        }
        else
        {
            memberExp = _queryBody.Select.FunctionExpression.Body;
        }

        var columnName = _queryBody.GetColumnName(memberExp);

        sqlBuilder.Append(_dbAdapter.FunctionMapper(_queryBody.Select.FunctionName, columnName));

        sqlBuilder.Append(" FROM ");
        ExpressionResolver.ResolveFrom(_queryBody, sqlBuilder, parameters);
        sqlBuilder.Append(" ");
        ExpressionResolver.ResolveWhere(_queryBody, sqlBuilder, parameters);

        return sqlBuilder.ToString();
    }

19 View Source File : QueryableSqlBuilder.cs
License : MIT License
Project Creator : 17MKH

public void ResolveSelect(StringBuilder sqlBuilder)
    {
        var select = _queryBody.Select;

        //先解析出要排除的列
        var excludeColumns = ResolveSelectExcludeColumns();

        if (select == null)
        {
            //解析所有实体
            ResolveSelectForEnreplacedy(sqlBuilder, 0, excludeColumns);
        }
        else if (select.Mode == QuerySelectMode.Sql)
        {
            //SQL语句
            sqlBuilder.Append(select.Sql);
        }
        else if (select.Mode == QuerySelectMode.Lambda)
        {
            //表达式
            var exp = select.Include.Body;
            switch (exp.NodeType)
            {
                //返回的整个实体
                case ExpressionType.Parameter:
                    ResolveSelectForEnreplacedy(sqlBuilder, 0, excludeColumns);
                    break;
                //返回的某个列
                case ExpressionType.MemberAccess:
                    ResolveSelectForMember(sqlBuilder, exp as MemberExpression, select.Include, excludeColumns);
                    if (sqlBuilder.Length > 0 && sqlBuilder[^1] == ',')
                    {
                        sqlBuilder.Remove(sqlBuilder.Length - 1, 1);
                    }
                    break;
                //自定义的返回对象
                case ExpressionType.New:
                    ResolveSelectForNew(sqlBuilder, exp as NewExpression, select.Include, excludeColumns);
                    break;
            }
        }

        //移除末尾的逗号
        if (sqlBuilder.Length > 0 && sqlBuilder[^1] == ',')
        {
            sqlBuilder.Remove(sqlBuilder.Length - 1, 1);
        }
    }

19 View Source File : ValidateResultFormatAttribute.cs
License : MIT License
Project Creator : 17MKH

public override void OnResultExecuting(ResultExecutingContext context)
    {
        if (!context.ModelState.IsValid)
        {
            try
            {
                var errors = context.ModelState
                    .Where(m => m.Value!.ValidationState == ModelValidationState.Invalid)
                    .Select(m =>
                    {
                        var sb = new StringBuilder();
                        sb.AppendFormat("{0}:", m.Key);
                        sb.Append(m.Value.Errors.Select(n => n.ErrorMessage).Aggregate((x, y) => x + ";" + y));
                        return sb.ToString();
                    })
                    .Aggregate((x, y) => x + "|" + y);

                context.Result = new JsonResult(ResultModel.Failed(errors));
            }
            catch
            {
                context.Result = new StatusCodeResult(StatusCodes.Status500InternalServerError);
            }
        }
    }

19 View Source File : MapSchemaStringBuilder.cs
License : MIT License
Project Creator : 1996v

public void AppendRouteToken(long position, BssMapRouteToken value)
        {
            sb.Append($"[{position.ToString()}]");
            sb.Append(value.ToString());
            sb.Append(" ");
        }

19 View Source File : ExpressionResolver.cs
License : MIT License
Project Creator : 17MKH

public static void ResolveFrom(QueryBody queryBody, StringBuilder sqlBuilder, IQueryParameters parameters)
    {
        var dbAdapter = queryBody.DbAdapter;
        var first = queryBody.Joins.First();

        if (queryBody.Joins.Count < 2)
        {
            sqlBuilder.AppendFormat("{0}", dbAdapter.AppendQuote(first.TableName));

            //附加SqlServer的NOLOCK特性
            if (dbAdapter.Provider == DbProvider.SqlServer && first.NoLock)
            {
                sqlBuilder.Append(" WITH (NOLOCK)");
            }

            return;
        }

        sqlBuilder.AppendFormat("{0} AS {1}", dbAdapter.AppendQuote(first.TableName), first.Alias);
        //附加NOLOCK特性
        if (dbAdapter.Provider == DbProvider.SqlServer && first.NoLock)
        {
            sqlBuilder.Append(" WITH (NOLOCK)");
        }

        for (var i = 1; i < queryBody.Joins.Count; i++)
        {
            var join = queryBody.Joins[i];
            switch (join.Type)
            {
                case JoinType.Inner:
                    sqlBuilder.Append(" INNER");
                    break;
                case JoinType.Right:
                    sqlBuilder.Append(" RIGHT");
                    break;
                default:
                    sqlBuilder.Append(" LEFT");
                    break;
            }

            sqlBuilder.AppendFormat(" JOIN {0} AS {1}", dbAdapter.AppendQuote(join.TableName), join.Alias);
            //附加SqlServer的NOLOCK特性
            if (dbAdapter.Provider == DbProvider.SqlServer && first.NoLock)
            {
                sqlBuilder.Append(" WITH (NOLOCK)");
            }

            sqlBuilder.Append(" ON ");
            sqlBuilder.Append(Resolve(queryBody, join.On, parameters));

            if (join.Type == JoinType.Inner)
            {
                //过滤软删除
                if (queryBody.FilterDeleted && join.EnreplacedyDescriptor.IsSoftDelete)
                {
                    sqlBuilder.AppendFormat(" AND {0}.{1} = {2}", join.Alias, dbAdapter.AppendQuote(join.EnreplacedyDescriptor.GetDeletedColumnName()), dbAdapter.BooleanFalseValue);
                }

                //添加租户过滤
                if (queryBody.FilterTenant && join.EnreplacedyDescriptor.IsTenant)
                {
                    var x1 = dbAdapter.AppendQuote(DbConstants.TENANT_COLUMN_NAME);
                    var tenantId = queryBody.Repository.DbContext.AccountResolver.TenantId;
                    if (tenantId == null)
                    {
                        sqlBuilder.AppendFormat(" AND {0}.{1} IS NULL", join.Alias, x1);
                    }
                    else
                    {
                        sqlBuilder.AppendFormat(" AND {0}.{1} = '{2}'", join.Alias, x1, tenantId);
                    }
                }
            }
        }
    }

19 View Source File : ExpressionResolver.cs
License : MIT License
Project Creator : 17MKH

private static void ResolveMethodForStartsWith(QueryBody queryBody, MethodCallExpression exp, StringBuilder sqlBuilder, IQueryParameters parameters)
    {
        if (exp.Object is MemberExpression objExp)
        {
            sqlBuilder.Append(queryBody.GetColumnName(objExp));

            string value;
            if (exp.Arguments[0] is ConstantExpression c)
            {
                value = c.Value!.ToString();
            }
            else
            {
                value = ResolveDynamicInvoke(exp.Arguments[0]).ToString();
            }

            sqlBuilder.Append(" LIKE ");

            AppendValue(queryBody, $"{value}%", sqlBuilder, parameters);
        }
    }

19 View Source File : Form1.cs
License : Apache License 2.0
Project Creator : 1694439208

private void button5_Click(object sender, EventArgs e)
        {
            byte[] jmp_inst =
            {
                233,0,0,0,0,//JMP Address
            };
            int Method = NativeAPI.GetMethodPTR(typeof(WeChetHook), "Callback");
            textBox3.Text = (3212659 + int.Parse(label1.Text)).ToString();

            List<byte> byteSource = new List<byte>();
            byteSource.AddRange(new byte[] { 199, 134, 236, 2, 0, 0 });//mov dword [esi+0x000002EC],
            byteSource.AddRange(BitConverter.GetBytes(int.Parse(textBox3.Text) + 5));//0x00000000  把hook的后五个字节地址压进寄存器
            byteSource.AddRange(jmp_inst);//让他跳到跳板函数
            //这部分根据实际情况填写
            byteSource.Add(185);//补充替换的汇编指令
            byteSource.AddRange(BitConverter.GetBytes(int.Parse(label1.Text) + 19255272));//补充替换的汇编指令地址
            //开始hook
            Inline_Hook.InlineHook(int.Parse(textBox3.Text),5, byteSource.ToArray(), getInt(Method),11+10,"接收消息",(obj) =>{
                StringBuilder sb = new StringBuilder();
                sb.Append("接收消息:");
                int a = 0x68;
                //System.Windows.Forms.MessageBox.Show("esp:"+a.ToString());
                try
                {
                    if (obj.ESP == 0)
                        return;
                    int MsgPtr = NativeAPI.ReadMemoryValue(obj.ESP);
                    if (MsgPtr == 0)
                        return;
                    MsgPtr = NativeAPI.ReadMemoryValue(MsgPtr);
                    if (MsgPtr == 0)
                        return;
                    MsgPtr = NativeAPI.ReadMemoryValue(MsgPtr + 0x68);
                    if (MsgPtr == 0)
                        return;
                    int len = NativeAPI.lstrlenW(MsgPtr);
                    if (len == 0)
                        return;
                    sb.Append(NativeAPI.ReadMemoryStrValue(MsgPtr, len*2+2));
                    sb.Append("\r\n");
                    listBox1.Items.Add(sb.ToString());
                }
                catch (Exception es)
                {
                    File.AppendAllText("error.txt", es.Message);
                }
            });
        }

19 View Source File : ExpressionResolver.cs
License : MIT License
Project Creator : 17MKH

private static void ResolveMethodForEquals(QueryBody queryBody, MethodCallExpression exp, LambdaExpression fullLambda, StringBuilder sqlBuilder, IQueryParameters parameters)
    {
        if (exp.Object is MemberExpression objExp)
        {
            sqlBuilder.Append(queryBody.GetColumnName(objExp));

            sqlBuilder.Append(" = ");

            var arg = exp.Arguments[0];
            switch (arg.NodeType)
            {
                case ExpressionType.Constant:
                    AppendValue(queryBody, (arg as ConstantExpression)!.Value!.ToString(), sqlBuilder, parameters);
                    break;
                case ExpressionType.MemberAccess:
                    ResolveMember(queryBody, arg as MemberExpression, fullLambda, sqlBuilder, parameters);
                    break;
                case ExpressionType.Convert:
                    Resolve(queryBody, (arg as UnaryExpression)!.Operand, fullLambda, sqlBuilder, parameters);
                    break;
                default:
                    AppendValue(queryBody, ResolveDynamicInvoke(arg).ToString(), sqlBuilder, parameters);
                    break;
            }
        }
    }

19 View Source File : GroupBySqlBuilder.cs
License : MIT License
Project Creator : 17MKH

public void ResolveSelect(StringBuilder sqlBuilder)
        {
            var select = _queryBody.Select;
            if (select == null)
                throw new ArgumentException("未指定查询信息");

            if (select.Mode == QuerySelectMode.Sql)
            {
                //SQL语句
                sqlBuilder.Append(select.Sql);
            }
            else if (select.Mode == QuerySelectMode.Lambda)
            {
                //表达式
                var exp = select.Include.Body;
                if (exp.NodeType != ExpressionType.New)
                {
                    throw new ArgumentException("分组查询的列,必须使用匿名对象的方式");
                }

                var newExp = exp as NewExpression;
                for (var i = 0; i < newExp.Arguments.Count; i++)
                {
                    var arg = newExp.Arguments[i];
                    var alias = newExp.Members![i].Name;
                    string columnName;

                    switch (arg.NodeType)
                    {
                        case ExpressionType.MemberAccess:
                            var memExp = arg as MemberExpression;
                            columnName = GetColumnName(memExp);
                            sqlBuilder.AppendFormat("{0} AS {1},", columnName, _dbAdapter.AppendQuote(alias));
                            break;
                        case ExpressionType.Call:
                            if (arg is MethodCallExpression callExp)
                            {
                                var methodName = callExp.Method.Name;
                                switch (callExp.Object!.NodeType)
                                {
                                    case ExpressionType.Parameter:
                                        if (callExp.Arguments.Count > 0)
                                        {
                                            //m => m.Sum(x => x.Id)
                                            var s = (callExp.Arguments[0] as UnaryExpression)!.Operand as LambdaExpression;
                                            var memberExp = s.Body as MemberExpression;
                                            columnName = _queryBody.GetColumnName(memberExp);
                                            sqlBuilder.AppendFormat("{0} AS {1},", _dbAdapter.FunctionMapper(callExp.Method.Name, columnName, callExp.Object!.Type), _dbAdapter.AppendQuote(alias));
                                        }
                                        else
                                        {
                                            sqlBuilder.AppendFormat("{0} AS {1},", _dbAdapter.FunctionMapper(methodName, null), _dbAdapter.AppendQuote(alias));
                                        }
                                        break;
                                    case ExpressionType.MemberAccess:
                                        //m => m.Key.replacedle.Substring(3)
                                        columnName = GetColumnName(callExp!.Object as MemberExpression);
                                        var args = ExpressionResolver.Arguments2Object(callExp.Arguments);
                                        sqlBuilder.AppendFormat("{0} AS {1},", _dbAdapter.FunctionMapper(methodName, columnName, callExp.Object.Type, args), _dbAdapter.AppendQuote(alias));
                                        break;
                                    default:
                                        sqlBuilder.AppendFormat("{0} AS {1},", _dbAdapter.FunctionMapper(methodName, null), _dbAdapter.AppendQuote(alias));
                                        break;
                                }
                            }
                            break;
                    }

19 View Source File : GroupBySqlBuilder.cs
License : MIT License
Project Creator : 17MKH

private void ResolveHaving(StringBuilder sqlBuilder, IQueryParameters parameters)
        {
            if (_queryBody.Havings.NotNullAndEmpty())
            {
                sqlBuilder.Append(" HAVING");
                foreach (var having in _queryBody.Havings)
                {
                    if (having.Mode == QueryHavingMode.Sql)
                    {
                        sqlBuilder.Append(having.Sql);
                    }
                    else
                    {
                        ExpressionResolver.Resolve(_queryBody, having.Lambda.Body, having.Lambda, sqlBuilder, parameters);
                    }
                }
            }
        }

19 View Source File : QueryableSqlBuilder.cs
License : MIT License
Project Creator : 17MKH

public string BuildUpdateSql(IQueryParameters parameters)
    {
        var tableName = _queryBody.Joins.First().TableName;
        Check.NotNull(tableName, nameof(tableName), "未指定更新表");

        var sqlBuilder = new StringBuilder();

        //更新语句优先
        var updateSql = _queryBody.Update.Sql.NotNull() ? _queryBody.Update.Sql : ExpressionResolver.Resolve(_queryBody, _queryBody.Update.Lambda, parameters);
        Check.NotNull(updateSql, nameof(updateSql), "生成更新sql异常");

        sqlBuilder.AppendFormat("UPDATE {0} SET ", _dbAdapter.AppendQuote(tableName));
        sqlBuilder.Append(updateSql);

        SetUpdateInfo(sqlBuilder, parameters);

        var whereSql = ExpressionResolver.ResolveWhere(_queryBody, parameters);
        Check.NotNull(whereSql, nameof(whereSql), "批量更新必须指定条件,防止人为失误误操作");
        sqlBuilder.AppendFormat(" {0};", whereSql);

        return sqlBuilder.ToString();
    }

19 View Source File : MapSchemaStringBuilder.cs
License : MIT License
Project Creator : 1996v

public void AppendUInt64Val(long position, ref byte refb, int len)
        {
            sb.Append("KeyBytes(");
            for (int i = 0; i < len; i++)
            {
                sb.Append(Unsafe.Add(ref refb, i).ToString());
                if (i != len - 1)
                {
                    sb.Append(",");
                }
            }
            sb.Append(")");
            sb.Append(" ");
        }

19 View Source File : MapSchemaStringBuilder.cs
License : MIT License
Project Creator : 1996v

public void AppendKeyType(long position, bool isNativeType, byte typeCode)
        {
            if (isNativeType && typeCode == NativeBssomType.DateTimeCode)
            {
                sb.Append("KeyType(NativeDateTimeCode)");
            }
            else
            {
                sb.Append("KeyType(" + BssomType.GetTypeName(isNativeType, typeCode) + ")");
            }
            sb.Append(" ");
        }

19 View Source File : G_AdvancedData.cs
License : MIT License
Project Creator : 1ZouLTReX1

private void Update()
        {
            m_deltaTime += Time.unscaledDeltaTime;

            if (m_deltaTime > 1f / m_updateRate)
            {
                // Update screen window resolution
                m_sb.Length = 0;

                m_sb.Append(m_windowStrings[0]).Append(Screen.width.ToStringNonAlloc())
                    .Append(m_windowStrings[1]).Append(Screen.height.ToStringNonAlloc())
                    .Append(m_windowStrings[2]).Append(Screen.currentResolution.refreshRate.ToStringNonAlloc())
                    .Append(m_windowStrings[3])
                    .Append(m_windowStrings[4]).Append(Screen.dpi.ToStringNonAlloc())
                    .Append(m_windowStrings[5]);

                m_gameWindowResolutionText.text = m_sb.ToString();

                // Reset variables
                m_deltaTime = 0f;
            }
        }

19 View Source File : RedisWriter.cs
License : MIT License
Project Creator : 2881099

public byte[] Prepare(RedisCommand command)
        {
            var parts = command.Command.Split(' ');
            int length = parts.Length + command.Arguments.Length;
            StringBuilder sb = new StringBuilder();
            sb.Append(MultiBulk).Append(length).Append(EOL);

            foreach (var part in parts)
                sb.Append(Bulk).Append(_io.Encoding.GetByteCount(part)).Append(EOL).Append(part).Append(EOL);

            MemoryStream ms = new MemoryStream();
            var data = _io.Encoding.GetBytes(sb.ToString());
            ms.Write(data, 0, data.Length);

            foreach (var arg in command.Arguments)
            {
                if (arg != null && arg.GetType() == typeof(byte[]))
                {
                    data = arg as byte[];
                    var data2 = _io.Encoding.GetBytes($"{Bulk}{data.Length}{EOL}");
                    ms.Write(data2, 0, data2.Length);
                    ms.Write(data, 0, data.Length);
                    ms.Write(new byte[] { 13, 10 }, 0, 2);
                }
                else
                {
                    string str = String.Format(CultureInfo.InvariantCulture, "{0}", arg);
                    data = _io.Encoding.GetBytes($"{Bulk}{_io.Encoding.GetByteCount(str)}{EOL}{str}{EOL}");
                    ms.Write(data, 0, data.Length);
                }
                //string str = String.Format(CultureInfo.InvariantCulture, "{0}", arg);
                //sb.Append(Bulk).Append(_io.Encoding.GetByteCount(str)).Append(EOL).Append(str).Append(EOL);
            }

            return ms.ToArray();
        }

19 View Source File : CommandPacket.cs
License : MIT License
Project Creator : 2881099

public override string ToString()
        {
            var sb = new StringBuilder();
            for (var b = 0; b < _input.Count; b++)
            {
                if (b > 0) sb.Append(" ");
                var tmpstr = _input[b].ToInvariantCultureToString().Replace("\r\n", "\\r\\n");
                if (tmpstr.Length > 96) tmpstr = $"{tmpstr.Substring(0, 96).Trim()}..";
                sb.Append(tmpstr);
            }
            return sb.ToString();
        }

19 View Source File : PipelineAdapter.cs
License : MIT License
Project Creator : 2881099

static void EndPipe(IRedisSocket rds, IEnumerable<PipelineCommand> cmds)
            {
                var err = new List<PipelineCommand>();
                var ms = new MemoryStream();

                try
                {
                    var respWriter = new RespHelper.Resp3Writer(ms, rds.Encoding, rds.Protocol);
                    foreach (var cmd in cmds)
                        respWriter.WriteCommand(cmd.Command);

                    if (rds.IsConnected == false) rds.Connect();
                    ms.Position = 0;
                    ms.CopyTo(rds.Stream);

                    foreach (var pc in cmds)
                    {
                        pc.RedisResult = rds.Read(pc.Command);
                        pc.Result = pc.Parse(pc.RedisResult);
                        if (pc.RedisResult.IsError) err.Add(pc);
#if isasync
                        pc.TrySetResult(pc.Result, pc.RedisResult.IsError ? new RedisServerException(pc.RedisResult.SimpleError) : null);
#endif
                    }
                }
                finally
                {
                    ms.Close();
                    ms.Dispose();
                }

                if (err.Any())
                {
                    var sb = new StringBuilder();
                    for (var a = 0; a < err.Count; a++)
                    {
                        var cmd = err[a].Command;
                        if (a > 0) sb.Append("\r\n");
                        sb.Append(err[a].RedisResult.SimpleError).Append(" {").Append(cmd.ToString()).Append("}");
                    }
                    throw new RedisServerException(sb.ToString());
                }
            }

19 View Source File : ConnectionStringBuilder.cs
License : MIT License
Project Creator : 2881099

public override string ToString()
        {
            var sb = new StringBuilder();
            sb.Append(string.IsNullOrWhiteSpace(Host) ? "127.0.0.1:6379" : Host);
            if (Ssl) sb.Append(",ssl=true");
            if (Protocol == RedisProtocol.RESP3) sb.Append(",protocol=").Append(Protocol);
            if (!string.IsNullOrWhiteSpace(User)) sb.Append(",user=").Append(User);
            if (!string.IsNullOrEmpty(Preplacedword)) sb.Append(",preplacedword=").Append(Preplacedword);
            if (Database > 0) sb.Append(",database=").Append(Database);

            if (!string.IsNullOrWhiteSpace(Prefix)) sb.Append(",prefix=").Append(Prefix);
            if (!string.IsNullOrWhiteSpace(ClientName)) sb.Append(",client name=").Append(ClientName);
            if (Encoding != Encoding.UTF8) sb.Append(",encoding=").Append(Encoding.BodyName);

            if (IdleTimeout != TimeSpan.FromSeconds(20)) sb.Append(",idle timeout=").Append((long)IdleTimeout.TotalMilliseconds);
            if (ConnectTimeout != TimeSpan.FromSeconds(10)) sb.Append(",connect timeout=").Append((long)ConnectTimeout.TotalMilliseconds);
            if (ReceiveTimeout != TimeSpan.FromSeconds(10)) sb.Append(",receive timeout=").Append((long)ReceiveTimeout.TotalMilliseconds);
            if (SendTimeout != TimeSpan.FromSeconds(10)) sb.Append(",send timeout=").Append((long)SendTimeout.TotalMilliseconds);
            if (MaxPoolSize != 100) sb.Append(",max pool size=").Append(MaxPoolSize);
            if (MinPoolSize != 1) sb.Append(",min pool size=").Append(MinPoolSize);
            if (Retry != 0) sb.Append(",retry=").Append(Retry);
            return sb.ToString();
        }

19 View Source File : RedisClientEvents.cs
License : MIT License
Project Creator : 2881099

public void After(InterceptorAfterEventArgs args)
        {
            string log;
            if (args.Exception != null) log = $"{args.Exception.Message}";
            else if (args.Value is Array array)
            {
                var sb = new StringBuilder().Append("[");
                var itemindex = 0;
                foreach (var item in array)
                {
                    if (itemindex++ > 0) sb.Append(", ");
                    sb.Append(item.ToInvariantCultureToString());
                }
                log = sb.Append("]").ToString();
                sb.Clear();
            }
            else
                log = $"{args.Value.ToInvariantCultureToString()}";
            _cli.OnNotice(null, new NoticeEventArgs(
                NoticeType.Call,
                args.Exception,
                $"{(args.Command.WriteTarget ?? "Not connected").PadRight(21)} > {args.Command}\r\n{log}\r\n({args.ElapsedMilliseconds}ms)\r\n",
                args.Value));
        }

19 View Source File : StringFuzzer.cs
License : Apache License 2.0
Project Creator : 42skillz

public string GenerateStringFromPattern(string diverseFormat)
        {
            var builder = new StringBuilder(diverseFormat.Length);
            foreach (var c in diverseFormat.ToCharArray())
            {
                switch (c)
                {
                    case '#':
                        builder.Append(_fuzzer.GenerateInteger(0,9));
                        break;

                    case 'X': builder.Append(_fuzzer.GenerateLetter().ToString().ToUpper());
                        break;

                    case 'x': builder.Append(_fuzzer.GenerateLetter());
                        break;

                    default: builder.Append(c);
                        break;
                }
            }

            return builder.ToString();
        }

19 View Source File : Foto.cs
License : MIT License
Project Creator : 6tail

public string toFullString()
        {
            StringBuilder s = new StringBuilder();
            s.Append(toString());
            foreach (FotoFestival f in getFestivals())
            {
                s.Append(" (");
                s.Append(f);
                s.Append(")");
            }
            return s.ToString();
        }

19 View Source File : Foto.cs
License : MIT License
Project Creator : 6tail

public string getYearInChinese()
        {
            char[] y = (getYear() + "").ToCharArray();
            StringBuilder s = new StringBuilder();
            for (int i = 0, j = y.Length; i < j; i++)
            {
                s.Append(LunarUtil.NUMBER[y[i] - '0']);
            }
            return s.ToString();
        }

19 View Source File : Visitor.Expressions.cs
License : MIT License
Project Creator : 71

public override Expression VisitInterpolatedStringExpression(InterpolatedStringExpressionSyntax node)
    {
        StringBuilder template = new StringBuilder();
        Sequence<Expression> parameters = new Sequence<Expression>();

        foreach (var content in node.Contents)
        {
            if (content is InterpolatedStringTextSyntax text)
            {
                template.Append(text.TextToken.ValueText);
            }
            else if (content is InterpolationSyntax interpolation)
            {
                template.Append('{');
                template.Append(parameters.Count);
                template.Append('}');

                parameters.Add(interpolation.Expression.Accept(this));
            }
            else
            {
                throw new NotSupportedException();
            }
        }

        return Expression.Call(
            typeof(string).GetRuntimeMethod(nameof(string.Format), new[] { typeof(string), typeof(object[]) }),
            Expression.Constant(template.ToString()),
            Expression.NewArrayInit(typeof(object), parameters.ToArray())
        );
    }

19 View Source File : PlantumlStructure.cs
License : MIT License
Project Creator : 8T4

private static string ToPumlString(this DeploymentNode deployment, int concat = 0)
        {
            var stream = new StringBuilder();
            var spaces = SpaceMethods.Indent(concat);

            if (concat == 0)
            {
                stream.AppendLine();
            }

            if (deployment.Properties != null)
            {
                foreach (var (key, value) in deployment.Properties)
                {
                    stream.AppendLine($"{spaces}AddProperty(\"{key}\", \"{value}\")");
                }
            }

            stream.AppendLine(deployment.Tags is null
                ? $"{spaces}Deployment_Node({deployment.Alias}, \"{deployment.Label}\", \"{deployment.Description}\") {{"
                : $"{spaces}Deployment_Node({deployment.Alias}, \"{deployment.Label}\", \"{deployment.Description}\", $tags=\"{string.Join(',', deployment.Tags)}\") {{");

            if (deployment.Nodes != null)
            {
                foreach (var node in deployment.Nodes)
                {
                    stream.AppendLine($"{node.ToPumlString(concat + SpaceMethods.TabSize)}");
                }
            }

            if (deployment.Container != null)
            {
                stream.AppendLine(SpaceMethods.Indent(concat) + deployment.Container.ToPumlString());
            }

            stream.Append(spaces + "}");

            return stream.ToString();
        }

19 View Source File : ReaderCache.cs
License : Apache License 2.0
Project Creator : aadreja

public override string ToString()
        { 
            // to be used in the debugger
            if (names != null)
            {
                return string.Join(", ", names);
            }
            if (reader != null)
            {
                var sb = new StringBuilder();
                int index = 0;
                for (int i = 0; i < length; i++)
                {
                    if (i != 0) sb.Append(", ");
                    sb.Append(reader.GetName(index++));
                }
                return sb.ToString();
            }
            return base.ToString();
        }

See More Examples