{
public class EventLogRecord : EventRecord
{
- private const int SYSTEM_PROPERTY_COUNT = 18;
private readonly EventLogSession _session;
private readonly NativeWrapper.SystemProperties _systemProperties;
{
if (_systemProperties.filled == false)
{
- NativeWrapper.EvtRenderBufferWithContextSystem(_session.renderContextHandleSystem, Handle, UnsafeNativeMethods.EvtRenderFlags.EvtRenderEventValues, _systemProperties, SYSTEM_PROPERTY_COUNT);
+ NativeWrapper.EvtRenderBufferWithContextSystem(_session.renderContextHandleSystem, Handle, UnsafeNativeMethods.EvtRenderFlags.EvtRenderEventValues, _systemProperties);
_systemProperties.filled = true;
}
}
}
}
- public static void EvtRenderBufferWithContextSystem(EventLogHandle contextHandle, EventLogHandle eventHandle, UnsafeNativeMethods.EvtRenderFlags flag, SystemProperties systemProperties, int SYSTEM_PROPERTY_COUNT)
+ public static void EvtRenderBufferWithContextSystem(EventLogHandle contextHandle, EventLogHandle eventHandle, UnsafeNativeMethods.EvtRenderFlags flag, SystemProperties systemProperties)
{
IntPtr buffer = IntPtr.Zero;
IntPtr pointer = IntPtr.Zero;
if (!status)
EventLogException.Throw(win32Error);
- if (propCount != SYSTEM_PROPERTY_COUNT)
- throw new InvalidOperationException("We do not have " + SYSTEM_PROPERTY_COUNT + " variants given for the UnsafeNativeMethods.EvtRenderFlags.EvtRenderEventValues flag. (System Properties)");
-
pointer = buffer;
// Read each Variant structure
for (int i = 0; i < propCount; i++)
case (int)UnsafeNativeMethods.EvtSystemPropertyId.EvtSystemVersion:
systemProperties.Version = (byte?)ConvertToObject(varVal, UnsafeNativeMethods.EvtVariantType.EvtVarTypeByte);
break;
+ default:
+ Debug.Fail($"Do not understand EVT_SYSTEM_PROPERTY_ID {i}. A new case is needed.");
+ break;
}
pointer = new IntPtr(((long)pointer + Marshal.SizeOf(varVal)));
}