System.Text.StringBuilder.Append(string)

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

30015 Examples 7

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

public bool VisitExprOutputColumnDeleted(ExprOutputColumnDeleted exprOutputColumnDeleted, IExpr? parent)
        {
            this.Builder.Append("DELETED.");
            exprOutputColumnDeleted.ColumnName.Accept(this, exprOutputColumnDeleted);
            return true;
        }

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

public bool VisitExprCase(ExprCase exprCase, IExpr? parent)
        {
            this.replacedertNotEmptyList(exprCase.Cases, "Cases cannot be empty");

            this.Builder.Append("CASE");
            for (int i = 0; i < exprCase.Cases.Count; i++)
            {
                this.Builder.Append(' ');
                exprCase.Cases[i].Accept(this, exprCase);
            }
            this.Builder.Append(" ELSE ");
            exprCase.DefaultValue.Accept(this, exprCase);
            this.Builder.Append(" END");
            return true;
        }

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

public bool VisitExprInSubQuery(ExprInSubQuery exprInSubQuery, IExpr? parent)
        {
            exprInSubQuery.TestExpression.Accept(this, exprInSubQuery);
            this.Builder.Append(" IN");
            this.AcceptPar('(', exprInSubQuery.SubQuery, ')', exprInSubQuery);
            return true;
        }

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

public bool VisitExprSelectOffsetFetch(ExprSelectOffsetFetch exprSelectOffsetFetch, IExpr? parent)
        {
            exprSelectOffsetFetch.SelectQuery.Accept(this, exprSelectOffsetFetch);
            this.Builder.Append(" ORDER BY ");
            exprSelectOffsetFetch.OrderBy.Accept(this, exprSelectOffsetFetch);
            return true;
        }

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

public bool VisitExprLike(ExprLike exprLike, IExpr? parent)
        {
            exprLike.Test.Accept(this, exprLike);
            this.Builder.Append(" LIKE ");
            exprLike.Pattern.Accept(this, exprLike);
            return true;
        }

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

public bool VisitExprBooleanNot(ExprBooleanNot expr, IExpr? parent)
        {
            this.Builder.Append("NOT");
            if (expr.Expr is ExprPredicate)
            {
                this.Builder.Append(' ');
                expr.Expr.Accept(this, expr);
            }
            else
            {
                this.AcceptPar('(', expr.Expr, ')', expr);
            }

            return true;
        }

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

public bool VisitExprFrameClause(ExprFrameClause exprFrameClause, IExpr? arg)
        {
            this.Builder.Append("ROWS ");
            
            if (exprFrameClause.End != null)
            {
                this.Builder.Append("BETWEEN ");
                exprFrameClause.Start.Accept(this, exprFrameClause);
                this.Builder.Append(" AND ");
                exprFrameClause.End.Accept(this, exprFrameClause);
            }
            else
            {
                exprFrameClause.Start.Accept(this, exprFrameClause);
            }

            return true;
        }

19 View Source File : MainActivity.cs
License : Microsoft Public License
Project Creator : 0x0ade

public static void SDL_Main()
		{
			if (string.IsNullOrEmpty(Instance.GamePath))
			{
				AlertDialog dialog = null;
				Instance.RunOnUiThread(() =>
				{
					using (AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(Instance))
					{
						StringBuilder stringBuilder = new StringBuilder();
						stringBuilder.Append("Game not found: ").AppendLine(Game);
						foreach (Java.IO.File root in Instance.GetExternalFilesDirs(null))
						{
							stringBuilder.AppendLine();
							stringBuilder.AppendLine(Path.Combine(root.AbsolutePath, Game));
						}

						dialogBuilder.SetMessage(stringBuilder.ToString());
						dialogBuilder.SetCancelable(false);
						dialog = dialogBuilder.Show();
					}
				});

				while (dialog == null || dialog.IsShowing)
				{
					System.Threading.Thread.Sleep(0);
				}
				dialog.Dispose();
				return;
			}

			// Replace the following with whatever was in your Program.Main method.

			/*/
			using (TestGame game = new TestGame())
			{
				game.Run();
			}
			/*/
			replacedembly.LoadFrom(Instance.GamePath).EntryPoint.Invoke(null, new object[] { new string[] { /*args*/ } });
			/**/
		}

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

