Release() public static méthode

public static Release ( StringBuilder sb ) : void
sb StringBuilder
Résultat void
    public static string EncodeNonAsciiCharacters(this string value)
    {
        var  bytes            = Encoding.Unicode.GetBytes(value);
        var  sb               = StringBuilderCache.Acquire(value.Length);
        bool encodedsomething = false;

        for (int i = 0; i < bytes.Length; i += 2)
        {
            var c = BitConverter.ToUInt16(bytes, i);
            if ((c >= 0x20 && c <= 0x7f) || c == 0x0A || c == 0x0D)
            {
                sb.Append((char)c);
            }
            else
            {
                sb.Append($"\\u{c:x4}");
                encodedsomething = true;
            }
        }
        if (!encodedsomething)
        {
            StringBuilderCache.Release(sb);
            return(value);
        }
        return(StringBuilderCache.GetStringAndRelease(sb));
    }
Exemple #2
0
    static public void ComputeAssetBundlesMD5(string path, string target)
    {
        var filter    = @"*.manifest";
        int endLength = filter.Length - 1;
        var manifests = GetAllFiles(path, filter);
        var builder   = StringBuilderCache.Acquire(1024);

        for (int i = 0; i < manifests.Count; ++i)
        {
            var bundleName = manifests[i].Substring(path.Length, manifests[i].Length - path.Length).Replace('\\', '/');
            bundleName = bundleName.Remove(bundleName.Length - endLength, endLength);

            var fileName = System.IO.Path.GetFileNameWithoutExtension(manifests[i]);
            var filePath = System.IO.Path.GetDirectoryName(manifests[i]);

            var md5 = CommonFunction.GetMD5HashFromFile(System.IO.Path.Combine(filePath, fileName));
            if (i != manifests.Count - 1)
            {
                builder.AppendFormat("{0}|{1}\r\n", bundleName, md5);
            }
            else
            {
                builder.AppendFormat("{0}|{1}", bundleName, md5);
            }
            Debug.LogFormat("<color=#00ff00>{0}|{1}</color>", bundleName, md5);
        }
        var version = System.IO.Path.Combine(target, "VersionMd5File.txt");

        System.IO.File.WriteAllText(version, builder.ToString());
        StringBuilderCache.Release(builder);
    }
Exemple #3
0
            /// <summary>
            /// Normalize <paramref name="text"/> by <see cref="currentDescription"/>
            /// </summary>
            private string Normalize(string text)
            {
                var builder             = StringBuilderCache.Acquire();
                var currentIsWhiteSpace = false;

                foreach (var item in text)
                {
                    if (char.IsWhiteSpace(item))
                    {
                        currentIsWhiteSpace = true;
                    }
                    else
                    {
                        if (currentIsWhiteSpace)
                        {
                            currentIsWhiteSpace = false;
                            // NOTE: skip whitespaces if still doesn't add anything
                            if (HasAnyParts || builder.Length > 0)
                            {
                                builder.Append(' ');
                            }
                        }
                        builder.Append(item);
                    }
                }

                if (currentIsWhiteSpace)
                {
                    builder.Append(' ');
                }

                return(StringBuilderCache.Release(builder));
            }
Exemple #4
0
    internal static string ReplaceCaseless(this string str, string oldValue, string newValue)
    {
        var stringBuilder = StringBuilderCache.Acquire();

        try
        {
            var previousIndex = 0;
            var index         = str.IndexOf(oldValue, StringComparison.OrdinalIgnoreCase);
            while (index != -1)
            {
                stringBuilder.Append(str.Substring(previousIndex, index - previousIndex));
                stringBuilder.Append(newValue);
                index += oldValue.Length;

                previousIndex = index;
                index         = str.IndexOf(oldValue, index, StringComparison.OrdinalIgnoreCase);
            }
            stringBuilder.Append(str.Substring(previousIndex));

            return(stringBuilder.ToString());
        }
        finally
        {
            StringBuilderCache.Release(stringBuilder);
        }
    }
