private TimeSeriesEventParser(Type eventType, TimeSeriesEventAttribute tsAttr, Regex regex, string prefix, UInt32 numericId) { _eventDataType = eventType; _regEx = regex; _prefix = prefix; _numericId = numericId; _timeSeries = MetadataHelper.SeriesDescriptorFromMetadata(eventType, tsAttr).ToList(); var firstTs = _timeSeries.First(); _classifierGroup = firstTs.ObjectIdFromGroup; _classifierFromObjectAddress = firstTs.ObjectIdFromAddress; }
public static IEnumerable <TimeSeriesDescriptor> SeriesDescriptorFromMetadata(Type t, TimeSeriesEventAttribute tsAttr) { var objectAttr = t.GetCustomAttributes(typeof(SourceAttribute), true).OfType <SourceAttribute>().FirstOrDefault(); var exampleLogLines = (from a in t.GetCustomAttributes(typeof(ExampleLineAttribute), true).OfType <ExampleLineAttribute>() select a.Value).ToList(); return(from f in t.GetFields() from a in f.GetCustomAttributes(typeof(TimeSeriesAttribute), true).OfType <TimeSeriesAttribute>() select new TimeSeriesDescriptor() { Name = a.Name == null ? f.Name : null, NameFromGroup = a.Name, ObjectType = tsAttr.Type, Unit = a.Unit, ExampleLogLines = exampleLogLines, Description = a.Description, Scale = a.Scale, Optional = a.Optional, From = a.From ?? f.Name, ObjectIdFromGroup = (objectAttr != null) ? objectAttr.From : null, ObjectIdFromAddress = (objectAttr != null) ? objectAttr.FromObjectAddress : false, }); }