public bool VisitExprTableValueConstructor(ExprTableValueConstructor tableValueConstructor, IExpr? parent)
        {
            this.Builder.Append("VALUES ");

            for (var i = 0; i < tableValueConstructor.Items.Count; i++)
            {
                var rowValue = tableValueConstructor.Items[i];

                if (i>0)
                {
                    this.Builder.Append(',');
                }

                rowValue.Accept(this, tableValueConstructor);
            }

            return true;
        }

19 View Source File : Message.cs
License : zlib License
Project Creator : 0x0ade

public static StringBuilder Parenthesize(this StringBuilder builder, string input)
            => !string.IsNullOrEmpty(input) ? builder.Append(" (").Append(input).Append(")") : builder;

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

public bool VisitExprQueryExpression(ExprQueryExpression exprQueryExpression, IExpr? parent)
        {
            if (ForceParenthesesForQueryExpressionPart(exprQueryExpression.Left))
            {
                this.AcceptPar('(', exprQueryExpression.Left, ')', exprQueryExpression);
            }
            else
            {
                exprQueryExpression.Left.Accept(this, exprQueryExpression);
            }

            switch (exprQueryExpression.QueryExpressionType)
            {
                case ExprQueryExpressionType.UnionAll:
                    this.Builder.Append(" UNION ALL ");
                    break;
                case ExprQueryExpressionType.Union:
                    this.Builder.Append(" UNION ");
                    break;
                case ExprQueryExpressionType.Except:
                    this.Builder.Append(" EXCEPT ");
                    break;
                case ExprQueryExpressionType.Intersect:
                    this.Builder.Append(" INTERSECT ");
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            if (exprQueryExpression.Right is ExprQueryExpression || ForceParenthesesForQueryExpressionPart(exprQueryExpression.Right))
            {
                this.AcceptPar('(', exprQueryExpression.Right, ')', exprQueryExpression);
            }
            else
            {
                exprQueryExpression.Right.Accept(this, exprQueryExpression);
            }

            return true;
        }

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

public bool VisitExprDefault(ExprDefault exprDefault, IExpr? parent)
        {
            this.Builder.Append("DEFAULT");
            return true;
        }

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

public bool VisitExprBooleanAnd(ExprBooleanAnd expr, IExpr? parent)
        {
            if (expr.Left is ExprBooleanOr)
            {
                this.AcceptPar('(', expr.Left, ')', expr);
                this.Builder.Append("AND");
            }
            else
            {
                expr.Left.Accept(this, expr);
                this.Builder.Append(" AND");
            }

            if (expr.Right is ExprBooleanOr)
            {
                this.AcceptPar('(', expr.Right, ')', expr);
            }
            else
            {
                this.Builder.Append(' ');
                expr.Right.Accept(this, expr);
            }

            return true;
        }

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

protected bool VisitExprOffsetFetchCommon(ExprOffsetFetch exprOffsetFetch, IExpr? parent)
        {
            this.Builder.Append(" OFFSET ");
            exprOffsetFetch.Offset.Accept(this, exprOffsetFetch);
            this.Builder.Append(" ROW");

            if (!ReferenceEquals(exprOffsetFetch.Fetch,null))
            {
                this.Builder.Append(" FETCH NEXT ");
                exprOffsetFetch.Fetch.Accept(this, exprOffsetFetch);
                this.Builder.Append(" ROW ONLY");
            }

            return true;
        }

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

public static void WriteHTMLStart(HttpListenerContext c, StringBuilder builder) {
            builder.Append(
@"<!DOCTYPE html>
<html>
    <head>
        <meta charset=""utf-8"" />
        <meta name=""viewport"" content=""width=device-width, initial-scale=1, user-scalable=no"" />
        <replacedle>CelesteNet ClientRC</replacedle>
        <style>
@font-face {
    font-family: Renogare;
    src:
    url(""https://everestapi.github.io/fonts/Renogare-Regular.woff"") format(""woff""),
    url(""https://everestapi.github.io/fonts/Renogare-Regular.otf"") format(""opentype"");
}
body {
    color: rgba(0, 0, 0, 0.87);
    font-family: sans-serif;
    padding: 0;
    margin: 0;
    line-height: 1.5em;
}
header {
    background: #3b2d4a;
    color: white;
    font-family: Renogare, sans-serif;
    font-size: 32px;
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    line-height: 64px;
    padding: 8px 48px;
    z-index: 100;
}
#main {
    position: relative;
    margin: 8px;
    min-height: 100vh;
}
#endpoints li h3 {
    margin-bottom: 0;
}
#endpoints li p {
    margin-top: 0;
}
        </style>
    </head>
    <body>
"
            );

            builder.AppendLine(@"<header>CelesteNet ClientRC</header>");
            builder.AppendLine(@"<div id=""main"">");
        }

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

