static void Main(string[] args) { // IChannelFactory<IMachineChannel> factory = new ChannelFactory<IMachineChannel>(new BasicHttpBinding()); // IMachineChannel channel = factory.CreateChannel(new EndpointAddress("http://localhost:8733/ServiceMachine/basic")); var channel = new MachineClient("basic"); try { string machineName = channel.GetMachineName(new MachineDTO { MachineID = "1", MachineName = "test" }); Console.WriteLine(machineName); Console.ReadLine(); channel.Close(); } catch (FaultException faultException) { channel.Abort(); Console.WriteLine(faultException.Message); } catch (CommunicationException communicationException) { channel.Abort(); Console.WriteLine(communicationException.Message); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldPackUnpackBytesHeaderWithCorrectBufferSize() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldPackUnpackBytesHeaderWithCorrectBufferSize() { Machine machine = new Machine(); PackStream.Packer packer = machine.Packer(); MachineClient client = new MachineClient(8); PackStream.Unpacker unpacker = client.Unpacker(); for (int size = 0; size <= 65536; size++) { machine.Reset(); packer.PackBytesHeader(size); packer.Flush(); // Then int bufferSize = ComputeOutputBufferSize(size, false); sbyte[] output = machine.Output(); assertThat(output.Length, equalTo(bufferSize)); client.Reset(output); int value = unpacker.UnpackBytesHeader(); assertThat(value, equalTo(size)); } }
static void Main(string[] args) { // IChannelFactory<IMachineChannel> factory = new ChannelFactory<IMachineChannel>(new BasicHttpBinding()); // IMachineChannel channel = factory.CreateChannel(new EndpointAddress("http://localhost:8733/ServiceMachine/basic")); var channel = new MachineClient("basic"); try { string machineName = channel.GetMachineName(new MachineDTO {MachineID = "1", MachineName = "test"}); Console.WriteLine(machineName); Console.ReadLine(); channel.Close(); } catch (FaultException faultException) { channel.Abort(); Console.WriteLine(faultException.Message); } catch(CommunicationException communicationException) { channel.Abort(); Console.WriteLine(communicationException.Message); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void shouldPackUnpackHeaderWithCorrectBufferSize(PackType type) throws Throwable private void ShouldPackUnpackHeaderWithCorrectBufferSize(PackType type) { Machine machine = new Machine(); PackStream.Packer packer = machine.Packer(); MachineClient client = new MachineClient(8); PackStream.Unpacker unpacker = client.Unpacker(); for (int size = 0; size <= 65536; size++) { machine.Reset(); switch (type) { case Org.Neo4j.Bolt.v1.packstream.PackType.Map: packer.PackMapHeader(size); break; case Org.Neo4j.Bolt.v1.packstream.PackType.List: packer.PackListHeader(size); break; case Org.Neo4j.Bolt.v1.packstream.PackType.String: packer.PackStringHeader(size); break; default: throw new System.ArgumentException("Unsupported type: " + type + "."); } packer.Flush(); int bufferSize = ComputeOutputBufferSize(size, true); sbyte[] output = machine.Output(); assertThat(output.Length, equalTo(bufferSize)); client.Reset(output); int value = 0; switch (type) { case Org.Neo4j.Bolt.v1.packstream.PackType.Map: value = ( int )unpacker.UnpackMapHeader(); break; case Org.Neo4j.Bolt.v1.packstream.PackType.List: value = ( int )unpacker.UnpackListHeader(); break; case Org.Neo4j.Bolt.v1.packstream.PackType.String: value = unpacker.UnpackStringHeader(); break; default: throw new System.ArgumentException("Unsupported type: " + type + "."); } assertThat(value, equalTo(size)); } }
static void Main(string[] args) { var channel = new MachineClient("basic"); channel.GetMachineNameCompleted+=ChannelOnGetMachineNameCompleted; channel.GetMachineNameAsync(new MachineDTO {MachineID = "1",MachineName = "async machine"}); Console.WriteLine("some other operation is going on ..."); Console.ReadLine(); }
private static void Main(string[] args) { MachineClient machineClient = new MachineClient(); machineClient.InitializeMachine(); machineClient.StartMachine(); //SodaMachine sodaMachine = new SodaMachine(); //sodaMachine.Start(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void unpackHeaderSizeGreaterThanIntMaxValue(PackType type) throws Throwable private void UnpackHeaderSizeGreaterThanIntMaxValue(PackType type) { sbyte marker32; switch (type) { case Org.Neo4j.Bolt.v1.packstream.PackType.Map: marker32 = PackStream.Map_32; break; case Org.Neo4j.Bolt.v1.packstream.PackType.List: marker32 = PackStream.List_32; break; case Org.Neo4j.Bolt.v1.packstream.PackType.String: marker32 = PackStream.String_32; break; case Org.Neo4j.Bolt.v1.packstream.PackType.Bytes: marker32 = PackStream.Bytes_32; break; default: throw new System.ArgumentException("Unsupported type: " + type + "."); } sbyte[] input = new sbyte[] { marker32, unchecked (( sbyte )0xff), unchecked (( sbyte )0xff), unchecked (( sbyte )0xff), unchecked (( sbyte )0xff) }; MachineClient client = new MachineClient(8); client.Reset(input); PackStream.Unpacker unpacker = client.Unpacker(); switch (type) { case Org.Neo4j.Bolt.v1.packstream.PackType.Map: unpacker.UnpackMapHeader(); break; case Org.Neo4j.Bolt.v1.packstream.PackType.List: unpacker.UnpackListHeader(); break; case Org.Neo4j.Bolt.v1.packstream.PackType.String: unpacker.UnpackStringHeader(); break; case Org.Neo4j.Bolt.v1.packstream.PackType.Bytes: unpacker.UnpackBytesHeader(); break; default: throw new System.ArgumentException("Unsupported type: " + type + "."); } }
static void Main(string[] args) { var channel = new MachineClient("basic"); channel.GetMachineNameCompleted += ChannelOnGetMachineNameCompleted; channel.GetMachineNameAsync(new MachineDTO { MachineID = "1", MachineName = "async machine" }); Console.WriteLine("some other operation is going on ..."); Console.ReadLine(); }
static void Main(string[] args) { ServiceEndpointCollection serviceEndpointCollection = MetadataResolver.Resolve(typeof(IMachine), new EndpointAddress("http://localhost:8080/ServiceMachine/mex")); foreach (var endpoint in serviceEndpointCollection) { var channel = new MachineClient(endpoint.Binding, endpoint.Address); string machineName = channel.GetMachineName(new MachineDTO { MachineID = "1", MachineName = "test" }); Console.WriteLine(machineName); Console.WriteLine(endpoint.Binding); } }