Exemple #5
0
        /// <inheritdoc cref="Format(LogEvent,TextWriter,IFormatProvider)"/>
        public static string Format(
            [NotNull] LogEvent @event,
            [CanBeNull] IFormatProvider formatProvider = null)
        {
            if (@event == null)
            {
                throw new ArgumentNullException(nameof(@event));
            }

            if (@event.MessageTemplate == null)
            {
                return(string.Empty);
            }

            if (!TemplateTokenizer.CanContainNamedTokens(@event.MessageTemplate))
            {
                return(@event.MessageTemplate);
            }

            var builder = StringBuilderCache.Acquire(@event.MessageTemplate.Length * 2);
            var writer  = new StringWriter(builder);

            FormatInternal(@event, writer, formatProvider);

            StringBuilderCache.Release(builder);

            return(builder.ToString());
        }
Exemple #6
0
	private void SVCInfo(IPEndPoint from)
	{
		var infoStr = StringBuilderCache.Acquire();
		
		int humans = 0;
		int count = 0;
		for(int i = 0; i < CConstVar.MAX_CLIENTS; i++){
			if(clients[i].state >= ClientState.CONNECTED){
				count++;
				if(clients[i].netChan.isBot){
					humans++;
				}
			}
		}
		infoStr.Append("infoResponse\n");
		infoStr.Append("\\").Append("challenge").Append("$").Append(CDataModel.CmdBuffer.Argv(1));
		infoStr.Append("\\").Append("protocol").Append("$").Append(CConstVar.Protocol);
		infoStr.Append("\\").Append("port").Append("$").Append(CConstVar.ServerPort);
		infoStr.Append("\\").Append("clients").Append("$").Append(count);
		infoStr.Append("\\").Append("humans").Append("$").Append(humans);
		infoStr.Append("\\").Append("hostname").Append("$").Append("test");
		infoStr.Append("\\").Append("gamename").Append("$").Append("moba");
		infoStr.Append("\\").Append("sv_maxclients").Append("$").Append(CConstVar.MAX_CLIENTS);
		infoStr.Append("\\").Append("minPing").Append("$").Append(CConstVar.minPing);
		infoStr.Append("\\").Append("maxPing").Append("$").Append(CConstVar.maxPing);
		infoStr.Append("\\").Append("serverID").Append("$").Append(CConstVar.serverID);

		CNetwork_Server.Instance.OutOfBandSend(NetSrc.SERVER, from, infoStr.ToString());

		StringBuilderCache.Release(infoStr);
	}
    public static string GetStringAndRelease(StringBuilder sb)
    {
        string arg_0C_0 = sb.ToString();

        StringBuilderCache.Release(sb);
        return(arg_0C_0);
    }
Exemple #8
0
        private string GetLocaleInfo(string localeName, LocaleStringData type)
        {
            Contract.Assert(localeName != null, "[CultureData.GetLocaleInfo] Expected localeName to be not be null");

            switch (type)
            {
            case LocaleStringData.NegativeInfinitySymbol:
                // not an equivalent in ICU; prefix the PositiveInfinitySymbol with NegativeSign
                return(GetLocaleInfo(localeName, LocaleStringData.NegativeSign) +
                       GetLocaleInfo(localeName, LocaleStringData.PositiveInfinitySymbol));
            }

            StringBuilder sb = StringBuilderCache.Acquire(ICU_ULOC_KEYWORD_AND_VALUES_CAPACITY);

            bool result = Interop.GlobalizationInterop.GetLocaleInfoString(localeName, (uint)type, sb, sb.Capacity);

            if (!result)
            {
                // Failed, just use empty string
                StringBuilderCache.Release(sb);
                Contract.Assert(false, "[CultureData.GetLocaleInfo(LocaleStringData)] Failed");
                return(String.Empty);
            }
            return(StringBuilderCache.GetStringAndRelease(sb));
        }
    public static string GetStringAndRelease(StringBuilder sb)
    {
        string result = sb.ToString();

        StringBuilderCache.Release(sb);
        return(result);
    }
        protected static string BuildMessage(string desc, string message, Type type, string param, string caller, int line, string file)
        {
            var sb = StringBuilderCache.Take(64 + message != null ? message.Length : 0);

            sb.Append(desc);
            if (message.IsNotWhitespace())
            {
                sb.Append(message);
            }
            if (type != null)
            {
                sb.AppendLine().Append(" | Type: ").Append(type.Name);
            }
            if (param.IsNotWhitespace())
            {
                sb.Append(" | Param: ").Append(param);
            }
            if (caller.IsNotWhitespace())
            {
                sb.Append(" | Method: ").Append(caller);
            }
            if (line > 0)
            {
                sb.Append(" | Line: ").Append(line);
            }
            if (file.IsNotWhitespace())
            {
                sb.AppendLine().Append(" | File: ").Append(file);
            }
            return(StringBuilderCache.Release(ref sb));
        }