public bool VisitExprAggregateFunction(ExprAggregateFunction exprAggregateFunction, IExpr? parent)
        {
            exprAggregateFunction.Name.Accept(this, exprAggregateFunction);
            this.Builder.Append('(');
            if (exprAggregateFunction.IsDistinct)
            {
                this.Builder.Append("DISTINCT ");
            }

            exprAggregateFunction.Expression.Accept(this, exprAggregateFunction);
            this.Builder.Append(')');

            return true;
        }

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

public bool VisitExprBooleanGtEq(ExprBooleanGtEq booleanGtEq, IExpr? parent)
        {
            booleanGtEq.Left.Accept(this, booleanGtEq);
            this.Builder.Append(">=");
            booleanGtEq.Right.Accept(this, booleanGtEq);

            return true;
        }

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

public bool VisitExprCurrentRowFrameBorder(ExprCurrentRowFrameBorder exprCurrentRowFrameBorder, IExpr? arg)
        {
            this.Builder.Append("CURRENT ROW");
            return true;
        }

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 : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000

public bool VisitExprFuncCoalesce(ExprFuncCoalesce exprFuncCoalesce, IExpr? parent)
        {
            this.Builder.Append("COALESCE(");
            exprFuncCoalesce.Test.Accept(this, exprFuncCoalesce);
            this.Builder.Append(',');
            this.replacedertNotEmptyList(exprFuncCoalesce.Alts, "Alt argument list cannot be empty in 'COALESCE' function call");
            this.AcceptListComaSeparated(exprFuncCoalesce.Alts, exprFuncCoalesce);
            this.Builder.Append(')');
            return true;
        }

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

public bool VisitExprExists(ExprExists exprExists, IExpr? parent)
        {
            this.Builder.Append("EXISTS");
            this.AcceptPar('(', exprExists.SubQuery, ')', exprExists);
            return true;
        }

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

public bool VisitExprIsNull(ExprIsNull exprIsNull, IExpr? parent)
        {
            exprIsNull.Test.Accept(this, exprIsNull);
            this.Builder.Append(" IS");
            if (exprIsNull.Not)
            {
                this.Builder.Append(" NOT");
            }
            this.Builder.Append(" NULL");
            return true;
        }

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 : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000

public bool VisitExprNull(ExprNull exprNull, IExpr? parent)
        {
            this.Builder.Append("NULL");
            return true;
        }

19 View Source File : Message.cs
License : zlib License
Project Creator : 0x0ade

