Exemple #1
0
        private static void AppendArg(StringBuffer stringBuffer, ref byte *argPointer, ArgumentType argumentType, StringView format, string[] strings, IntPtr[] argPointers, int argCount)
        {
            switch (argumentType)
            {
            case ArgumentType.String:
                var stringIndex = *argPointer;
                stringBuffer.Append(strings[stringIndex]);
                argPointer += sizeof(byte);
                break;

            case ArgumentType.AsciiString:
                var length = *(int *)argPointer;
                argPointer += sizeof(int);
                stringBuffer.Append(new AsciiString(argPointer, length));
                argPointer += length;
                break;

            case ArgumentType.Boolean:
                stringBuffer.Append(*(bool *)argPointer);
                argPointer += sizeof(bool);
                break;

            case ArgumentType.Byte:
                stringBuffer.Append(*argPointer, format);
                argPointer += sizeof(byte);
                break;

            case ArgumentType.Char:
                stringBuffer.Append(*(char *)argPointer);
                argPointer += sizeof(char);
                break;

            case ArgumentType.Int16:
                stringBuffer.Append(*(short *)argPointer, format);
                argPointer += sizeof(short);
                break;

            case ArgumentType.Int32:
                stringBuffer.Append(*(int *)argPointer, format);
                argPointer += sizeof(int);
                break;

            case ArgumentType.Int64:
                stringBuffer.Append(*(long *)argPointer, format);
                argPointer += sizeof(long);
                break;

            case ArgumentType.Single:
                stringBuffer.Append(*(float *)argPointer, format);
                argPointer += sizeof(float);
                break;

            case ArgumentType.Double:
                stringBuffer.Append(*(double *)argPointer, format);
                argPointer += sizeof(double);
                break;

            case ArgumentType.Decimal:
                stringBuffer.Append(*(decimal *)argPointer, format);
                argPointer += sizeof(decimal);
                break;

            case ArgumentType.Guid:
                stringBuffer.Append(*(Guid *)argPointer, format);
                argPointer += sizeof(Guid);
                break;

            case ArgumentType.DateTime:
                stringBuffer.Append(*(DateTime *)argPointer, format);
                argPointer += sizeof(DateTime);
                break;

            case ArgumentType.TimeSpan:
                stringBuffer.Append(*(TimeSpan *)argPointer, format);
                argPointer += sizeof(TimeSpan);
                break;

            case ArgumentType.FormatString:
                var formatStringIndex = *argPointer++;
                var argOffset         = *argPointer++;
                var argSet            = new ArgSet(argPointers, strings, argOffset, argCount);
                stringBuffer.AppendArgSet(strings[formatStringIndex], ref argSet);
                argPointer += argSet.BytesRead;
                break;

            case ArgumentType.Enum:
                var enumArg = (EnumArg *)argPointer;
                argPointer += sizeof(EnumArg);
                enumArg->AppendTo(stringBuffer);
                break;

            case ArgumentType.Null:
                stringBuffer.Append(LogManager.Config.NullDisplayString);
                break;

            case ArgumentType.Unmanaged:
                var unmanagedArgHeader = (UnmanagedArgHeader *)argPointer;
                argPointer += sizeof(UnmanagedArgHeader);
                unmanagedArgHeader->AppendTo(stringBuffer, argPointer, format);
                argPointer += unmanagedArgHeader->Size;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        private static void AppendArg(StringBuffer stringBuffer, ref byte *argPointer, ArgumentType argumentType, StringView format, List <string> strings, List <IntPtr> argPointers)
        {
            switch (argumentType)
            {
            case ArgumentType.String:
                var stringIndex = *argPointer;
                stringBuffer.Append(strings[stringIndex]);
                argPointer += sizeof(byte);
                break;

            case ArgumentType.AsciiString:
                var length = *(int *)argPointer;
                argPointer += sizeof(int);
                stringBuffer.Append(new AsciiString(argPointer, length));
                argPointer += length;
                break;

            case ArgumentType.Boolean:
                stringBuffer.Append(*(bool *)argPointer);
                argPointer += sizeof(bool);
                break;

            case ArgumentType.Byte:
                stringBuffer.Append(*argPointer, format);
                argPointer += sizeof(byte);
                break;

            case ArgumentType.Char:
                stringBuffer.Append(*(char *)argPointer);
                argPointer += sizeof(char);
                break;

            case ArgumentType.Int16:
                stringBuffer.Append(*(short *)argPointer, format);
                argPointer += sizeof(short);
                break;

            case ArgumentType.Int32:
                stringBuffer.Append(*(int *)argPointer, format);
                argPointer += sizeof(int);
                break;

            case ArgumentType.Int64:
                stringBuffer.Append(*(long *)argPointer, format);
                argPointer += sizeof(long);
                break;

            case ArgumentType.Single:
                stringBuffer.Append(*(float *)argPointer, format);
                argPointer += sizeof(float);
                break;

            case ArgumentType.Double:
                stringBuffer.Append(*(double *)argPointer, format);
                argPointer += sizeof(double);
                break;

            case ArgumentType.Decimal:
                stringBuffer.Append(*(decimal *)argPointer, format);
                argPointer += sizeof(decimal);
                break;

            case ArgumentType.Guid:
                stringBuffer.Append(*(Guid *)argPointer, format);
                argPointer += sizeof(Guid);
                break;

            case ArgumentType.DateTime:
                stringBuffer.Append(*(DateTime *)argPointer, format);
                argPointer += sizeof(DateTime);
                break;

            case ArgumentType.TimeSpan:
                stringBuffer.Append(*(TimeSpan *)argPointer, format);
                argPointer += sizeof(TimeSpan);
                break;

            case ArgumentType.FormatString:
                var argSet = new ArgSet(argPointers, strings);
                stringBuffer.AppendArgSet(strings[*argPointer], ref argSet);
                argPointer += sizeof(byte) + argSet.BytesRead;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }