System.Text.StringBuilder.Append(int)

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

1718 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 : 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 : 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 : 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 : JsonWriter.cs
License : MIT License
Project Creator : 5minlab

public void AppendJson(StringBuilder sb) {
            sb.Append(val);
        }

19 View Source File : Server.cs
License : MIT License
Project Creator : 5minlab

private void OnGUI() {
            if(!showGUI) { return; }

            if (hostAndPort == "" && Port > 0) {
                var sb = new StringBuilder();
                sb.Append("Sagiri Server ");
                sb.Append(Host);
                sb.Append(":");
                sb.Append(Port);
                hostAndPort = sb.ToString();
            }

            if(hostAndPort.Length > 0) {
                GUI.Label(new Rect(0, 0, 400, 100), hostAndPort);
            }
        }

19 View Source File : FdbKeySelector.cs
License : MIT License
Project Creator : abdullin

[Pure]
		public string PrettyPrint(FdbKey.PrettyPrintMode mode)
		{
			var sb = new StringBuilder();
			int offset = this.Offset;
			if (offset < 1)
			{
				sb.Append(this.OrEqual ? "lLE{" : "lLT{");
			}
			else
			{
				--offset;
				sb.Append(this.OrEqual ? "fGT{" : "fGE{");
			}
			sb.Append(FdbKey.PrettyPrint(m_key, mode));
			sb.Append("}");

			if (offset > 0)
				sb.Append(" + ").Append(offset);
			else if (offset < 0)
				sb.Append(" - ").Append(-offset);

			return sb.ToString();
		}

19 View Source File : VssApiResourceVersion.cs
License : MIT License
Project Creator : actions

public override string ToString()
        {
            StringBuilder sbVersion = new StringBuilder(ApiVersion.ToString(2));
            if (IsPreview)
            {
                sbVersion.Append('-');
                sbVersion.Append(c_PreviewStageName);

                if (ResourceVersion > 0)
                {
                    sbVersion.Append('.');
                    sbVersion.Append(ResourceVersion);
                }
            }
            return sbVersion.ToString();
        }

19 View Source File : Message.cs
License : MIT License
Project Creator : adrenak

public override string ToString() {
            StringBuilder sb = new StringBuilder("Message:\n");
            sb.Append("sender=").Append(sender).Append("\n");
            var recipientsJoined = string.Join(", ", recipients);
            sb.Append("recipients={").Append(recipientsJoined).Append("}\n");
            sb.Append("bytesLen=").Append(bytes.Length).Append("\n");
            sb.Append("bytes=").Append(BitConverter.ToString(bytes));
            return sb.ToString();
        }

19 View Source File : Packet.cs
License : MIT License
Project Creator : adrenak

public override string ToString() {
            try {
                StringBuilder sb = new StringBuilder("Packet:");
                sb.Append("\nTag=").Append(Tag);
                sb.Append("\nPayloadLength=").Append(Payload.Length);
                sb.Append("\nPayload=").Append(BitConverter.ToString(Payload));
                return sb.ToString();
            }
            catch { return base.ToString(); }
        }

19 View Source File : CSC.cs
License : MIT License
Project Creator : adrenak

override public string ToString() {
			var sb = new StringBuilder();
			sb.Append(m_Net).Append(" ^\n");

			sb.Append("/target:").Append(target).Append(" ^\n");
			sb.Append("/out:").Append("\"").Append(output.Replace("/", "\\")).Append("\" ^\n");

			for (int i = 0; i < defines.Length; i++)
				sb.Append("/define:").Append("\"").Append(defines[i]).Append("\"").Append(" ^\n");

			for (int i = 0; i < references.Length; i++) {
				references[i] = references[i].Replace('/', '\\');
				sb.Append("/r:").Append("\"").Append(references[i]).Append("\"").Append(" ^\n");
			}

			for (int i = 0; i < recurse.Length; i++) {
				recurse[i] = recurse[i].Replace('/', '\\');

				if (Utils.IsFile(recurse[i]))
					sb.Append("/recurse:").Append("\"").Append(recurse[i]).Append("\"").Append(" ^\n");
				else
					sb.Append("/recurse:").Append("\"").Append(recurse[i]).Append("\\*.cs").Append("\"").Append(" ^\n");
			}

			sb.Append("/warn:").Append(warn);
			return sb.ToString();
		}

19 View Source File : RedisWriter.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

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.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 : StackValuePointerArray.cs
License : GNU General Public License v3.0
Project Creator : ahmed605

public override string GetDisplayText()
        {
            var sb = new StringBuilder();
            
            if (Pointer is StackValuePointerFake)
            {
                sb.Append("(");
                sb.Append(Pointer.GetDisplayText());
                sb.Append(")");
            }
            else
            {
                sb.Append(Pointer.GetDisplayText());
            }
            
            sb.Append("[");
            sb.Append(Index.ToString());
            if (ItemSize > 1)
            {
                sb.Append(" * ");
                sb.Append(ItemSize);
            }
            sb.Append("]");

            return sb.ToString();
        }

19 View Source File : StackValuePointerIndex.cs
License : GNU General Public License v3.0
Project Creator : ahmed605

public override string GetDisplayText()
        {
            var sb = new StringBuilder();

            sb.Append(Pointer.GetDisplayText());
            sb.Append(".v");
            sb.Append(Index);

            return sb.ToString();
        }

19 View Source File : Instruction.cs
License : GNU General Public License v3.0
Project Creator : ahmed605

