Microsoft SQL Server 2008 R2 810-08234 User Manual

Product codes
810-08234
Page of 236
 152
 
CHAPTER 8 
Complex Event Processing with StreamInsight
the fields one at a time and enqueue the event. The untyped output adapter works similarly, 
but instead it must be able to use the configuration specification 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 configuration parameters to adapter constructors. Recall that 
an untyped adapter relies on the configuration specification 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 file:
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() 
      { 
      } 
}