public static string ToString(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam, IntPtr result) {
            StringBuilder builder = new StringBuilder();
            builder
                .Append("msg=0x").Append(Convert.ToString(msg, 16)).Parenthesize(MsgToString(msg))
                .Append(" hwnd=0x").Append(Convert.ToString((long) hWnd, 16))
                .Append(" wparam=0x").Append(Convert.ToString((long) wparam, 16))
                .Append(" lparam=0x").Append(Convert.ToString((long) lparam, 16))
                .Parenthesize(msg == (int) Messages.WM_PARENTNOTIFY ? MsgToString((int) wparam & 0x0000FFFF) : null)
                .Append(" result=0x").Append(Convert.ToString((long) result, 16));
            return builder.ToString();
        }

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

public bool VisitExprCrossedTable(ExprCrossedTable exprCrossedTable, IExpr? parent)
        {
            exprCrossedTable.Left.Accept(this, exprCrossedTable);
            this.Builder.Append(" CROSS JOIN ");
            exprCrossedTable.Right.Accept(this, exprCrossedTable);
            return true;
        }

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

public bool VisitExprQuerySpecification(ExprQuerySpecification exprQuerySpecification, IExpr? parent)
        {
            this.Builder.Append("SELECT ");
            if (exprQuerySpecification.Distinct)
            {
                this.Builder.Append("DISTINCT ");
            }
            if (!ReferenceEquals(exprQuerySpecification.Top, null))
            {
                this.AppendSelectTop(exprQuerySpecification.Top, exprQuerySpecification);
            }

            this.AcceptListComaSeparated(exprQuerySpecification.SelectList, exprQuerySpecification);

            if (exprQuerySpecification.From != null)
            {
                this.Builder.Append(" FROM ");
                exprQuerySpecification.From.Accept(this, exprQuerySpecification);
            }

            if (exprQuerySpecification.Where != null)
            {
                this.Builder.Append(" WHERE ");
                exprQuerySpecification.Where.Accept(this, exprQuerySpecification);
            }

            if (exprQuerySpecification.GroupBy != null)
            {
                this.Builder.Append(" GROUP BY ");
                this.AcceptListComaSeparated(exprQuerySpecification.GroupBy, exprQuerySpecification);
            }

            if (!ReferenceEquals(exprQuerySpecification.Top, null) && !(parent is ExprSelect) && !(parent is ExprSelectOffsetFetch))
            {
                //For non T-SQL (PostgresSQL, My SQL)
                this.AppendSelectLimit(exprQuerySpecification.Top, exprQuerySpecification);
            }

            return true;
        }

19 View Source File : FileSystemHelper.cs
License : zlib License
Project Creator : 0x0ade

public static string ChangePath(string path, char separator) {
            // Can't trust File.Exists if MONO_IOMAP_ALL is set.
            if (!MONO_IOMAP_ALL) {
                string pathMaybe = path;
                // Check if target exists in the first place.
                if (Directory.Exists(path) || File.Exists(path))
                    return pathMaybe;

                // Try a simpler fix first: Maybe the casing is already correct...
                pathMaybe = path.Replace('/', separator).Replace('\\', separator);
                if (Directory.Exists(pathMaybe) || File.Exists(pathMaybe))
                    return pathMaybe;

                // Fall back to the slow rebuild.
            }

            // Check if the path has been rebuilt before.
            Dictionary<string, string> cachedPaths;
            if (!_CachedChanges.TryGetValue(separator, out cachedPaths))
                _CachedChanges[separator] = cachedPaths = new Dictionary<string, string>();
            string cachedPath;
            if (cachedPaths.TryGetValue(path, out cachedPath))
                return cachedPath;

            // Split and rebuild path.

            string[] pathSplit = path.Split(DirectorySeparatorChars);

            StringBuilder builder = new StringBuilder();

            bool unixRooted = false;

            if (Path.IsPathRooted(path)) {
                // The first element in a rooted path will always be correct.
                // On Windows, this will be the drive letter.
                // On Unix and Unix-like systems, this will be empty.
                if (unixRooted = (builder.Length == 0))
                    // Path is rooted, but the path separator is the root.
                    builder.Append(separator);
                else
                    builder.Append(pathSplit[0]);
            }

            for (int i = 1; i < pathSplit.Length; i++) {
                string next;
                if (i < pathSplit.Length - 1)
                    next = GetDirectory(builder.ToString(), pathSplit[i]);
                else
                    next = GetTarget(builder.ToString(), pathSplit[i]);
                next = next ?? pathSplit[i];

                if (i != 1 || !unixRooted)
                    builder.Append(separator);

                builder.Append(next);
            }

            return cachedPaths[path] = builder.ToString();
        }

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