protected virtual string GetInstructionTextInternal()
        {
            var str = new StringBuilder();

            if (!Enum.IsDefined(typeof (OpCode), OpCode))
            {
                str.Append("Unknown_");
                str.Append((int) OpCode);
            }
            else
            {
                str.Append(OpCode);
            }

            for (int i = 0; i < OperandCount; i++)
            {
                str.Append(i > 0 ? ", " : " ");

                object opValue = Operands[i];
                Type opType = opValue.GetType();
                string opName = GetOperandName(i);

                if (opName != null)
                {
                    str.Append(opName);
                    str.Append("=");
                }

                if (opType == typeof (string))
                {
                    str.Append(LiteralFormatter.FormatString(opValue.ToString()));
                }
                else if (opType == typeof(uint))
                {
                    str.Append(LiteralFormatter.FormatInteger((int) (uint) opValue));
                }
                else if (opType == typeof(int))
                {
                    str.Append(LiteralFormatter.FormatInteger((int) opValue));
                }
                else if (opType == typeof(float))
                {
                    str.Append(LiteralFormatter.FormatFloat((float) opValue));
                }
                else
                {
                    str.Append(opValue.ToString());
                }
            }

            return str.ToString();
        }

19 View Source File : StackValuePointerVar.cs
License : GNU General Public License v3.0
Project Creator : ahmed605

public override string GetDisplayText()
        {
            var sb = new StringBuilder();
            switch (PointerType)
            {
                case StackValuePointerType.Local:
                    sb.Append("L");
                    break;
                case StackValuePointerType.Global:
                    sb.Append("G");
                    break;
                case StackValuePointerType.Null:
                    sb.Append("null");
                    break;
                case StackValuePointerType.Stack:
                    sb.Append("var");
                    break;
                case StackValuePointerType.Temporary:
                    sb.Append("temp");
                    break;
                default:
                    Debug.replacedert(false);
                    break;
            }

            if (PointerType == StackValuePointerType.Stack || PointerType == StackValuePointerType.Temporary )
            {
                sb.Append(PointerIndex);
            }
            else if (PointerType != StackValuePointerType.Null)
            {
                sb.Append("[");
                sb.Append(PointerIndex);
                sb.Append("]");
            }

            return sb.ToString();
        }

19 View Source File : DecompileFullOutput.cs
License : GNU General Public License v3.0
Project Creator : ahmed605

public void Process(File file, TextWriter writer)
        {
            var decoder = new Decoder(file);
            var program = new ScriptProgram(decoder);
            var replacedyzer = new ControlFlowreplacedyzer(program);
            replacedyzer.replacedyze();

            var stackreplacedyzer = new StackUsereplacedyzer(program);
            stackreplacedyzer.replacedyze();

            foreach (Function function in program.Functions)
            {
                var sb = new StringBuilder();
                for (int i = 0; i < function.ParameterCount; i++)
                {
                    if (i != 0)
                    {
                        sb.Append(", ");
                    }
                    sb.Append("var");
                    sb.Append(i);
                }

                writer.WriteLine(string.Format("{0} {1}({2})", function.ReturnCount > 0 ? "function" : "void",
                                               function.Name, sb));
                writer.WriteLine("{");

                if (function.VariableCount > 2)
                {
                    writer.Write("   auto ");
                    for (int i = 2; i < function.VariableCount; i++)
                    {
                        if (i != 2)
                        {
                            writer.Write(", ");
                        }
                        writer.Write("var" + (i + function.ParameterCount));
                    }
                    writer.WriteLine(";");
                }

                if (function.TemporaryCount > 0)
                {
                    writer.Write("   auto ");
                    for (int i = 0; i < function.TemporaryCount; i++)
                    {
                        if (i != 0)
                        {
                            writer.Write(", ");
                        }
                        writer.Write("temp" + i);
                    }
                    writer.WriteLine(";");
                }

                if (function.TemporaryCount > 0 || function.VariableCount > 2)
                {
                    writer.WriteLine();
                }

                ProcessCodePath(writer, function.MainCodePath, "   ");

                writer.WriteLine("}");
                writer.WriteLine();
            }
        }

19 View Source File : TestSubscriber.cs
License : Apache License 2.0
Project Creator : akarnokd

public InvalidOperationException Fail(string message)
        {
            StringBuilder b = new StringBuilder(64);

            b.Append(message);
            b.Append(" (latch = ").Append(latch.CurrentCount);
            b.Append(", values = ").Append(Volatile.Read(ref valueCount));
            long ec = Volatile.Read(ref errorCount);
            b.Append(", errors = ").Append(ec);
            b.Append(", completions = ").Append(Volatile.Read(ref completions));
            b.Append(", subscribed = ").Append(Volatile.Read(ref upstream) != null);
            b.Append(", cancelled = ").Append(SubscriptionHelper.IsCancelled(ref upstream));
            if (tag != null)
            {
                b.Append(", tag = ").Append(tag);
            }
            b.Append(")");

            InvalidOperationException ex;

            if (ec != 0)
            {
                if (ec == 1)
                {
                    ex = new InvalidOperationException(b.ToString(), errors[0]);
                }
                else
                {
                    ex = new InvalidOperationException(b.ToString(), new AggregateException(errors));
                }
            }
            else
            {
                ex = new InvalidOperationException(b.ToString());
            }
            return ex;
        }

19 View Source File : JsonPosition.cs
License : MIT License
Project Creator : akaskela

internal void WriteTo(StringBuilder sb)
        {
            switch (Type)
            {
                case JsonContainerType.Object:
                    string propertyName = PropertyName;
                    if (propertyName.IndexOfAny(SpecialCharacters) != -1)
                    {
                        sb.Append(@"['");
                        sb.Append(propertyName);
                        sb.Append(@"']");
                    }
                    else
                    {
                        if (sb.Length > 0)
                        {
                            sb.Append('.');
                        }

                        sb.Append(propertyName);
                    }
                    break;
                case JsonContainerType.Array:
                case JsonContainerType.Constructor:
                    sb.Append('[');
                    sb.Append(Position);
                    sb.Append(']');
                    break;
            }
        }

19 View Source File : JsonSerializer.cs
License : MIT License
Project Creator : AlenToma