Exemple #11
0
        public static string GetStringAndRelease(StringBuilder sb)
        {
            string @string = sb.ToString();

            StringBuilderCache.Release(sb);
            return(@string);
        }
Exemple #12
0
        public static string ReplaceSpans(string script, IEnumerable <KeyValuePair <Span, string> > worklist)
        {
            Contracts.AssertValue(script);
            Contracts.AssertValue(worklist);

            StringBuilder sb = null;

            try
            {
                sb = StringBuilderCache.Acquire(script.Length);
                int index = 0;

                foreach (var pair in worklist.OrderBy(kvp => kvp.Key.Min))
                {
                    sb.Append(script, index, pair.Key.Min - index);
                    sb.Append(pair.Value);
                    index = pair.Key.Lim;
                }

                if (index < script.Length)
                {
                    sb.Append(script, index, script.Length - index);
                }

                return(sb.ToString());
            }
            finally
            {
                if (sb != null)
                {
                    StringBuilderCache.Release(sb);
                }
            }
        }
Exemple #13
0
        private readonly List <int> _rules;      // negative -> group #, positive -> string #

        /// <summary>
        /// Since RegexReplacement shares the same parser as Regex,
        /// the constructor takes a RegexNode which is a concatenation
        /// of constant strings and backreferences.
        /// </summary>
        public RegexReplacement(string rep, RegexNode concat, Hashtable _caps)
        {
            if (concat.Type() != RegexNode.Concatenate)
            {
                throw new ArgumentException(SR.ReplacementError);
            }

            StringBuilder sb      = StringBuilderCache.Acquire();
            List <string> strings = new List <string>();
            List <int>    rules   = new List <int>();

            for (int i = 0; i < concat.ChildCount(); i++)
            {
                RegexNode child = concat.Child(i);

                switch (child.Type())
                {
                case RegexNode.Multi:
                    sb.Append(child.Str);
                    break;

                case RegexNode.One:
                    sb.Append(child.Ch);
                    break;

                case RegexNode.Ref:
                    if (sb.Length > 0)
                    {
                        rules.Add(strings.Count);
                        strings.Add(sb.ToString());
                        sb.Length = 0;
                    }
                    int slot = child.M;

                    if (_caps != null && slot >= 0)
                    {
                        slot = (int)_caps[slot];
                    }

                    rules.Add(-Specials - 1 - slot);
                    break;

                default:
                    throw new ArgumentException(SR.ReplacementError);
                }
            }

            if (sb.Length > 0)
            {
                rules.Add(strings.Count);
                strings.Add(sb.ToString());
            }

            StringBuilderCache.Release(sb);

            Pattern  = rep;
            _strings = strings;
            _rules   = rules;
        }
Exemple #14
0
        // DOM Level 2

        // Puts all XmlText nodes in the full depth of the sub-tree
        // underneath this XmlNode into a "normal" form where only
        // markup (e.g., tags, comments, processing instructions, CDATA sections,
        // and entity references) separates XmlText nodes, that is, there
        // are no adjacent XmlText nodes.
        public virtual void Normalize()
        {
            XmlNode       firstChildTextLikeNode = null;
            StringBuilder sb = StringBuilderCache.Acquire();

            for (XmlNode crtChild = this.FirstChild; crtChild != null;)
            {
                XmlNode nextChild = crtChild.NextSibling;
                switch (crtChild.NodeType)
                {
                case XmlNodeType.Text:
                case XmlNodeType.Whitespace:
                case XmlNodeType.SignificantWhitespace:
                {
                    sb.Append(crtChild.Value);
                    XmlNode winner = NormalizeWinner(firstChildTextLikeNode, crtChild);
                    if (winner == firstChildTextLikeNode)
                    {
                        this.RemoveChild(crtChild);
                    }
                    else
                    {
                        if (firstChildTextLikeNode != null)
                        {
                            this.RemoveChild(firstChildTextLikeNode);
                        }
                        firstChildTextLikeNode = crtChild;
                    }
                    break;
                }

                case XmlNodeType.Element:
                {
                    crtChild.Normalize();
                    goto default;
                }

                default:
                {
                    if (firstChildTextLikeNode != null)
                    {
                        firstChildTextLikeNode.Value = sb.ToString();
                        firstChildTextLikeNode       = null;
                    }
                    sb.Remove(0, sb.Length);
                    break;
                }
                }
                crtChild = nextChild;
            }
            if (firstChildTextLikeNode != null && sb.Length > 0)
            {
                firstChildTextLikeNode.Value = sb.ToString();
            }

            StringBuilderCache.Release(sb);
        }
