private GenericEventParser(Type eventDataType, EventAttribute eAttr, Regex regex, string prefix, UInt32 numericId) { _eventDataType = eventDataType; _regEx = regex; _prefix = prefix; _numericId = numericId; _eventDescriptor = MetadataHelper.EventDescriptorFromMetadata(eventDataType, eAttr); var objectAttr = _eventDataType.GetCustomAttributes(typeof(SourceAttribute), true).OfType <SourceAttribute>().FirstOrDefault(); if (objectAttr != null) { _classifierGroup = objectAttr.From; _classifierFromObjectAddress = objectAttr.FromObjectAddress; } }
internal static EventDescriptor EventDescriptorFromMetadata(Type t, EventAttribute eAttr) { var result = new EventDescriptor() { Name = eAttr.Name, ObjectType = eAttr.Type, Description = eAttr.Description, ExampleLogLines = (from a in t.GetCustomAttributes(typeof(ExampleLineAttribute), true).OfType <ExampleLineAttribute>() select a.Value).ToList(), }; result.Fields = from f in t.GetFields() from a in f.GetCustomAttributes(typeof(EventFieldAttribute), true).OfType <EventFieldAttribute>() select new EventFieldDescriptor() { Field = f, Group = a.From, Converter = TypeDescriptor.GetConverter(f.FieldType), FromObjectAddress = a.FromObjectAddress }; return(result); }