internal string ConvertToJSON(object obj)
        {
            WriteValue(obj);

            if (_params.UsingGlobalTypes && _globalTypes != null && _globalTypes.Count > 0)
            {
                var sb = new StringBuilder();
                sb.Append("\"$types\":{");
                var pendingSeparator = false;
                foreach (var kv in _globalTypes)
                {
                    if (pendingSeparator) sb.Append(',');
                    pendingSeparator = true;
                    sb.Append('\"');
                    sb.Append(kv.Key);
                    sb.Append("\":\"");
                    sb.Append(kv.Value);
                    sb.Append('\"');
                }
                sb.Append("},");
                _output.Insert(_before, sb.ToString());
            }
            return _output.ToString();
        }

19 View Source File : ExperimentDataExportController.cs
License : MIT License
Project Creator : AlexanderFroemmgen

private void GetResultDataCSVExport(int id, string path)
        {
            /* 
             * Performance notes:
             * 
             * This lazy style is much faster than loading all data at once.
             * 
             */
            var data =
                _context.Experiments
                    .Include(s => s.Parameters).ThenInclude(p => p.Values)
                    .Include(s => s.ExperimentInstances)
                    .Single(s => s.Id == id);

            var outputFileStream = new StreamWriter(new FileStream(path, FileMode.Create));

            var result = new StringBuilder("simInstanceId;");

            foreach (var parameter in data.Parameters.OrderBy(p => p.Name))
            {
                result.Append(parameter.Name);
                result.Append(";");
            }
            result.Append("value;offset;key;key2;key3;\n");
            outputFileStream.Write(result);            
            result.Clear();

            int counter = -1;
            int total = data.ExperimentInstances.Count();
            var sb = new StringBuilder();

            foreach (var simInstanceBlank in data.ExperimentInstances)
            {
                var simInstance = _context.ExperimentInstances
                    .Include(i => i.ParameterValues)
                    .Include(i => i.Records)
		   // .Include(i => i.LogMessages) Denny
                    .Single(i => i.Id == simInstanceBlank.Id);
                /* 
                 * Design desicion: 
                 * 
                 * All records are in a own row and share the same parameters.
                 * 
                 */

                var parameterStringBuilder = new StringBuilder(simInstance.Id + ";");

                foreach (var paramInstance in simInstance.ParameterValues
                    .OrderBy(pv => pv.ParameterValue.Parameter.Name)
                    .Select(a => a.ParameterValue))
                {
                    parameterStringBuilder.Append(paramInstance.Value);
                    parameterStringBuilder.Append(";");
                }

                var parameterString = parameterStringBuilder.ToString();
                foreach (var record in simInstance.Records)
                {
                    sb.Append(parameterString);
                    sb.Append(record.Value);
                    sb.Append(";");
                    sb.Append(record.Offset);
                    sb.Append(";");
                    sb.Append(record.Key);
                    sb.Append(";");
                    sb.Append(record.Key2);
                    sb.Append(";");
                    sb.Append(record.Key3);
                    sb.Append(";\n");
                }

                /* add failed statistics */
                sb.Append(parameterString);
                sb.Append(simInstance.Status == Data.Persistence.Model.ExperimentStatus.Finished ? 1 : 0);
                sb.Append(";0;Finished;\n");

                sb.Append(parameterString);
                sb.Append((simInstance.Status == Data.Persistence.Model.ExperimentStatus.Error || 
                    simInstance.Status == Data.Persistence.Model.ExperimentStatus.Aborted) ? 1 : 0);
                sb.Append(";0;Error;\n");


                /* denny string */

                /*                var log = simInstance.LogMessages.Where(lm => lm.Key == "Measurement result").SingleOrDefault();

                        if(log != null) {
                            var logStr = log.Message.Replace(";", "|");

                                sb.Append(parameterString);
                                sb.Append("DennyAdaptationLog");
                                sb.Append(";");
                                sb.Append(0);
                                sb.Append(";");
                                sb.Append(logStr);
                                sb.Append(";\n");
                        } else {
                            Console.WriteLine("No log message for " + simInstance.Id.ToString());
                        }*/

                /* end denny */

                counter++;
                if (counter % 50 == 0)
                {
                    Console.WriteLine("Exported " + counter.ToString() + " of " + total.ToString());
                    outputFileStream.Write(sb);
                    sb.Clear();
                }
            }
            /* write remaining stuff */
            outputFileStream.Write(sb);
            outputFileStream.Close();

            Console.WriteLine("Finished Export");
        }

19 View Source File : SMBIOS.cs
License : MIT License
Project Creator : AlexGyver

