public SyncResultsHandlerAdapter(ObjectStreamHandler target)
 {
     _target = target;
 }
Exemple #2
0
 /// <summary>
 /// Handles a stream response until the end of the stream
 /// </summary>
 private static void HandleStreamResponse(RemoteFrameworkConnection connection, ObjectStreamHandler streamHandler)
 {
     Object response;
     bool handleMore = true;
     while (true)
     {
         response = connection.ReadObject();
         if (response is OperationResponsePart)
         {
             OperationResponsePart part = (OperationResponsePart)response;
             if (part.Exception != null)
             {
                 throw part.Exception;
             }
             object obj =
                 part.Result;
             if (handleMore)
             {
                 handleMore = streamHandler.Handle(obj);
             }
         }
         else if (response is OperationResponsePause)
         {
             if (handleMore)
             {
                 connection.WriteObject(new OperationRequestMoreData());
             }
             else
             {
                 connection.WriteObject(new OperationRequestStopData());
             }
         }
         else if (response is OperationResponseEnd)
         {
             break;
         }
         else
         {
             throw new ConnectorException("Unexpected response: " + response);
         }
     }
 }
 public static Object AdaptFromObjectStreamHandler(Type interfaceType,
     ObjectStreamHandler target)
 {
     if (interfaceType.Equals(typeof(ResultsHandler)))
     {
         return new ResultsHandlerAdapter(target).ResultsHandler;
     }
     else if (interfaceType.Equals(typeof(SyncResultsHandler)))
     {
         return new SyncResultsHandlerAdapter(target).SyncResultsHandler;
     }
     else
     {
         throw new InvalidOperationException("Unhandled case: " + interfaceType);
     }
 }
        /// <summary>
        /// Handles a stream response until the end of the stream
        /// </summary>
        private static void HandleStreamResponse(RemoteFrameworkConnection connection, ObjectStreamHandler streamHandler)
        {
            Object response;
            bool   handleMore = true;

            while (true)
            {
                response = connection.ReadObject();
                if (response is OperationResponsePart)
                {
                    OperationResponsePart part = (OperationResponsePart)response;
                    if (part.Exception != null)
                    {
                        throw part.Exception;
                    }
                    object obj =
                        part.Result;
                    if (handleMore)
                    {
                        handleMore = streamHandler.Handle(obj);
                    }
                }
                else if (response is OperationResponsePause)
                {
                    if (handleMore)
                    {
                        connection.WriteObject(new OperationRequestMoreData());
                    }
                    else
                    {
                        connection.WriteObject(new OperationRequestStopData());
                    }
                }
                else if (response is OperationResponseEnd)
                {
                    break;
                }
                else
                {
                    throw new ConnectorException("Unexpected response: " + response);
                }
            }
        }