Exemple #15
0
        private readonly List<Int32> _rules;    // negative -> group #, positive -> string #

        /// <summary>
        /// Since RegexReplacement shares the same parser as Regex,
        /// the constructor takes a RegexNode which is a concatenation
        /// of constant strings and backreferences.
        /// </summary>
        internal RegexReplacement(String rep, RegexNode concat, Dictionary<Int32, Int32> _caps)
        {
            if (concat.Type() != RegexNode.Concatenate)
                throw new ArgumentException(SR.ReplacementError);

            StringBuilder sb = StringBuilderCache.Acquire();
            List<String> strings = new List<String>();
            List<Int32> rules = new List<Int32>();

            for (int i = 0; i < concat.ChildCount(); i++)
            {
                RegexNode child = concat.Child(i);

                switch (child.Type())
                {
                    case RegexNode.Multi:
                        sb.Append(child._str);
                        break;

                    case RegexNode.One:
                        sb.Append(child._ch);
                        break;

                    case RegexNode.Ref:
                        if (sb.Length > 0)
                        {
                            rules.Add(strings.Count);
                            strings.Add(sb.ToString());
                            sb.Length = 0;
                        }
                        int slot = child._m;

                        if (_caps != null && slot >= 0)
                            slot = (int)_caps[slot];

                        rules.Add(-Specials - 1 - slot);
                        break;

                    default:
                        throw new ArgumentException(SR.ReplacementError);
                }
            }

            if (sb.Length > 0)
            {
                rules.Add(strings.Count);
                strings.Add(sb.ToString());
            }

            StringBuilderCache.Release(sb);

            _rep = rep;
            _strings = strings;
            _rules = rules;
        }
Exemple #16
0
        public void Free(ref StringBuilder sb)
        {
            var exchanged = Interlocked.Exchange(ref sb, null);

            if (exchanged == null)
            {
                return;
            }

            StringBuilderCache.Release(exchanged);
        }
Exemple #17
0
        public void Test3()
        {
            StringBuilder sb1 = StringBuilderCache.Acquire();
            StringBuilder sb2 = StringBuilderCache.Acquire();

            Assert.AreNotSame(sb1, sb2);
            StringBuilderCache.Release(ref sb1);
            StringBuilderCache.Release(ref sb2);

            Assert.IsNull(sb1);
            Assert.IsNull(sb2);
        }
    string ReadFirstLine()
    {
        var builder = StringBuilderCache.Acquire();

        try
        {
            do
            {
                var c = textReader.Read();
                if (c == -1)
                {
                    break;
                }

                if (c == '\r')
                {
                    var peek = textReader.Peek();
                    if (peek == -1)
                    {
                        NewLine = "\r";
                        break;
                    }

                    if (peek == '\n')
                    {
                        NewLine = "\r\n";
                    }
                    else
                    {
                        NewLine = "\r";
                    }

                    textReader.Read();
                    break;
                }

                if (c == '\n')
                {
                    NewLine = "\n";
                    break;
                }

                builder.Append((char)c);
            } while (true);

            return(builder.ToString());
        }
        finally
        {
            StringBuilderCache.Release(builder);
        }
    }
Exemple #19
0
    public void ConnectServer(ServerInfo server)
    {
        var str = StringBuilderCache.Acquire();

        str.Append("connect ");
        str.Append("\\protocol$").Append(CConstVar.Protocol);
        str.Append("\\qport$").Append(CConstVar.Qport);
        str.Append("\\challenge$").Append(CDataModel.Connection.challenge);
        str.Append("\\port$").Append(CConstVar.LocalPort);
        // str.Append("\\password$").Append(CConstVar.Protocol);
        CNetwork.Instance.OutOfBandSend(NetSrc.CLIENT, server.address, str.ToString());
        StringBuilderCache.Release(str);
    }