public string GetReport() {
      StringBuilder r = new StringBuilder();

      if (version != null) {
        r.Append("SMBIOS Version: "); r.AppendLine(version.ToString(2));
        r.AppendLine();
      }

      if (BIOS != null) {
        r.Append("BIOS Vendor: "); r.AppendLine(BIOS.Vendor);
        r.Append("BIOS Version: "); r.AppendLine(BIOS.Version);
        r.AppendLine();
      }

      if (System != null) {
        r.Append("System Manufacturer: ");
        r.AppendLine(System.ManufacturerName);
        r.Append("System Name: ");
        r.AppendLine(System.ProductName);
        r.Append("System Version: ");
        r.AppendLine(System.Version);
        r.AppendLine();
      }

      if (Board != null) {
        r.Append("Mainboard Manufacturer: ");
        r.AppendLine(Board.ManufacturerName);
        r.Append("Mainboard Name: ");
        r.AppendLine(Board.ProductName);
        r.Append("Mainboard Version: ");
        r.AppendLine(Board.Version);
        r.AppendLine();
      }

      if (Processor != null) {
        r.Append("Processor Manufacturer: ");
        r.AppendLine(Processor.ManufacturerName);
        r.Append("Processor Version: ");
        r.AppendLine(Processor.Version);
        r.Append("Processor Core Count: ");
        r.AppendLine(Processor.CoreCount.ToString());
        r.Append("Processor Core Enabled: ");
        r.AppendLine(Processor.CoreEnabled.ToString());
        r.Append("Processor Thread Count: ");
        r.AppendLine(Processor.ThreadCount.ToString());
        r.Append("Processor External Clock: ");
        r.Append(Processor.ExternalClock);
        r.AppendLine(" Mhz");
        r.AppendLine();
      }

      for (int i = 0; i < MemoryDevices.Length; i++) {        
        r.Append("Memory Device [" + i + "] Manufacturer: ");
        r.AppendLine(MemoryDevices[i].ManufacturerName);
        r.Append("Memory Device [" + i + "] Part Number: ");
        r.AppendLine(MemoryDevices[i].PartNumber);
        r.Append("Memory Device [" + i + "] Device Locator: ");
        r.AppendLine(MemoryDevices[i].DeviceLocator);
        r.Append("Memory Device [" + i + "] Bank Locator: ");
        r.AppendLine(MemoryDevices[i].BankLocator);
        r.Append("Memory Device [" + i + "] Speed: ");
        r.Append(MemoryDevices[i].Speed);
        r.AppendLine(" MHz");
        r.AppendLine();
      }

      if (raw != null) {
        string base64 = Convert.ToBase64String(raw);
        r.AppendLine("SMBIOS Table");
        r.AppendLine();

        for (int i = 0; i < Math.Ceiling(base64.Length / 64.0); i++) {
          r.Append(" ");
          for (int j = 0; j < 0x40; j++) {
            int index = (i << 6) | j;
            if (index < base64.Length) {              
              r.Append(base64[index]);
            }
          }
          r.AppendLine();
        }
        r.AppendLine();
      }

      return r.ToString();
    }

19 View Source File : SenderIDRecord.cs
License : Apache License 2.0
Project Creator : alexreinert

public override string ToString()
		{
			StringBuilder res = new StringBuilder();

			if (Version == 1)
			{
				res.Append("v=spf1");
			}
			else
			{
				res.Append("v=spf");
				res.Append(Version);
				res.Append(".");
				res.Append(MinorVersion);
				res.Append("/");
				res.Append(String.Join(",", Scopes.Where(s => s != SenderIDScope.Unknown).Select(s => EnumHelper<SenderIDScope>.ToString(s).ToLower())));
			}

			if ((Terms != null) && (Terms.Count > 0))
			{
				foreach (SpfTerm term in Terms)
				{
					SpfModifier modifier = term as SpfModifier;
					if ((modifier == null) || (modifier.Type != SpfModifierType.Unknown))
					{
						res.Append(" ");
						res.Append(term);
					}
				}
			}

			return res.ToString();
		}

19 View Source File : SpfMechanism.cs
License : Apache License 2.0
Project Creator : alexreinert

public override string ToString()
		{
			StringBuilder res = new StringBuilder();

			switch (Qualifier)
			{
				case SpfQualifier.Fail:
					res.Append("-");
					break;
				case SpfQualifier.SoftFail:
					res.Append("~");
					break;
				case SpfQualifier.Neutral:
					res.Append("?");
					break;
			}

			res.Append(EnumHelper<SpfMechanismType>.ToString(Type).ToLower());

			if (!String.IsNullOrEmpty(Domain))
			{
				res.Append(":");
				res.Append(Domain);
			}

			if (Prefix.HasValue)
			{
				res.Append("/");
				res.Append(Prefix.Value);
			}

			if (Prefix6.HasValue)
			{
				res.Append("//");
				res.Append(Prefix6.Value);
			}

			return res.ToString();
		}

19 View Source File : EngineViewModel.cs
License : Apache License 2.0
Project Creator : AlexWan

public string GetStringForSave()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(EngineName).Append(";");
            sb.Append(Ip).Append(";");
            sb.Append(Port).Append(";");
            sb.Append(Token).Append(";");
            sb.Append(RebootRam).Append(";");

            return sb.ToString();
        }

19 View Source File : HTMLTextHandling.cs
License : MIT License
Project Creator : AlFasGD

public static string ConvertHTMLHexCharacterCodes(string str)
        {
            var chars = str.ToCharArray();
            var result = new StringBuilder(chars.Length);
            for (int i = 0; i < chars.Length; i++)
            {
                if (chars[i] == '%')
                {
                    result.Append(int.Parse(chars[(i + 1)..(i + 2)], NumberStyles.HexNumber));
                    i += 2;
                }
                else
                    result.Append(chars[i]);
            }
            return result.ToString();
        }

19 View Source File : AutomataDictionary.cs
License : Apache License 2.0
Project Creator : allenai

private static void ToStringCore(IEnumerable<AutomataNode> nexts, StringBuilder sb, int depth)
        {
            foreach (AutomataNode item in nexts)
            {
                if (depth != 0)
                {
                    sb.Append(' ', depth * 2);
                }

                sb.Append("[" + item.Key + "]");
                if (item.Value != -1)
                {
                    sb.Append("(" + item.OriginalKey + ")");
                    sb.Append(" = ");
                    sb.Append(item.Value);
                }

                sb.AppendLine();
                ToStringCore(item.YieldChildren(), sb, depth + 1);
            }
        }

19 View Source File : JoystickState.cs
License : MIT License
Project Creator : allenwp