public bool VisitExprSelect(ExprSelect exprSelect, IExpr? parent)
        {
            exprSelect.SelectQuery.Accept(this, exprSelect);
            this.Builder.Append(" ORDER BY ");
            exprSelect.OrderBy.Accept(this, exprSelect);

            if (exprSelect.SelectQuery is ExprQuerySpecification specification)
            {
                if (!ReferenceEquals(specification.Top, null))
                {
                    this.AppendSelectLimit(specification.Top, exprSelect);
                }
            }

            return true;
        }

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 : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000

public bool VisitExprOrderByItem(ExprOrderByItem exprOrderByItem, IExpr? parent)
        {
            exprOrderByItem.Value.Accept(this, exprOrderByItem);
            if (exprOrderByItem.Descendant)
            {
                this.Builder.Append(" DESC");
            }
            return true;
        }

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

public bool VisitExprBooleanOr(ExprBooleanOr expr, IExpr? parent)
        {
            expr.Left.Accept(this, expr);
            this.Builder.Append(" OR ");
            expr.Right.Accept(this, expr);

            return true;
        }

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

public bool VisitExprOutputColumnInserted(ExprOutputColumnInserted exprOutputColumnInserted, IExpr? parent)
        {
            this.Builder.Append("INSERTED.");
            exprOutputColumnInserted.ColumnName.Accept(this, exprOutputColumnInserted);
            return true;
        }

19 View Source File : Helper.cs
License : MIT License
Project Creator : 0ffffffffh

private static string HashWith(HashAlgorithm algo,string v)
        {
            string hash;
            StringBuilder sb = new StringBuilder();
            byte[] bytes = Encoding.ASCII.GetBytes(v);

            bytes = algo.ComputeHash(bytes);
            algo.Dispose();

            for (int i = 0; i < bytes.Length; i++)
                sb.Append(bytes[i].ToString("X2"));

            hash = sb.ToString();
            sb.Clear();
            sb = null;
            
            return hash;
        }

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

public bool VisitExprOutputAction(ExprOutputAction exprOutputAction, IExpr? parent)
        {
            this.Builder.Append("$ACTION");
            if (exprOutputAction.Alias != null)
            {
                this.Builder.Append(' ');
                exprOutputAction.Alias.Accept(this, exprOutputAction);
            }
            return true;
        }

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

public bool VisitExprBooleanNotEq(ExprBooleanNotEq exprBooleanNotEq, IExpr? parent)
        {
            exprBooleanNotEq.Left.Accept(this, exprBooleanNotEq);
            this.Builder.Append("!=");
            exprBooleanNotEq.Right.Accept(this, exprBooleanNotEq);

            return true;
        }

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

public bool VisitExprOver(ExprOver exprOver, IExpr? parent)
        {
            this.Builder.Append("OVER(");

            if (exprOver.Parreplacedions != null)
            {
                this.replacedertNotEmptyList(exprOver.Parreplacedions, "Parreplacedion list cannot be empty");
                this.Builder.Append("PARreplacedION BY ");
                this.AcceptListComaSeparated(exprOver.Parreplacedions, exprOver);
            }

            if (exprOver.OrderBy != null)
            {
                if (exprOver.Parreplacedions != null)
                {
                    this.Builder.Append(' ');
                }
                this.Builder.Append("ORDER BY ");
                exprOver.OrderBy.Accept(this, exprOver);
            }

            if (exprOver.FrameClause != null)
            {
                this.Builder.Append(' ');
                exprOver.FrameClause.Accept(this, exprOver);
            }

            this.Builder.Append(")");
            return true;
        }

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

