in sources/Google.Solutions.IapDesktop.Extensions.Management/Auditing/Events/EventFactory.cs [92:136]
public static EventBase FromRecord(LogRecord record)
{
if (!record.IsValidAuditLogRecord)
{
throw new ArgumentException("Not a valid audit log record");
}
if (record.ProtoPayload?.MethodName != null &&
lifecycleEvents.TryGetValue(record.ProtoPayload.MethodName, out var lcFunc))
{
var e = lcFunc(record);
Debug.Assert(e.Category == EventCategory.Lifecycle);
return e;
}
else if (record.ProtoPayload?.MethodName != null &&
systemEvents.TryGetValue(record.ProtoPayload.MethodName, out var sysFunc))
{
var e = sysFunc(record);
Debug.Assert(e.Category == EventCategory.System);
return e;
}
else if (record.ProtoPayload?.MethodName != null &&
accessEvents.TryGetValue(record.ProtoPayload.MethodName, out var accessFunc))
{
var e = accessFunc(record);
Debug.Assert(e.Category == EventCategory.Access);
return e;
}
else if (record.IsSystemEvent)
{
//
// There are some less common/more esoteric system events that do not
// have a wrapper class. Map these to GenericSystemEvent.
//
return new GenericSystemEvent(record);
}
else
{
//
// The list of activity event types is incomplete any might grow stale over time,
// so ensure to fail open.
//
return new UnknownEvent(record);
}
}