public override string ToString()
        {
            var ret = new StringBuilder(54 - 2 + Axes.Length * 7 + Buttons.Length + Hats.Length * 5);
            ret.Append("[JoystickState: IsConnected=" + (IsConnected ? 1 : 0));

            if (IsConnected)
            {
                ret.Append(", Axes=");
                foreach (var axis in Axes)
                    ret.Append((axis > 0 ? "+" : "") + axis.ToString("00000") + " ");
                ret.Length--;

                ret.Append(", Buttons=");
                foreach (var button in Buttons)
                    ret.Append((int)button);

                ret.Append(", Hats=");
                foreach (var hat in Hats)
                    ret.Append(hat + " ");
                ret.Length--;
            }

            ret.Append("]");
            return ret.ToString();
        }

19 View Source File : PageHeader.cs
License : MIT License
Project Creator : aloneguid

public override string ToString() {
      StringBuilder __sb = new StringBuilder("PageHeader(");
      __sb.Append(", Type: ");
      __sb.Append(Type);
      __sb.Append(", Uncompressed_page_size: ");
      __sb.Append(Uncompressed_page_size);
      __sb.Append(", Compressed_page_size: ");
      __sb.Append(Compressed_page_size);
      if (__isset.crc) {
        __sb.Append(", Crc: ");
        __sb.Append(Crc);
      }
      if (Data_page_header != null && __isset.data_page_header) {
        __sb.Append(", Data_page_header: ");
        __sb.Append(Data_page_header== null ? "<null>" : Data_page_header.ToString());
      }
      if (Index_page_header != null && __isset.index_page_header) {
        __sb.Append(", Index_page_header: ");
        __sb.Append(Index_page_header== null ? "<null>" : Index_page_header.ToString());
      }
      if (Dictionary_page_header != null && __isset.dictionary_page_header) {
        __sb.Append(", Dictionary_page_header: ");
        __sb.Append(Dictionary_page_header== null ? "<null>" : Dictionary_page_header.ToString());
      }
      if (Data_page_header_v2 != null && __isset.data_page_header_v2) {
        __sb.Append(", Data_page_header_v2: ");
        __sb.Append(Data_page_header_v2== null ? "<null>" : Data_page_header_v2.ToString());
      }
      __sb.Append(")");
      return __sb.ToString();
    }

19 View Source File : SchemaElement.cs
License : MIT License
Project Creator : aloneguid

public override string ToString() {
      StringBuilder __sb = new StringBuilder("SchemaElement(");
      bool __first = true;
      if (__isset.type) {
        if(!__first) { __sb.Append(", "); }
        __first = false;
        __sb.Append("Type: ");
        __sb.Append(Type);
      }
      if (__isset.type_length) {
        if(!__first) { __sb.Append(", "); }
        __first = false;
        __sb.Append("Type_length: ");
        __sb.Append(Type_length);
      }
      if (__isset.repereplacedion_type) {
        if(!__first) { __sb.Append(", "); }
        __first = false;
        __sb.Append("Repereplacedion_type: ");
        __sb.Append(Repereplacedion_type);
      }
      if(!__first) { __sb.Append(", "); }
      __sb.Append("Name: ");
      __sb.Append(Name);
      if (__isset.num_children) {
        __sb.Append(", Num_children: ");
        __sb.Append(Num_children);
      }
      if (__isset.converted_type) {
        __sb.Append(", Converted_type: ");
        __sb.Append(Converted_type);
      }
      if (__isset.scale) {
        __sb.Append(", Scale: ");
        __sb.Append(Scale);
      }
      if (__isset.precision) {
        __sb.Append(", Precision: ");
        __sb.Append(Precision);
      }
      if (__isset.field_id) {
        __sb.Append(", Field_id: ");
        __sb.Append(Field_id);
      }
      if (LogicalType != null && __isset.logicalType) {
        __sb.Append(", LogicalType: ");
        __sb.Append(LogicalType== null ? "<null>" : LogicalType.ToString());
      }
      __sb.Append(")");
      return __sb.ToString();
    }

19 View Source File : AwsS3FileStorage.cs
License : Apache License 2.0
Project Creator : aloneguid

private HttpRequestMessage CreateCompleteMultipartUploadRequest(string key, string uploadId, IEnumerable<string> partTags)
      {
         var request = new HttpRequestMessage(HttpMethod.Post, $"/{key}?uploadId={uploadId}");

         var sb = new StringBuilder(@"<?xml version=""1.0"" encoding=""UTF-8""?><CompleteMultipartUpload xmlns=""http://s3.amazonaws.com/doc/2006-03-01/"">");
         int partId = 1;
         foreach(string eTag in partTags)
         {
            sb
               .Append("<Part><ETag>")
               .Append(eTag)
               .Append("</ETag><PartNumber>")
               .Append(partId++)
               .Append("</PartNumber></Part>");

         }
         sb.Append("</CompleteMultipartUpload>");
         request.Content = new StringContent(sb.ToString());
         return request;
      }

19 View Source File : DataPageHeader.cs
License : MIT License
Project Creator : aloneguid

public override string ToString() {
      StringBuilder __sb = new StringBuilder("DataPageHeader(");
      __sb.Append(", Num_values: ");
      __sb.Append(Num_values);
      __sb.Append(", Encoding: ");
      __sb.Append(Encoding);
      __sb.Append(", Definition_level_encoding: ");
      __sb.Append(Definition_level_encoding);
      __sb.Append(", Repereplacedion_level_encoding: ");
      __sb.Append(Repereplacedion_level_encoding);
      if (Statistics != null && __isset.statistics) {
        __sb.Append(", Statistics: ");
        __sb.Append(Statistics== null ? "<null>" : Statistics.ToString());
      }
      __sb.Append(")");
      return __sb.ToString();
    }

19 View Source File : SortingColumn.cs
License : MIT License
Project Creator : aloneguid

public override string ToString() {
      StringBuilder __sb = new StringBuilder("SortingColumn(");
      __sb.Append(", Column_idx: ");
      __sb.Append(Column_idx);
      __sb.Append(", Descending: ");
      __sb.Append(Descending);
      __sb.Append(", Nulls_first: ");
      __sb.Append(Nulls_first);
      __sb.Append(")");
      return __sb.ToString();
    }

