Specifications
152 CHAPTER 8 Complex Event Processing with StreamInsight
the elds one at a time and enqueue the event. The untyped output adapter works similarly,
but instead it must be able to use the conguration specication to retrieve query processing
results from a dequeued event.
The next step is to develop an AdapterFactory object as a container class for your input
and output adapters. You use an AdapterFactory object to share resources between adapter
implementations and to pass conguration parameters to adapter constructors. Recall that
an untyped adapter relies on the conguration specication to properly handle an event’s
payload structure. The adapter factory must implement the Create() and Dispose() methods
as shown in the following code example, which shows how to create adapters for events in a
text le:
public class TextFileInputFactory : IInputAdapterFactory<TextFileInputConfig>
{
public InputAdapterBase Create(TextFileInputConfig configInfo,
EventShape eventShape, CepEventType cepEventType)
{
InputAdapterBase adapter = default(InputAdapterBase);
if (eventShape == EventShape.Point)
{
adapter = new TextFilePointInput(configInfo, cepEventType);
}
else if (eventShape == EventShape.Interval)
{
adapter = new TextFileIntervalInput(configInfo, cepEventType);
}
else if (eventShape == EventShape.Edge)
{
adapter = new TextFileEdgeInput(configInfo, cepEventType);
}
else
{
throw new ArgumentException(
string.Format(CultureInfo.InvariantCulture,
"TextFileInputFactory cannot instantiate adapter with event shape {0}",
eventShape.ToString()));
}
return adapter;
}
public void Dispose()
{
}
}