context: // **********************************************************************
  //
  // Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved.
  //
  // This copy of Ice is licensed to you under the terms described in the
  // ICE_LICENSE file included in this distribution.
  //
  // **********************************************************************
  
  using System;
  using System.Diagnostics;
  using System.Threading;
  using System.Collections.Generic;
  using Test;
  
  public class TwowaysNewAMI
  {
      private static void test(bool b)
      {
          if(!b)
          {
              throw new System.SystemException();
          }
      }
  
      private class CallbackBase
      {
          internal CallbackBase()
          {
              _called = false;
          }
  
          public virtual void check()
          {
              _m.Lock();
              try
              {
                  while(!_called)
                  {
                      _m.Wait();
                  }
          
                  _called = false;
              }
              finally
              {
                  _m.Unlock();
              }
          }
  
          public virtual void called()
          {
              _m.Lock();
              try
              {
                  Debug.Assert(!_called);
                  _called = true;
                  _m.Notify();
              }
              finally
              {
                  _m.Unlock();
              }
          }
  
          private bool _called;
          private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
      }
  
      private class Callback
      {
          public void opAByteSI(Ice.AsyncResult result)
          {
              byte[] i = (byte[])result.AsyncState;
              byte[] o;
              byte[] r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opAByteS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opLByteSI(Ice.AsyncResult result)
          {
              List<byte> i = (List<byte>)result.AsyncState;
              List<byte> o;
              List<byte> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opLByteS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opKByteSI(Ice.AsyncResult result)
          {
              LinkedList<byte> i = (LinkedList<byte>)result.AsyncState;
              LinkedList<byte> o;
              LinkedList<byte> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opKByteS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opQByteSI(Ice.AsyncResult result)
          {
              Queue<byte> i = (Queue<byte>)result.AsyncState;
              Queue<byte> o;
              Queue<byte> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opQByteS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opSByteSI(Ice.AsyncResult result)
          {
              Stack<byte> i = (Stack<byte>)result.AsyncState;
              Stack<byte> o;
              Stack<byte> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opSByteS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opCByteSI(Ice.AsyncResult result)
          {
              CByteS i = (CByteS)result.AsyncState;
              CByteS o;
              CByteS r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opCByteS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opABoolSI(Ice.AsyncResult result)
          {
              bool[] i = (bool[])result.AsyncState;
              bool[] o;
              bool[] r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opABoolS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opLBoolSI(Ice.AsyncResult result)
          {
              List<bool> i = (List<bool>)result.AsyncState;
              List<bool> o;
              List<bool> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opLBoolS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opKBoolSI(Ice.AsyncResult result)
          {
              LinkedList<bool> i = (LinkedList<bool>)result.AsyncState;
              LinkedList<bool> o;
              LinkedList<bool> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opKBoolS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opQBoolSI(Ice.AsyncResult result)
          {
              Queue<bool> i = (Queue<bool>)result.AsyncState;
              Queue<bool> o;
              Queue<bool> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opQBoolS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opSBoolSI(Ice.AsyncResult result)
          {
              Stack<bool> i = (Stack<bool>)result.AsyncState;
              Stack<bool> o;
              Stack<bool> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opSBoolS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opCBoolSI(Ice.AsyncResult result)
          {
              CBoolS i = (CBoolS)result.AsyncState;
              CBoolS o;
              CBoolS r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opCBoolS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opAShortSI(Ice.AsyncResult result)
          {
              short[] i = (short[])result.AsyncState;
              short[] o;
              short[] r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opAShortS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opLShortSI(Ice.AsyncResult result)
          {
              List<short> i = (List<short>)result.AsyncState;
              List<short> o;
              List<short> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opLShortS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opKShortSI(Ice.AsyncResult result)
          {
              LinkedList<short> i = (LinkedList<short>)result.AsyncState;
              LinkedList<short> o;
              LinkedList<short> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opKShortS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opQShortSI(Ice.AsyncResult result)
          {
              Queue<short> i = (Queue<short>)result.AsyncState;
              Queue<short> o;
              Queue<short> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opQShortS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opSShortSI(Ice.AsyncResult result)
          {
              Stack<short> i = (Stack<short>)result.AsyncState;
              Stack<short> o;
              Stack<short> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opSShortS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opCShortSI(Ice.AsyncResult result)
          {
              CShortS i = (CShortS)result.AsyncState;
              CShortS o;
              CShortS r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opCShortS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opAIntSI(Ice.AsyncResult result)
          {
              int[] i = (int[])result.AsyncState;
              int[] o;
              int[] r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opAIntS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opLIntSI(Ice.AsyncResult result)
          {
              List<int> i = (List<int>)result.AsyncState;
              List<int> o;
              List<int> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opLIntS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opKIntSI(Ice.AsyncResult result)
          {
              LinkedList<int> i = (LinkedList<int>)result.AsyncState;
              LinkedList<int> o;
              LinkedList<int> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opKIntS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opQIntSI(Ice.AsyncResult result)
          {
              Queue<int> i = (Queue<int>)result.AsyncState;
              Queue<int> o;
              Queue<int> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opQIntS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opSIntSI(Ice.AsyncResult result)
          {
              Stack<int> i = (Stack<int>)result.AsyncState;
              Stack<int> o;
              Stack<int> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opSIntS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opCIntSI(Ice.AsyncResult result)
          {
              CIntS i = (CIntS)result.AsyncState;
              CIntS o;
              CIntS r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opCIntS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opALongSI(Ice.AsyncResult result)
          {
              long[] i = (long[])result.AsyncState;
              long[] o;
              long[] r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opALongS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opLLongSI(Ice.AsyncResult result)
          {
              List<long> i = (List<long>)result.AsyncState;
              List<long> o;
              List<long> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opLLongS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opKLongSI(Ice.AsyncResult result)
          {
              LinkedList<long> i = (LinkedList<long>)result.AsyncState;
              LinkedList<long> o;
              LinkedList<long> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opKLongS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opQLongSI(Ice.AsyncResult result)
          {
              Queue<long> i = (Queue<long>)result.AsyncState;
              Queue<long> o;
              Queue<long> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opQLongS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opSLongSI(Ice.AsyncResult result)
          {
              Stack<long> i = (Stack<long>)result.AsyncState;
              Stack<long> o;
              Stack<long> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opSLongS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opCLongSI(Ice.AsyncResult result)
          {
              CLongS i = (CLongS)result.AsyncState;
              CLongS o;
              CLongS r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opCLongS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opAFloatSI(Ice.AsyncResult result)
          {
              float[] i = (float[])result.AsyncState;
              float[] o;
              float[] r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opAFloatS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opLFloatSI(Ice.AsyncResult result)
          {
              List<float> i = (List<float>)result.AsyncState;
              List<float> o;
              List<float> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opLFloatS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opKFloatSI(Ice.AsyncResult result)
          {
              LinkedList<float> i = (LinkedList<float>)result.AsyncState;
              LinkedList<float> o;
              LinkedList<float> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opKFloatS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opQFloatSI(Ice.AsyncResult result)
          {
              Queue<float> i = (Queue<float>)result.AsyncState;
              Queue<float> o;
              Queue<float> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opQFloatS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opSFloatSI(Ice.AsyncResult result)
          {
              Stack<float> i = (Stack<float>)result.AsyncState;
              Stack<float> o;
              Stack<float> r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opSFloatS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opCFloatSI(Ice.AsyncResult result)
          {
              CFloatS i = (CFloatS)result.AsyncState;
              CFloatS o;
              CFloatS r = MyClassPrxHelper.uncheckedCast(result.getProxy()).end_opCFloatS(out o, result);
              test(Ice.CollectionComparer.Equals(i, o));
              test(Ice.CollectionComparer.Equals(i, r));
              callback.called();
          }
  
          public void opADoubleSI(Ice.AsyncResult result)
          {
  
gt:             double[] i = (double[])result.AsyncState;