19 View Source File : PageEncodingStats.cs
License : MIT License
Project Creator : aloneguid

public override string ToString() {
      StringBuilder __sb = new StringBuilder("PageEncodingStats(");
      __sb.Append(", Page_type: ");
      __sb.Append(Page_type);
      __sb.Append(", Encoding: ");
      __sb.Append(Encoding);
      __sb.Append(", Count: ");
      __sb.Append(Count);
      __sb.Append(")");
      return __sb.ToString();
    }

19 View Source File : PageLocation.cs
License : MIT License
Project Creator : aloneguid

public override string ToString() {
      StringBuilder __sb = new StringBuilder("PageLocation(");
      __sb.Append(", Offset: ");
      __sb.Append(Offset);
      __sb.Append(", Compressed_page_size: ");
      __sb.Append(Compressed_page_size);
      __sb.Append(", First_row_index: ");
      __sb.Append(First_row_index);
      __sb.Append(")");
      return __sb.ToString();
    }

19 View Source File : BloomFilterHeader.cs
License : MIT License
Project Creator : aloneguid

public override string ToString() {
      StringBuilder __sb = new StringBuilder("BloomFilterHeader(");
      __sb.Append(", NumBytes: ");
      __sb.Append(NumBytes);
      __sb.Append(", Algorithm: ");
      __sb.Append(Algorithm== null ? "<null>" : Algorithm.ToString());
      __sb.Append(", Hash: ");
      __sb.Append(Hash== null ? "<null>" : Hash.ToString());
      __sb.Append(", Compression: ");
      __sb.Append(Compression== null ? "<null>" : Compression.ToString());
      __sb.Append(")");
      return __sb.ToString();
    }

19 View Source File : ColumnChunk.cs
License : MIT License
Project Creator : aloneguid

public override string ToString() {
      StringBuilder __sb = new StringBuilder("ColumnChunk(");
      bool __first = true;
      if (File_path != null && __isset.file_path) {
        if(!__first) { __sb.Append(", "); }
        __first = false;
        __sb.Append("File_path: ");
        __sb.Append(File_path);
      }
      if(!__first) { __sb.Append(", "); }
      __sb.Append("File_offset: ");
      __sb.Append(File_offset);
      if (Meta_data != null && __isset.meta_data) {
        __sb.Append(", Meta_data: ");
        __sb.Append(Meta_data== null ? "<null>" : Meta_data.ToString());
      }
      if (__isset.offset_index_offset) {
        __sb.Append(", Offset_index_offset: ");
        __sb.Append(Offset_index_offset);
      }
      if (__isset.offset_index_length) {
        __sb.Append(", Offset_index_length: ");
        __sb.Append(Offset_index_length);
      }
      if (__isset.column_index_offset) {
        __sb.Append(", Column_index_offset: ");
        __sb.Append(Column_index_offset);
      }
      if (__isset.column_index_length) {
        __sb.Append(", Column_index_length: ");
        __sb.Append(Column_index_length);
      }
      if (Crypto_metadata != null && __isset.crypto_metadata) {
        __sb.Append(", Crypto_metadata: ");
        __sb.Append(Crypto_metadata== null ? "<null>" : Crypto_metadata.ToString());
      }
      if (Encrypted_column_metadata != null && __isset.encrypted_column_metadata) {
        __sb.Append(", Encrypted_column_metadata: ");
        __sb.Append(Encrypted_column_metadata);
      }
      __sb.Append(")");
      return __sb.ToString();
    }

19 View Source File : DataPageHeaderV2.cs
License : MIT License
Project Creator : aloneguid

public override string ToString() {
      StringBuilder __sb = new StringBuilder("DataPageHeaderV2(");
      __sb.Append(", Num_values: ");
      __sb.Append(Num_values);
      __sb.Append(", Num_nulls: ");
      __sb.Append(Num_nulls);
      __sb.Append(", Num_rows: ");
      __sb.Append(Num_rows);
      __sb.Append(", Encoding: ");
      __sb.Append(Encoding);
      __sb.Append(", Definition_levels_byte_length: ");
      __sb.Append(Definition_levels_byte_length);
      __sb.Append(", Repereplacedion_levels_byte_length: ");
      __sb.Append(Repereplacedion_levels_byte_length);
      if (__isset.is_compressed) {
        __sb.Append(", Is_compressed: ");
        __sb.Append(Is_compressed);
      }
      if (Statistics != null && __isset.statistics) {
        __sb.Append(", Statistics: ");
        __sb.Append(Statistics== null ? "<null>" : Statistics.ToString());
      }
      __sb.Append(")");
      return __sb.ToString();
    }

19 View Source File : DecimalType.cs
License : MIT License
Project Creator : aloneguid

public override string ToString() {
      StringBuilder __sb = new StringBuilder("DecimalType(");
      __sb.Append(", Scale: ");
      __sb.Append(Scale);
      __sb.Append(", Precision: ");
      __sb.Append(Precision);
      __sb.Append(")");
      return __sb.ToString();
    }

19 View Source File : DictionaryPageHeader.cs
License : MIT License
Project Creator : aloneguid

public override string ToString() {
      StringBuilder __sb = new StringBuilder("DictionaryPageHeader(");
      __sb.Append(", Num_values: ");
      __sb.Append(Num_values);
      __sb.Append(", Encoding: ");
      __sb.Append(Encoding);
      if (__isset.is_sorted) {
        __sb.Append(", Is_sorted: ");
        __sb.Append(Is_sorted);
      }
      __sb.Append(")");
      return __sb.ToString();
    }

19 View Source File : FileMetaData.cs
License : MIT License
Project Creator : aloneguid

