コード例 #1
0
ファイル: HttpUtilities.cs プロジェクト: tarynt/AspNetCore
    private static string GetMasksSection(List <MethodInfo> methodsInfo)
    {
        var distinctLengths = methodsInfo.Select(m => m.MaskLength).Distinct().ToList();

        distinctLengths.Sort((t1, t2) => - t1.CompareTo(t2));

        var result = new StringBuilder();

        for (var index = 0; index < distinctLengths.Count; index++)
        {
            var maskBytesLength = distinctLengths[index];
            var maskArray       = GetMaskArray(maskBytesLength);

            var hexMaskString = HttpUtilitiesGeneratorHelpers.GeHexString(maskArray, "0x", ", ");
            var maskFieldName = GetMaskFieldName(maskBytesLength);

            result.AppendFormat(CultureInfo.InvariantCulture, "        private static readonly ulong {0} = GetMaskAsLong(new byte[]\r\n            {{{1}}});", maskFieldName, hexMaskString);
            result.AppendLine();
            if (index < distinctLengths.Count - 1)
            {
                result.AppendLine();
            }
        }

        return(result.ToString());
    }