System.Net.Http.Formatting.Internal.HttpValueCollection.AppendNameValuePair C# (CSharp) Method

AppendNameValuePair() private static method

private static AppendNameValuePair ( StringBuilder builder, bool first, bool urlEncode, string name, string value ) : bool
builder System.Text.StringBuilder
first bool
urlEncode bool
name string
value string
return bool
        private static bool AppendNameValuePair(StringBuilder builder, bool first, bool urlEncode, string name, string value)
        {
            string effectiveName = name ?? String.Empty;
            string encodedName = urlEncode ? UriQueryUtility.UrlEncode(effectiveName) : effectiveName;

            string effectiveValue = value ?? String.Empty;
            string encodedValue = urlEncode ? UriQueryUtility.UrlEncode(effectiveValue) : effectiveValue;

            if (first)
            {
                first = false;
            }
            else
            {
                builder.Append("&");
            }

            builder.Append(encodedName);
            if (!String.IsNullOrEmpty(encodedValue))
            {
                builder.Append("=");
                builder.Append(encodedValue);
            }
            return first;
        }