public override string ToString() {
      StringBuilder __sb = new StringBuilder("FileMetaData(");
      __sb.Append(", Version: ");
      __sb.Append(Version);
      __sb.Append(", Schema: ");
      __sb.Append(Schema);
      __sb.Append(", Num_rows: ");
      __sb.Append(Num_rows);
      __sb.Append(", Row_groups: ");
      __sb.Append(Row_groups);
      if (Key_value_metadata != null && __isset.key_value_metadata) {
        __sb.Append(", Key_value_metadata: ");
        __sb.Append(Key_value_metadata);
      }
      if (Created_by != null && __isset.created_by) {
        __sb.Append(", Created_by: ");
        __sb.Append(Created_by);
      }
      if (Column_orders != null && __isset.column_orders) {
        __sb.Append(", Column_orders: ");
        __sb.Append(Column_orders);
      }
      if (Encryption_algorithm != null && __isset.encryption_algorithm) {
        __sb.Append(", Encryption_algorithm: ");
        __sb.Append(Encryption_algorithm== null ? "<null>" : Encryption_algorithm.ToString());
      }
      if (Footer_signing_key_metadata != null && __isset.footer_signing_key_metadata) {
        __sb.Append(", Footer_signing_key_metadata: ");
        __sb.Append(Footer_signing_key_metadata);
      }
      __sb.Append(")");
      return __sb.ToString();
    }

19 View Source File : ManualModalityDataFormatter.cs
License : MIT License
Project Creator : AndreyAkinshin

public void Present([NotNull] StringBuilder builder, char open, string multiSeparator, char close, bool presentCount,
                [NotNull] string format, [NotNull] IFormatProvider formatProvider)
            {
                switch (Count)
                {
                    case 0:
                        break;
                    case 1:
                        builder.Append(open);
                        builder.Append(Min.ToString(format, formatProvider));
                        builder.Append(close);
                        break;
                    case 2:
                        builder.Append(open);
                        builder.Append(Min.ToString(format, formatProvider));
                        builder.Append(", ");
                        builder.Append(Max.ToString(format, formatProvider));
                        builder.Append(close);
                        break;
                    default:
                    {
                        builder.Append(open);
                        if (Mode != null)
                        {
                            builder.Append(Min.ToString(format, formatProvider));
                            builder.Append(" | ");
                            builder.Append(Mode?.ToString(format, formatProvider));
                            builder.Append(" | ");
                            builder.Append(Max.ToString(format, formatProvider));
                        }
                        else
                        {
                            builder.Append(Min.ToString(format, formatProvider));
                            builder.Append(multiSeparator);
                            builder.Append(Max.ToString(format, formatProvider));
                        }

                        builder.Append(close);
                        break;
                    }
                }

                if (Count > 2 && presentCount)
                {
                    builder.Append("_");
                    builder.Append(Count);
                }
            }

19 View Source File : ManualModalityDataFormatter.cs
License : MIT License
Project Creator : AndreyAkinshin

public string Format(ModalityData data, string numberFormat = null, IFormatProvider numberFormatProvider = null)
        {
            replacedertion.NotNull(nameof(data), data);

            var outlierDetectorFactory = OutlierDetectorFactory ?? SimpleOutlierDetectorFactory.DoubleMad;
            numberFormat ??= "N2";
            numberFormatProvider ??= DefaultCultureInfo.Instance;

            bool compactMode = CompactMiddleModes && data.Modality > 2;
            var modes = compactMode
                ? new[] {data.Modes.First(), data.Modes.Last()}
                : data.Modes;
            var builder = new StringBuilder();
            var bunch = new Bunch();
            bool isFirst = true;

            void AddBunch(char open, string multiSeparator, char close)
            {
                if (bunch.Any())
                {
                    if (isFirst)
                        isFirst = false;
                    else
                        builder.Append(GroupSeparator);
                    bunch.Present(builder, open, multiSeparator, close, PresentCount, numberFormat, numberFormatProvider);
                }
            }

            void AddMode() => AddBunch('[', "; ", ']');
            void AddOutliers() => AddBunch('{', "..", '}');

            void AddMiddleNodesIfNeeded(int index)
            {
                if (index == 0 && compactMode)
                {
                    int extraModes = data.Modality - 2;
                    if (isFirst)
                        isFirst = false;
                    else
                        builder.Append(GroupSeparator);
                    builder.Append('<');
                    builder.Append(extraModes);
                    builder.Append(' ');
                    builder.Append(extraModes > 1 ? "modes" : "mode");
                    builder.Append('>');
                }
            }


            if (PresentOutliers)
            {
                for (int i = 0; i < modes.Count; i++)
                {
                    var mode = modes[i];
                    var outlierDetector = outlierDetectorFactory.Create(mode.Values);
                    int index = 0;

                    // *Lower outliers*
                    while (index < mode.Values.Count && outlierDetector.IsLowerOutlier(mode.Values[index]))
                        bunch.Add(mode.Values[index++]);
                    if (!(compactMode && i != 0))
                        AddOutliers();
                    bunch.Clear();

                    // *Central values*
                    while (index < mode.Values.Count && !outlierDetector.IsOutlier(mode.Values[index]))
                        bunch.Add(mode.Values[index++]);
                    if (PresentModeLocations)
                        bunch.Mode = mode.Location;
                    AddMode();
                    bunch.Clear();

                    // *Upper outliers*
                    while (index < mode.Values.Count && outlierDetector.IsUpperOutlier(mode.Values[index]))
                        bunch.Add(mode.Values[index++]);
                    // Propagate bunch to the lower outliers of the next mode

                    AddMiddleNodesIfNeeded(i);
                }

                AddOutliers(); // Upper outliers of the last mode
            }
            else
            {
                for (int i = 0; i < modes.Count; i++)
                {
                    var mode = modes[i];
                    bunch.Min = mode.Min();
                    bunch.Max = mode.Max();
                    if (PresentModeLocations)
                        bunch.Mode = mode.Location;
                    bunch.Count = mode.Values.Count;
                    AddBunch('[', "; ", ']');
                    AddMiddleNodesIfNeeded(i);
                }
            }

            return builder.ToString();
        }