Exemple #20
0
        /// <inheritdoc cref="Format(TextWriter,object,string,IFormatProvider)"/>
        public static string Format(
            [CanBeNull] object value,
            [CanBeNull] string format = null,
            [CanBeNull] IFormatProvider formatProvider = null)
        {
            var builder = StringBuilderCache.Acquire(StringBuilderCapacity);
            var writer  = new StringWriter(builder);

            Format(writer, value, format, formatProvider);

            StringBuilderCache.Release(builder);

            return(builder.ToString());
        }
Exemple #21
0
	private void SVCStatus(IPEndPoint from)
	{
		var status = StringBuilderCache.Acquire();
		for(int i = 0; i < CConstVar.MAX_CLIENTS; i++){
			var cl = clients[i];
			if(cl.state >= ClientState.CONNECTED){
				var ps =  GetClientPlayer(cl);//cl.playerState;
				status.Append(ps.persistant[(int)PlayerStatePersistant.PERS_SCORE]).Append(" ").Append(cl.ping).Append(" ").Append(cl.name);
			}
		}

		CNetwork_Server.Instance.OutOfBandSend(NetSrc.SERVER, from, string.Format("statusResponse\n%s\n%s", "\\infostring$", status.ToString()));
		StringBuilderCache.Release(status);
	}
        public async Task <(string?errorMessage, JsonValue?value)> TryParseAsync(TextReader stream, CancellationToken token)
        {
            var buffer  = StringBuilderCache.Acquire();
            var scratch = SmallBufferCache.Acquire(1);

            string?errorMessage = null;

            while (stream.Peek() != -1)
            {
                if (token.IsCancellationRequested)
                {
                    errorMessage = "Parsing incomplete. The task was cancelled.";
                    break;
                }

                var c = (char)stream.Peek();
                if (char.IsWhiteSpace(c) || c == ',' || c == ']' || c == '}')
                {
                    break;
                }

                await stream.TryRead(scratch, 0, 1, token);                 // eat the character

                if (!_IsNumberChar(c))
                {
                    errorMessage = "Expected ',', ']', or '}'.";
                    break;
                }

                buffer.Append(c);
            }

            SmallBufferCache.Release(scratch);

            if (errorMessage != null)
            {
                StringBuilderCache.Release(buffer);
                return(errorMessage, null);
            }

            var result = StringBuilderCache.GetStringAndRelease(buffer);

            if (!double.TryParse(result, NumberStyles.Any, CultureInfo.InvariantCulture, out double dbl))
            {
                return($"Value not recognized: '{result}'", null);
            }

            return(null, dbl);
        }
Exemple #23
0
        internal static bool GetLocaleName(string localeName, out string windowsName)
        {
            // Get the locale name from ICU
            StringBuilder sb = StringBuilderCache.Acquire(ICU_ULOC_FULLNAME_CAPACITY);

            if (!Interop.GlobalizationInterop.GetLocaleName(localeName, sb, sb.Capacity))
            {
                StringBuilderCache.Release(sb);
                windowsName = null;
                return(false); // fail
            }

            // Success - use the locale name returned which may be different than realNameBuffer (casing)
            windowsName = StringBuilderCache.GetStringAndRelease(sb); // the name passed to subsequent ICU calls
            return(true);
        }
        public ICollection <ClassificationSettings> MigrateClassifications(
            string language, ICollection <ClassificationSettings> classificationSettings)
        {
            if (!language.EqualsNoCase(Languages.CSharp))
            {
                return(classificationSettings);
            }

            // NOTE: -> 2.3.0: Migrates a csharp classifications name from "{Some name}" to "CoCo csharp {some name}"

            string PatchName(string name)
            {
                if (name.Length < 13)
                {
                    return(name);
                }

                var builder = StringBuilderCache.Acquire();

                builder.Append(char.ToUpper(name[12]));
                for (int i = 13; i < name.Length; ++i)
                {
                    builder.Append(name[i]);
                }
                return(StringBuilderCache.Release(builder));
            }

            var classifications = new Dictionary <string, Settings.ClassificationSettings>();

            foreach (var item in classificationSettings)
            {
                classifications[item.Name] = item;
            }

            foreach (var name in CSharpNames.All)
            {
                var oldName = PatchName(name);
                if (!classifications.ContainsKey(name) &&
                    classifications.TryGetValue(oldName, out var classification))
                {
                    classification.Name      = name;
                    classifications[oldName] = classification;
                }
            }
            return(classifications.Values.ToList());
        }