public static void WriteHTMLEnd(HttpListenerContext c, StringBuilder builder) {
            builder.AppendLine(@"</div>");

            builder.Append(
@"
    </body>
</html>
"
            );
        }

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

public bool VisitExprValueFrameBorder(ExprValueFrameBorder exprValueFrameBorder, IExpr? arg)
        {
            exprValueFrameBorder.Value.Accept(this, exprValueFrameBorder);
            switch (exprValueFrameBorder.FrameBorderDirection)
            {
                case FrameBorderDirection.Preceding:
                    this.Builder.Append(" PRECEDING");
                    break;
                case FrameBorderDirection.Following:
                    this.Builder.Append(" FOLLOWING");
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
            return true;
        }

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

public bool VisitExprBooleanLtEq(ExprBooleanLtEq booleanLtEq, IExpr? parent)
        {
            booleanLtEq.Left.Accept(this, booleanLtEq);
            this.Builder.Append("<=");
            booleanLtEq.Right.Accept(this, booleanLtEq);

            return true;
        }

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

public bool VisitExprUnboundedFrameBorder(ExprUnboundedFrameBorder exprUnboundedFrameBorder, IExpr? arg)
        {
            switch (exprUnboundedFrameBorder.FrameBorderDirection)
            {
                case FrameBorderDirection.Preceding:
                    this.Builder.Append("UNBOUNDED PRECEDING");
                    break;
                case FrameBorderDirection.Following:
                    this.Builder.Append("UNBOUNDED FOLLOWING");
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            return true;
        }

19 View Source File : SozlukDataStore.cs
License : MIT License
Project Creator : 0ffffffffh

private static string BuildFetchSQLQuery(
            ref string baseQueryHash,
            string content, 
            string suser, 
            DateTime begin, DateTime end,
            int rowBegin,int rowEnd)
        {
            bool linkAnd = false;
            string query;

            StringBuilder sb = new StringBuilder();
            StringBuilder cond = new StringBuilder();

            if (!CacheManager.TryGetCachedResult<string>(baseQueryHash, out query))
            {

                if (!string.IsNullOrEmpty(suser))
                    sb.AppendFormat(SEARCH_SUSER_ID_GET_SQL, suser.Trim());

                if (!string.IsNullOrEmpty(content))
                {
                    cond.AppendFormat(SEARCH_COND_CONTENT, content.Trim());
                    linkAnd = true;
                }

                if (!string.IsNullOrEmpty(suser))
                {
                    if (linkAnd)
                        cond.Append(" AND ");
                    else
                        linkAnd = true;

                    cond.Append(SEARCH_COND_SUSER);
                }

                if (begin != DateTime.MinValue && end != DateTime.MinValue)
                {
                    if (linkAnd)
                        cond.Append(" AND ");

                    cond.AppendFormat(SEARCH_COND_DATE, begin.ToString(), end.ToString());

                }

                sb.Append(SEARCH_SQL_BASE);

                if (cond.Length > 0)
                {
                    cond.Insert(0, "WHERE ");
                    sb.Replace("%%CONDITIONS%%", cond.ToString());
                }
                else
                {
                    sb.Replace("%%CONDITIONS%%", string.Empty);
                }

                if (!string.IsNullOrEmpty(content))
                    sb.Replace("%%COUNT_CONDITION%%", string.Format(SEARCH_COND_COUNT_CONTENT, content));
                else
                    sb.Replace("%%COUNT_CONDITION%%", SEARCH_COND_COUNT_ALL);


                if (!string.IsNullOrEmpty(suser))
                    sb.Append(" AND EntryCount > 0");

                sb.Append(";");

                baseQueryHash = Helper.Md5(sb.ToString());

                CacheManager.CacheObject(baseQueryHash, sb.ToString());
            }
            else
            {
                sb.Append(query);
            }

            sb.Replace("%%ROW_LIMIT_CONDITION%%",
                string.Format("RowNum BETWEEN {0} AND {1}", rowBegin, rowEnd));
            
            query = sb.ToString();

            cond.Clear();
            sb.Clear();

            cond = null;
            sb = null;

            return query;
        }

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

public bool VisitExprCaseWhenThen(ExprCaseWhenThen exprCaseWhenThen, IExpr? parent)
        {
            this.Builder.Append("WHEN ");
            exprCaseWhenThen.Condition.Accept(this, exprCaseWhenThen);
            this.Builder.Append(" THEN ");
            exprCaseWhenThen.Value.Accept(this, exprCaseWhenThen);

            return true;
        }

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

public bool VisitExprInValues(ExprInValues exprInValues, IExpr? parent)
        {
            exprInValues.TestExpression.Accept(this, exprInValues);
            this.replacedertNotEmptyList(exprInValues.Items, "'IN' Predicate cannot have an empty list of expressions");
            this.Builder.Append(" IN");
            this.AcceptListComaSeparatedPar('(', exprInValues.Items, ')', exprInValues);
            return true;
        }

19 View Source File : KeyboardEvents.cs
License : zlib License
Project Creator : 0x0ade

public static bool GetKeyboardLayoutName(object pwszKLID) {
            // Let's just pretend EN - US (00000409)
            const string name = "00000409";

            if (pwszKLID is StringBuilder) {
                ((StringBuilder) pwszKLID).Append(name);
            } else if (pwszKLID is IntPtr) {
                // This is definitely wrong.
                unsafe
                {
                    char* str = (char*) ((IntPtr) pwszKLID).ToPointer();
                    for (int i = 0; i < name.Length; i++)
                        str[i] = name[i];
                }
            }

            return true; // No GetLastError
        }

19 View Source File : Entry.cs
License : MIT License
Project Creator : 0ffffffffh

public string GetTransportString()
        {
            StringBuilder sb = new StringBuilder();

            string s;

            if (RepCount > 1)
                sb.Append(MakeTag("Baslik", this.Baslik, "RepCount", RepCount)); 
            else
                sb.Append(MakeTag("Baslik", this.Baslik));

            sb.Append(MakeTag("Suser", Suser));
            sb.Append(MakeTag("Date", Date));
            sb.Append(MakeTag("Desc", Content));

            s = sb.ToString();
            sb.Clear();
            sb = null;
            
            return s;
        }

19 View Source File : SozlukRequestHandlerBase.cs
License : MIT License
Project Creator : 0ffffffffh

public bool PushResponseContent(string content)
        {
            this.respData.Append(content);
            return true;
        }

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 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 VisitExprJoinedTable(ExprJoinedTable joinedTable, IExpr? parent)
        {
            joinedTable.Left.Accept(this, joinedTable);
            switch (joinedTable.JoinType)
            {
                case ExprJoinedTable.ExprJoinType.Inner:
                    this.Builder.Append(" JOIN ");
                    break;
                case ExprJoinedTable.ExprJoinType.Left:
                    this.Builder.Append(" LEFT JOIN ");
                    break;
                case ExprJoinedTable.ExprJoinType.Right:
                    this.Builder.Append(" RIGHT JOIN ");
                    break;
                case ExprJoinedTable.ExprJoinType.Full:
                    this.Builder.Append(" FULL JOIN ");
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
            joinedTable.Right.Accept(this, joinedTable);
            this.Builder.Append(" ON ");
            joinedTable.SearchCondition.Accept(this, joinedTable);

            return true;
        }

See More Examples