19 View Source File : MovingP2QuantileEstimatorTests.cs
License : MIT License
Project Creator : AndreyAkinshin

[Theory]
        [InlineData(1000, 51, 0.5, 0.2, 0.7)]
        public void MovingP2QuantileEstimatorMedianTest1(int n, int windowSize, double probability, double relativeThreshold,
            double minSuccessRate)
        {
            var random = new Random();
            double[] data = new double[n];
            for (int i = 0; i < n; i++)
            {
                data[i] = 10 + Math.Sin(i / 20.0) * 5 + random.NextDouble(-3, 3);
                if (random.Next(10) == 0 && i > windowSize / 2)
                    data[i] += random.Next(20, 50);
                data[i] = Math.Round(data[i], 3);
            }

            var mp2Estimator = new MovingP2QuantileEstimator(probability, windowSize);
            var phEstimator = new ParreplacedioningHeapsMovingQuantileEstimator(windowSize, probability);

            var outputBuilder = new StringBuilder();
            outputBuilder.AppendLine("i,data,estimation,true");
            int successCounter = 0;
            for (int i = 0; i < n; i++)
            {
                mp2Estimator.Add(data[i]);
                phEstimator.Add(data[i]);

                double mp2Estimation = mp2Estimator.GetQuantile();
                double trueValue = phEstimator.GetQuantile();

                if (Math.Abs(mp2Estimation - trueValue) / trueValue < relativeThreshold)
                    successCounter++;

                outputBuilder.Append(i);
                outputBuilder.Append(',');
                outputBuilder.Append(data[i].ToString(TestCultureInfo.Instance));
                outputBuilder.Append(',');
                outputBuilder.Append(mp2Estimation.ToString(TestCultureInfo.Instance));
                outputBuilder.Append(',');
                outputBuilder.Append(trueValue.ToString(TestCultureInfo.Instance));
                outputBuilder.AppendLine();
            }
            double actualSuccessRate = successCounter * 1.0 / n;

            output.WriteLine("ExpectedSuccessRate = " + minSuccessRate.ToString(TestCultureInfo.Instance));
            output.WriteLine("ActualSuccessRate   = " + actualSuccessRate.ToString(TestCultureInfo.Instance));
            output.WriteLine();
            output.WriteLine(outputBuilder.ToString());

            replacedert.True(successCounter * 1.0 / n > minSuccessRate);
        }

19 View Source File : UserDictionary.cs
License : Apache License 2.0
Project Creator : AnkiUniversal

public override string ToString()
            {
                StringBuilder builder = new StringBuilder();
                builder.Append(surface);
                builder.Append(FEATURE_SEPARATOR);
                builder.Append(costs[0]);
                builder.Append(FEATURE_SEPARATOR);
                builder.Append(costs[1]);
                builder.Append(FEATURE_SEPARATOR);
                builder.Append(costs[2]);
                builder.Append(FEATURE_SEPARATOR);
                builder.Append(String.Join(FEATURE_SEPARATOR, features));
                return builder.ToString();
            }

19 View Source File : ExampleTable.cs
License : Apache License 2.0
Project Creator : AnkiUniversal

private static string ToIdList(List<ExampleTable> entries, int startIndex, int getLength)
        {
            int length = entries.Count > (startIndex + getLength) ? getLength : (entries.Count - startIndex);
            StringBuilder builder = new StringBuilder();
            builder.Append("(");
            for (int i = startIndex; i < length - 1; i++)
            {
                builder.Append(entries[i].Id);
                builder.Append(",");
            }
            builder.Append(entries[length - 1].Id);
            builder.Append(")");
            return builder.ToString();
        }

19 View Source File : BitsFormatter.cs
License : Apache License 2.0
Project Creator : AnkiUniversal

public string FormatArc(byte[] fst, int address, int acreplacedulateBytes, int jumpBytes)
        {
            StringBuilder builder = new StringBuilder();
            int output = Bits.GetInt(fst, address, acreplacedulateBytes);
            address -= acreplacedulateBytes;

            int jumpAddress = Bits.GetInt(fst, address, jumpBytes);
            address -= jumpBytes;

            char label = (char)Bits.GetShort(fst, address);
            //        address -= 1;

            builder.Append('\t');
            builder.Append(label);
            builder.Append(" -> ");
            builder.Append(output);
            builder.Append("\t(JMP: ");
            builder.Append(jumpAddress);
            builder.Append(')');
            return builder.ToString();
        }

19 View Source File : ViterbiFormatter.cs
License : Apache License 2.0
Project Creator : AnkiUniversal

private string FormatEdge(ViterbiNode from, ViterbiNode to, String attributes)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append(GetNodeId(from));
            builder.Append(" -> ");
            builder.Append(GetNodeId(to));
            builder.Append(" [ ");
            builder.Append("label=\"");
            builder.Append(GetCost(from, to));
            builder.Append("\"");
            builder.Append(" ");
            builder.Append(attributes);
            builder.Append(" ");
            builder.Append(" ]");
            builder.Append("\n");
            return builder.ToString();
        }

19 View Source File : JmdictEntity.cs
License : Apache License 2.0
Project Creator : AnkiUniversal

private static string MergeEntriesForDatabaseAccess(List<JmdictEnreplacedy> entries)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append('(');
            for (int i = 0; i < entries.Count - 1; i++)
            {
                builder.Append(entries[i].EntrySequence);
                builder.Append(',');
            }
            builder.Append(entries[entries.Count - 1].EntrySequence);
            builder.Append(')');
            return builder.ToString();
        }

See More Examples