Exemple #25
0
    public string GetLines()
    {
        if (builder == null)
        {
            return(string.Empty);
        }

        try
        {
            builder.TrimEnd();
            return(builder.ToString());
        }
        finally
        {
            StringBuilderCache.Release(builder);
        }
    }
Exemple #26
0
        private string GetTimeFormatString(bool shortFormat)
        {
            Contract.Assert(this.sWindowsName != null, "[CultureData.GetTimeFormatString(bool shortFormat)] Expected this.sWindowsName to be populated already");

            StringBuilder sb = StringBuilderCache.Acquire(ICU_ULOC_KEYWORD_AND_VALUES_CAPACITY);

            bool result = Interop.GlobalizationInterop.GetLocaleTimeFormat(this.sWindowsName, shortFormat, sb, sb.Capacity);

            if (!result)
            {
                // Failed, just use empty string
                StringBuilderCache.Release(sb);
                Contract.Assert(false, "[CultureData.GetTimeFormatString(bool shortFormat)] Failed");
                return(String.Empty);
            }
            return(StringBuilderCache.GetStringAndRelease(sb));
        }
Exemple #27
0
    protected string getDeclareCode()
    {
        string        ret           = string.Empty;
        StringBuilder stringBuilder = StringBuilderCache.Acquire();

        for (int i = 0; i < mDeclareCodeGUI.Count; ++i)
        {
            stringBuilder.Append(mDeclareCodeGUI[i]);
            if (i != mDeclareCodeGUI.Count - 1)
            {
                stringBuilder.Append("\r\n");
            }
        }
        ret = stringBuilder.ToString();
        StringBuilderCache.Release(stringBuilder);
        return(ret);
    }
        private static ITemplateToken ConsumeText(string template, int offset, out int next)
        {
            var beginning = offset;
            var builder   = StringBuilderCache.Acquire(Math.Max(4, template.Length - offset));

            do
            {
                var currentCharacter = template[offset];
                if (currentCharacter == OpeningBrace)
                {
                    // (iloktionov): When we encounter an opening brace:
                    // (iloktionov): 1. If the next symbol is also an opening brace, we consume it as text (escaping).
                    // (iloktionov): 2. If the next symbol is something different, we end the text token and try to parse a named token.
                    if (offset + 1 < template.Length && template[offset + 1] == OpeningBrace)
                    {
                        builder.Append(currentCharacter);
                        offset++;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    builder.Append(currentCharacter);

                    // (iloktionov): Handle escaping with double braces:
                    if (currentCharacter == ClosingBrace)
                    {
                        if (offset + 1 < template.Length && template[offset + 1] == ClosingBrace)
                        {
                            offset++;
                        }
                    }
                }

                offset++;
            } while (offset < template.Length);

            next = offset;

            StringBuilderCache.Release(builder);

            return(CreateTextToken(template, beginning, offset - beginning, builder));
        }
Exemple #29
0
        // Gets an error message for a Win32 error code.
        internal static String GetMessage(int errorCode)
        {
            StringBuilder sb     = StringBuilderCache.Acquire(512);
            int           result = Win32Native.FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS |
                                                             FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY,
                                                             IntPtr.Zero, errorCode, 0, sb, sb.Capacity, IntPtr.Zero);

            if (result != 0)
            {
                // result is the # of characters copied to the StringBuilder.
                return(StringBuilderCache.GetStringAndRelease(sb));
            }
            else
            {
                StringBuilderCache.Release(sb);
                return(SR.Format(SR.UnknownError_Num, errorCode));
            }
        }
Exemple #30
0
        /// <summary>Main method called from TimeSpan.TryFormat.</summary>
        internal static bool TryFormat(TimeSpan value, Span <char> destination, out int charsWritten, string format, IFormatProvider formatProvider)
        {
            StringBuilder sb = FormatToBuilder(value, format, formatProvider);

            if (sb.Length <= destination.Length)
            {
                charsWritten = sb.Length;
                sb.CopyTo(0, destination, sb.Length);
                StringBuilderCache.Release(sb);
                return(true);
            }
            else
            {
                StringBuilderCache.Release(sb);
                charsWritten = 0;
                return(false);
            }
        }