You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ar...@apache.org on 2008/09/08 13:46:06 UTC

svn commit: r693060 [2/6] - in /incubator/qpid/trunk/qpid/dotnet/client-010: ./ client/ client/Properties/ client/client/ client/generated/ client/transport/ client/transport/codec/ client/transport/exception/ client/transport/network/ client/transport...

Added: incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/ProtocolError.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/ProtocolError.cs?rev=693060&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/ProtocolError.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/ProtocolError.cs Mon Sep  8 04:46:01 2008
@@ -0,0 +1,86 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+using System;
+using NetworkDelegate = org.apache.qpid.transport.network.NetworkDelegate;
+using NetworkEvent = org.apache.qpid.transport.network.NetworkEvent;
+
+namespace org.apache.qpid.transport
+{
+    /// <summary> 
+    /// ProtocolError
+    /// </summary>
+    public sealed class ProtocolError : NetworkEvent, ProtocolEvent
+    {
+        private int channel;
+        private byte track;
+        private String format;
+        private Object[] args;
+
+        public ProtocolError(byte track, String format, params Object[] args)
+        {
+            this.track = track;
+            this.format = format;
+            this.args = args;
+        }
+
+        #region NetworkEvent Methods
+
+        public void ProcessNetworkEvent(NetworkDelegate ndelegate)
+        {
+            ndelegate.Error(this);
+        }
+
+        #endregion
+
+        #region ProtocolEvent Methods
+
+        public int Channel
+        {
+            get { return channel; }
+            set { channel = value; }
+        }
+
+        public byte EncodedTrack
+        {
+            get { return track; }
+            set { throw new NotImplementedException(); }
+        }
+
+        public void ProcessProtocolEvent<C>(C context, ProtocolDelegate<C> protocoldelegate)
+        {
+            protocoldelegate.Error(context, this);
+        }
+
+        #endregion
+
+        public String Message
+        {
+            get { return String.Format(format, args); }
+        }
+
+
+        public String toString()
+        {
+            return String.Format("protocol error: {0}", Message);
+        }
+
+    }
+}
\ No newline at end of file

Added: incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/ProtocolEvent.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/ProtocolEvent.cs?rev=693060&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/ProtocolEvent.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/ProtocolEvent.cs Mon Sep  8 04:46:01 2008
@@ -0,0 +1,42 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+namespace org.apache.qpid.transport
+{
+    /// <summary> 
+    /// ProtocolEvent
+    /// </summary>
+    public interface ProtocolEvent
+    {
+        int Channel
+        {
+            get;
+            set;
+        }
+
+        byte EncodedTrack
+        {
+            set; 
+            get;
+        }
+
+        void ProcessProtocolEvent<C>(C context, ProtocolDelegate<C> protocoldelegate);  
+    }    
+}
\ No newline at end of file

Added: incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/ProtocolHeader.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/ProtocolHeader.cs?rev=693060&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/ProtocolHeader.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/ProtocolHeader.cs Mon Sep  8 04:46:01 2008
@@ -0,0 +1,125 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+using System;
+using System.IO;
+using System.Text;
+using NetworkDelegate = org.apache.qpid.transport.network.NetworkDelegate;
+using NetworkEvent = org.apache.qpid.transport.network.NetworkEvent;
+using Frame = org.apache.qpid.transport.network.Frame;
+
+namespace org.apache.qpid.transport
+{
+    /// <summary> ProtocolHeader
+    /// 
+    /// </summary>
+    public sealed class ProtocolHeader : NetworkEvent, ProtocolEvent
+    {
+        private readonly char[] AMQP = new char[] {'A', 'M', 'Q', 'P'};
+        private const byte CLASS = 1;
+
+        private readonly byte instance;
+        private readonly byte major;
+        private readonly byte minor;
+        private int channel;
+
+        public ProtocolHeader(byte instance, byte major, byte minor)
+        {
+            this.instance = instance;
+            this.major = major;
+            this.minor = minor;
+        }
+
+        public ProtocolHeader(int instance, int major, int minor) : this((byte)instance, (byte)major, (byte)minor)
+        {
+        }
+
+        #region NetworkEvent Methods
+
+        public void ProcessNetworkEvent(NetworkDelegate ndelegate)
+        {
+            ndelegate.Init(this);
+        }
+
+        #endregion
+
+        #region ProtocolEvent Methods
+
+        public int Channel
+        {
+            get
+            {
+                return channel;
+            }
+            set
+            {
+                channel = value;
+            }           
+        }
+
+        public byte EncodedTrack
+        {
+            get
+            {
+                return Frame.L1;
+            }
+            set { throw new NotImplementedException(); }
+        }
+
+        public void ProcessProtocolEvent<C>(C context, ProtocolDelegate<C> protocoldelegate)
+        {
+            protocoldelegate.Init(context, this);
+        }
+
+        #endregion
+
+        public byte Instance
+        {
+            get { return instance; }
+        }
+
+        public byte Major
+        {
+            get { return major; }
+        }
+
+        public byte Minor
+        {
+            get { return minor; }
+        }
+
+        public MemoryStream ToMemoryStream()
+        {
+            MemoryStream buf = new MemoryStream(8);
+            BinaryWriter writer = new BinaryWriter(buf);
+            writer.Write(AMQP);
+            writer.Write(CLASS);
+            writer.Write(instance);
+            writer.Write((sbyte) major);
+            writer.Write((sbyte) minor);
+            return buf;
+        }
+
+        public String toString()
+        {
+            return String.Format("AMQP.{0:d} {1:d}-{2:d}", instance, major, minor);
+        }
+    }
+}
\ No newline at end of file

Added: incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Range.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Range.cs?rev=693060&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Range.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Range.cs Mon Sep  8 04:46:01 2008
@@ -0,0 +1,117 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+using System;
+using System.Collections.Generic;
+using org.apache.qpid.transport.util;
+
+namespace org.apache.qpid.transport
+{
+	
+	/// <summary> 
+	/// Range
+	/// </summary>
+
+
+    public sealed class Range
+    {
+        private int lower;
+        private int upper;
+
+        public Range(int lower, int upper)
+        {
+            this.lower = lower;
+            this.upper = upper;
+        }
+
+        public int Lower
+        {
+            get { return lower; }
+            set { lower = value; }
+        }
+        public int Upper
+        {
+            get { return upper; }
+            set { upper = value; }
+        }
+
+        public bool includes(int value)
+        {
+            return Serial.le(lower, value) && Serial.le(value, upper);
+        }
+
+        public bool includes(Range range)
+        {
+            return includes(range.lower) && includes(range.upper);
+        }
+
+        public bool intersects(Range range)
+        {
+            return (includes(range.lower) || includes(range.upper) ||
+                    range.includes(lower) || range.includes(upper));
+        }
+
+        public bool touches(Range range)
+        {
+            return (intersects(range) ||
+                    includes(range.upper + 1) || includes(range.lower - 1) ||
+                    range.includes(upper + 1) || range.includes(lower - 1));
+        }
+
+        public Range span(Range range)
+        {
+            return new Range(Serial.min(lower, range.lower), Serial.max(upper, range.upper));
+        }
+
+        public List<Range> subtract(Range range)
+        {
+            List<Range> result = new List<Range>();
+
+            if (includes(range.lower) && Serial.le(lower, range.lower - 1))
+            {
+                result.Add(new Range(lower, range.lower - 1));
+            }
+
+            if (includes(range.upper) && Serial.le(range.upper + 1, upper))
+            {
+                result.Add(new Range(range.upper + 1, upper));
+            }
+
+            if (result.Count == 0 && !range.includes(this))
+            {
+                result.Add(this);
+            }
+
+            return result;
+        }
+
+        public Range intersect(Range range)
+        {
+            int l = Serial.max(lower, range.lower);
+            int r = Serial.min(upper, range.upper);
+            return Serial.gt(l, r) ? null : new Range(l, r);
+        }
+
+        public String toString()
+        {
+            return "[" + lower + ", " + upper + "]";
+        }
+    }
+}
\ No newline at end of file

Added: incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/RangeSet.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/RangeSet.cs?rev=693060&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/RangeSet.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/RangeSet.cs Mon Sep  8 04:46:01 2008
@@ -0,0 +1,153 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Text;
+using org.apache.qpid.transport.util;
+
+namespace org.apache.qpid.transport
+{
+	
+	
+	/// <summary> 
+    /// RangeSet
+	/// </summary>
+
+    public sealed class RangeSet : IEnumerable<Range> 
+	{
+		    private readonly LinkedList<Range> ranges = new LinkedList<Range>();
+
+	    IEnumerator IEnumerable.GetEnumerator()
+	    {
+	        return GetEnumerator();
+	    }
+
+	    public IEnumerator<Range> GetEnumerator()
+	    {
+	        return ranges.GetEnumerator();
+	    }
+
+
+	    public int size()
+    {
+	        return ranges.Count;
+    }
+
+   
+
+    public Range getFirst()
+    {
+        return ranges.First.Value;
+    }
+
+    public bool includes(Range range)
+    {
+        foreach (Range r in this)
+        {
+            if (r.includes(range))
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public bool includes(int n)
+    {
+        foreach (Range r in this)
+        {
+            if (r.includes(n))
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public void add(Range range)
+    {
+         foreach (Range r in ranges)
+        {
+            if (range.touches(r))
+            {
+                ranges.Remove(r);
+                range = range.span(r);
+            }
+            else if (Serial.lt(range.Upper, r.Lower ))
+            {                               
+                ranges.AddBefore(ranges.Find(r), range);
+                return;
+            }
+        }
+        ranges.AddLast(range);
+    }
+
+    public void add(int lower, int upper)
+    {
+        add(new Range(lower, upper));
+    }
+
+    public void add(int value)
+    {
+        add(value, value);
+    }
+
+    public void clear()
+    {
+        ranges.Clear();
+    }
+
+    public RangeSet copy()
+    {
+        RangeSet copy = new RangeSet();
+        foreach( Range r in ranges)
+        {
+            copy.ranges.AddLast(r);
+        }        
+        return copy;
+    }
+
+    public String toString()
+    {
+        StringBuilder str = new StringBuilder();
+        str.Append("{");
+        bool first = true;
+        foreach (Range range in ranges)
+        {
+            if (first)
+            {
+                first = false;
+            }
+            else
+            {
+                str.Append(", ");
+            }
+            str.Append(range);
+        }
+        str.Append("}");
+        return str.ToString();
+    }
+	}
+}
\ No newline at end of file

Added: incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/ReceivedPayload.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/ReceivedPayload.cs?rev=693060&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/ReceivedPayload.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/ReceivedPayload.cs Mon Sep  8 04:46:01 2008
@@ -0,0 +1,43 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+using System;
+
+namespace org.apache.qpid.transport
+{
+    public class ReceivedPayload<T> : EventArgs
+    {
+        public ReceivedPayload()
+        {
+        }  
+
+        public ReceivedPayload(T payload)
+        {
+            m_payload = payload;
+        }  
+        private T m_payload;
+
+        public T Payload
+        {
+            get { return m_payload; }
+            set { m_payload = value; }
+        }
+    }
+}

Added: incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Receiver.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Receiver.cs?rev=693060&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Receiver.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Receiver.cs Mon Sep  8 04:46:01 2008
@@ -0,0 +1,39 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+
+using System;
+using org.apache.qpid.transport;
+
+namespace org.apache.qpid.transport
+{		
+	/// <summary> 
+    /// a receiver will raise an event when:
+    /// - data is received 
+    /// - an exception is thrown 
+    /// - it is closed 
+	/// </summary>
+	public interface Receiver <T> where T : EventArgs
+	{
+        event EventHandler<T> Received;
+        event EventHandler<ExceptionArgs> Exception;		
+	    event EventHandler Closed;		
+	}
+}
\ No newline at end of file

Added: incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Result.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Result.cs?rev=693060&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Result.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Result.cs Mon Sep  8 04:46:01 2008
@@ -0,0 +1,35 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+using System;
+namespace org.apache.qpid.transport
+{
+	
+	
+	/// <summary> Result
+	/// 
+	/// </summary>
+	/// <author>  Rafael H. Schloming
+	/// </author>
+	
+	public abstract class Result:Struct
+	{
+	}
+}
\ No newline at end of file

Added: incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Sender.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Sender.cs?rev=693060&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Sender.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Sender.cs Mon Sep  8 04:46:01 2008
@@ -0,0 +1,32 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+namespace org.apache.qpid.transport
+{
+    /// <summary> 
+    /// Sender
+    /// </summary>
+    public interface Sender<T>
+    {
+        void send(T msg);
+        void flush();
+        void close();
+    }
+}
\ No newline at end of file

Added: incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Session.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Session.cs?rev=693060&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Session.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Session.cs Mon Sep  8 04:46:01 2008
@@ -0,0 +1,513 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Threading;
+using org.apache.qpid.transport;
+using org.apache.qpid.transport.util;
+using Frame = org.apache.qpid.transport.network.Frame;
+using Logger = org.apache.qpid.transport.util.Logger;
+
+
+namespace org.apache.qpid.transport
+{
+    /// <summary>
+    ///  Session
+    /// 
+    /// </summary>
+    public class Session : Invoker
+    {
+        private static readonly Logger log = Logger.get(typeof (Session));
+        private static readonly bool ENABLE_REPLAY;
+
+        static Session()
+        {
+            const string enableReplay = "enable_command_replay";
+            try
+            {
+                String var = Environment.GetEnvironmentVariable(enableReplay);
+                if (var != null)
+                {
+                    ENABLE_REPLAY = bool.Parse(var);
+                }
+            }
+            catch (Exception)
+            {
+                ENABLE_REPLAY = false;
+            }
+        }
+
+        private readonly byte[] _name;
+        private const long _timeout = 600000;
+        private bool _autoSync = false;
+
+        // channel may be null
+        private Channel _channel;
+
+        // incoming command count
+        private int _commandsIn = 0;
+        // completed incoming commands
+        private readonly Object _processedLock = new Object();
+        private RangeSet _processed = new RangeSet();
+        private int _maxProcessed = - 1;
+        private int _syncPoint = -1;
+
+        // outgoing command count
+        private int _commandsOut = 0;
+        private readonly Dictionary<int, Method> _commands = new Dictionary<int, Method>();
+        private int _maxComplete = - 1;
+        private bool _needSync = false;
+        private bool _closed;
+        private readonly Dictionary<int, Future<Struct>> _results = new Dictionary<int, Future<Struct>>();
+        private readonly List<ExecutionException> _exceptions = new List<ExecutionException>();
+
+
+        public bool Closed
+        {
+            get
+            {
+                lock (this)
+                {
+                    return _closed;
+                }
+            }
+            set
+            {
+                lock (this)
+                {
+                    _closed = value;
+                }
+            }
+        }
+
+        public Session(byte[] name)
+        {
+            _name = name;
+        }
+
+        public byte[] getName()
+        {
+            return _name;
+        }
+
+        public void setAutoSync(bool value)
+        {
+            lock (_commands)
+            {
+                _autoSync = value;
+            }
+        }
+
+        public Dictionary<int, Method> getOutstandingCommands()
+        {
+            return _commands;
+        }
+
+        public int getCommandsOut()
+        {
+            return _commandsOut;
+        }
+
+        public int CommandsIn
+        {
+            get { return _commandsIn; }
+            set { _commandsIn = value; }
+        }
+
+        public int nextCommandId()
+        {
+            return _commandsIn++;
+        }
+
+        public void identify(Method cmd)
+        {
+            int id = nextCommandId();
+            cmd.Id = id;
+
+            if (log.isDebugEnabled())
+            {
+                log.debug("ID: [{0}] %{1}", _channel, id);
+            }
+
+            //if ((id % 65536) == 0)
+            if ((id & 0xff) == 0)
+            {
+                flushProcessed(Option.TIMELY_REPLY);
+            }
+        }
+
+        public void processed(Method command)
+        {
+            processed(command.Id);
+        }
+
+        public void processed(int command)
+        {
+            processed(new Range(command, command));
+        }
+
+        public void processed(int lower, int upper)
+        {
+            processed(new Range(lower, upper));
+        }
+
+        public void processed(Range range)
+        {
+            log.debug("{0} processed({1})", this, range);
+
+            bool flush;
+            lock (_processedLock)
+            {
+                _processed.add(range);
+                Range first = _processed.getFirst();
+                int lower = first.Lower;
+                int upper = first.Upper;
+                int old = _maxProcessed;
+                if (Serial.le(lower, _maxProcessed + 1))
+                {
+                    _maxProcessed = Serial.max(_maxProcessed, upper);
+                }
+                flush = Serial.lt(old, _syncPoint) && Serial.ge(_maxProcessed, _syncPoint);
+                _syncPoint = _maxProcessed;
+            }
+            if (flush)
+            {
+                flushProcessed();
+            }
+        }
+
+        public void flushProcessed(params Option[] options)
+        {
+            RangeSet copy;
+            lock (_processedLock)
+            {
+                copy = _processed.copy();
+            }
+            sessionCompleted(copy, options);
+        }
+
+        public void knownComplete(RangeSet kc)
+        {
+            lock (_processedLock)
+            {
+                RangeSet newProcessed = new RangeSet();
+                foreach (Range pr in _processed)
+                {
+                    foreach (Range kr in kc)
+                    {
+                        foreach (Range r in pr.subtract(kr))
+                        {
+                            newProcessed.add(r);
+                        }
+                    }
+                }
+                _processed = newProcessed;
+            }
+        }
+
+        public void syncPoint()
+        {
+            int id = CommandsIn - 1;
+            log.debug("{0} synced to {1}", this, id);
+            bool flush;
+            lock (_processedLock)
+            {
+                _syncPoint = id;
+                flush = Serial.ge(_maxProcessed, _syncPoint);
+            }
+            if (flush)
+            {
+                flushProcessed();
+            }
+        }
+
+        public void attach(Channel channel)
+        {
+            _channel = channel;
+            _channel.Session = this;
+        }
+
+        public Method getCommand(int id)
+        {
+            lock (_commands)
+            {
+                return _commands[id];
+            }
+        }
+
+        public bool complete(int lower, int upper)
+        {
+            //avoid autoboxing
+            if (log.isDebugEnabled())
+            {
+                log.debug("{0} complete({1}, {2})", this, lower, upper);
+            }
+            lock (_commands)
+            {
+                int old = _maxComplete;
+                for (int id = Serial.max(_maxComplete, lower); Serial.le(id, upper); id++)
+                {
+                    _commands.Remove(id);
+                }
+                if (Serial.le(lower, _maxComplete + 1))
+                {
+                    _maxComplete = Serial.max(_maxComplete, upper);
+                }
+                log.debug("{0} commands remaining: {1}", this, _commands);
+                Monitor.PulseAll(_commands);
+                return Serial.gt(_maxComplete, old);
+            }
+        }
+
+        protected override void invoke(Method m)
+        {
+            if (Closed)
+            {
+                List<ExecutionException> exc = getExceptions();
+                if (exc.Count > 0)
+                {
+                    throw new SessionException(exc);
+                }
+                else if (_close != null)
+                {
+                    throw new ConnectionException(_close);
+                }
+                else
+                {
+                    throw new SessionClosedException();
+                }
+            }
+
+            if (m.EncodedTrack == Frame.L4)
+            {
+                lock (_commands)
+                {
+                    int next = _commandsOut++;
+                    m.Id = next;
+                    if (next == 0)
+                    {
+                        sessionCommandPoint(0, 0);
+                    }
+                    if (ENABLE_REPLAY)
+                    {
+                        _commands.Add(next, m);
+                    }
+                    if (_autoSync)
+                    {
+                        m.Sync = true;
+                    }
+                    _needSync = ! m.Sync;
+                    _channel.method(m);
+                    if (_autoSync)
+                    {
+                        sync();
+                    }
+
+                    // flush every 64K commands to avoid ambiguity on
+                    // wraparound
+                    if ((next%65536) == 0)
+                    {
+                        sessionFlush(Option.COMPLETED);
+                    }
+                }
+            }
+            else
+            {
+                _channel.method(m);
+            }
+        }
+
+        public void sync()
+        {
+            sync(_timeout);
+        }
+
+        public void sync(long timeout)
+        {
+            log.debug("{0} sync()", this);
+            lock (_commands)
+            {
+                int point = _commandsOut - 1;
+
+                if (_needSync && Serial.lt(_maxComplete, point))
+                {
+                    executionSync(Option.SYNC);
+                }
+
+                long start = DateTime.Now.Millisecond;
+                long elapsed = 0;
+
+                while (! Closed && elapsed < timeout && Serial.lt(_maxComplete, point))
+                {
+                    log.debug("{0}   waiting for[{1}]: {2}, {3}", this, point,
+                              _maxComplete, _commands);
+                    Monitor.Wait(_commands, (int) (timeout - elapsed));
+                    elapsed = DateTime.Now.Millisecond - start;
+                }
+
+                if (Serial.lt(_maxComplete, point))
+                {
+                    if (Closed)
+                    {
+                        throw new SessionException(getExceptions());
+                    }
+                    else
+                    {
+                        throw new Exception
+                            (String.Format
+                                 ("timed out waiting for sync: complete = {0}, point = {1}", _maxComplete, point));
+                    }
+                }
+            }
+        }
+
+
+        public void result(int command, Struct result)
+        {
+            Future<Struct> future;
+            lock (_results)
+            {
+                if (_results.ContainsKey(command))
+                {
+                    future = _results[command];
+                    _results.Remove(command);
+                }
+                else
+                {
+                    throw new Exception(String.Format("Cannot ger result {0} for {1}", command, result));
+                }
+            }
+            future.Result = result;
+        }
+
+        public void addException(ExecutionException exc)
+        {
+            lock (_exceptions)
+            {
+                _exceptions.Add(exc);
+            }
+        }
+
+        private ConnectionClose _close = null;
+
+        public void closeCode(ConnectionClose close)
+        {
+            _close = close;
+        }
+
+        public List<ExecutionException> getExceptions()
+        {
+            lock (_exceptions)
+            {
+                return new List<ExecutionException>(_exceptions);
+            }
+        }
+
+        public override Future<T> invoke<T>(Method m, Future<T> future)
+        {
+            lock (_commands)
+            {
+                future.Session = this;
+                int command = _commandsOut;
+                lock (_results)
+                {
+                    _results.Add(command, (Future<Struct>) future);
+                }
+                invoke(m);
+            }
+            return future;
+        }
+
+
+        public void messageTransfer(String destination,
+                                    MessageAcceptMode acceptMode,
+                                    MessageAcquireMode acquireMode,
+                                    Header header,
+                                    byte[] body,
+                                    params Option[] options)
+        {
+            MemoryStream mbody = new MemoryStream();
+            mbody.Write(body,0, body.Length);
+            messageTransfer(destination, acceptMode, acquireMode, header,
+                            mbody, options);
+        }
+
+        public void messageTransfer(String destination,
+                                    MessageAcceptMode acceptMode,
+                                    MessageAcquireMode acquireMode,
+                                    Header header,
+                                    String body,
+                                    params Option[] options)
+        {
+            messageTransfer(destination, acceptMode, acquireMode, header,
+                            new MemoryStream(Convert.ToByte(body)), options);
+        }
+
+        public void close()
+        {
+            sessionRequestTimeout(0);
+            sessionDetach(_name);
+            lock (_commands)
+            {
+                long start = DateTime.Now.Millisecond;
+                long elapsed = 0;
+
+                while (! Closed && elapsed < _timeout)
+                {
+                    Monitor.Wait(_commands, (int) (_timeout - elapsed));
+                    elapsed = DateTime.Now.Millisecond - start;
+                }
+            }
+        }
+
+        public void exception(Exception t)
+        {
+            log.error(t, "Caught exception");
+        }
+
+        public void closed()
+        {
+            Closed = true;
+            lock (_commands)
+            {
+                Monitor.PulseAll(_commands);
+            }
+            lock (_results)
+            {
+                foreach (Future<Struct> result in _results.Values)
+                {
+                    lock (result)
+                    {
+                        Monitor.PulseAll(result);
+                    }
+                }
+            }
+            _channel.Session = null;
+            _channel = null;
+        }
+
+        public String toString()
+        {
+            return String.Format("session:{0}", _name);
+        }
+    }
+}
\ No newline at end of file

Added: incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/SessionDelegate.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/SessionDelegate.cs?rev=693060&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/SessionDelegate.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/SessionDelegate.cs Mon Sep  8 04:46:01 2008
@@ -0,0 +1,128 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+
+using System;
+
+namespace org.apache.qpid.transport
+{
+    /// <summary> 
+    /// SessionDelegate
+    /// 
+    /// </summary>
+    public abstract class SessionDelegate : MethodDelegate<Session>, ProtocolDelegate<Session>
+    {
+        public void Init(Session ssn, ProtocolHeader hdr)
+        {
+        }
+
+        public void Control(Session ssn, Method method)
+        {
+            method.dispatch(ssn, this);
+        }
+
+        public void Command(Session ssn, Method method)
+        {
+            ssn.identify(method);
+            method.dispatch(ssn, this);
+            if (!method.hasPayload())
+            {
+                ssn.processed(method);
+            }
+        }
+
+        public void Error(Session ssn, ProtocolError error)
+        {
+        }
+
+        public override void executionResult(Session ssn, ExecutionResult result)
+        {
+            ssn.result(result.getCommandId(), result.getValue());
+        }
+
+        public override void executionException(Session ssn, ExecutionException exc)
+        {
+            ssn.addException(exc);
+        }
+
+        public override void sessionCompleted(Session ssn, SessionCompleted cmp)
+        {           
+                RangeSet ranges = cmp.getCommands();
+                RangeSet known = null;
+                if (cmp.getTimelyReply())
+                {
+                    known = new RangeSet();
+                }
+
+                if (ranges != null)
+                {
+                    foreach (Range range in ranges)
+                    {
+                        bool advanced = ssn.complete(range.Lower, range.Upper);
+                        if (advanced && known != null)
+                        {
+                            known.add(range);
+                        }
+                    }
+                }
+
+                if (known != null)
+                {
+                    ssn.sessionKnownCompleted(known);
+                }           
+        }
+
+        public override void sessionKnownCompleted(Session ssn, SessionKnownCompleted kcmp)
+        {
+            RangeSet kc = kcmp.getCommands();
+            if (kc != null)
+            {
+                ssn.knownComplete(kc);
+            }
+        }
+
+        public override void sessionFlush(Session ssn, SessionFlush flush)
+        {
+            if (flush.getCompleted())
+            {
+                ssn.flushProcessed();
+            }
+            if (flush.getConfirmed())
+            {
+                ssn.flushProcessed();
+            }
+            if (flush.getExpected())
+            {
+               // to be done
+                //throw new Exception("not implemented");
+            }
+        }
+
+        public override void sessionCommandPoint(Session ssn, SessionCommandPoint scp)
+        {
+            ssn.CommandsIn = scp.getCommandId();
+        }
+
+        public override void executionSync(Session ssn, ExecutionSync sync)
+        {
+            ssn.syncPoint();
+        }
+    }
+}
\ No newline at end of file

Added: incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Struct.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Struct.cs?rev=693060&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Struct.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/Struct.cs Mon Sep  8 04:46:01 2008
@@ -0,0 +1,122 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Decoder = org.apache.qpid.transport.codec.Decoder;
+using Encodable = org.apache.qpid.transport.codec.Encodable;
+using Encoder = org.apache.qpid.transport.codec.Encoder;
+namespace org.apache.qpid.transport
+{
+	/// <summary> 
+	/// Struct
+	/// </summary>
+
+    public abstract class Struct : Encodable
+    {
+        public static Struct create(int type)
+        {
+            return StructFactory.create(type);
+        }
+
+        bool dirty = true;
+
+        public bool Dirty
+        {
+            get { return dirty; }
+            set { dirty = value; }
+        }
+
+        public abstract int getStructType();
+
+        public abstract int getSizeWidth();
+
+        public abstract int getPackWidth();
+
+        public int getEncodedType()
+        {
+            int type = getStructType();
+            if (type < 0)
+            {
+                throw new Exception();
+            }
+            return type;
+        }
+
+        private bool isBit<C, T>(Field<C, T> f)
+        {
+            return Equals(f.Type, typeof(Boolean));
+        }
+
+        private bool packed()
+        {
+            return getPackWidth() > 0;
+        }
+
+        private bool encoded<C, T>(Field<C, T> f)
+        {
+            return !packed() || !isBit(f) && f.has(this);
+        }
+
+        private int getFlagWidth()
+        {
+            return (Fields.Count + 7) / 8;
+        }
+
+        private int getFlagCount()
+        {
+            return 8 * getPackWidth();
+        }
+
+        public abstract void read(Decoder dec);
+
+        public abstract void write(Encoder enc);
+
+        public abstract Dictionary<String, Object> Fields
+        {
+            get;
+        }
+
+        public String toString()
+        {
+            StringBuilder str = new StringBuilder();
+            str.Append(GetType());
+            str.Append("(");
+            bool first = true;
+            foreach (KeyValuePair<String, Object> me in Fields)
+            {
+                if (first)
+                {
+                    first = false;
+                }
+                else
+                {
+                    str.Append(", ");
+                }
+                str.Append(me.Key);
+                str.Append("=");
+                str.Append(me.Value);
+            }
+            str.Append(")");
+            return str.ToString();
+        }
+    }
+}
\ No newline at end of file

Added: incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/AbstractDecoder.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/AbstractDecoder.cs?rev=693060&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/AbstractDecoder.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/AbstractDecoder.cs Mon Sep  8 04:46:01 2008
@@ -0,0 +1,392 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Text;
+using org.apache.qpid.transport.util;
+
+namespace org.apache.qpid.transport.codec
+{
+    /// <summary> 
+    /// AbstractDecoder
+    /// </summary>
+    public abstract class AbstractDecoder : Decoder
+    {
+        private readonly Dictionary<Binary, String> str8cache = new Dictionary<Binary, String>();
+
+        protected abstract byte doGet();
+
+        protected abstract void doGet(byte[] bytes);
+        public abstract bool hasRemaining();
+
+        protected byte get()
+        {
+            return doGet();
+        }
+
+        protected void get(byte[] bytes)
+        {
+            doGet(bytes);
+        }
+
+        protected Binary get(int size)
+        {
+            byte[] bytes = new byte[size];
+            get(bytes);
+            return new Binary(bytes);
+        }
+
+        protected short uget()
+        {
+            return (short) (0xFF & get());
+        }
+
+        public virtual short readUint8()
+        {
+            return uget();
+        }
+
+        public abstract int readUint16();
+       
+
+        public abstract long readUint32();
+      
+
+        public int readSequenceNo()
+        {
+            return (int) readUint32();
+        }
+
+        public virtual long readUint64()
+        {
+            long l = 0;
+            for (int i = 0; i < 8; i++)
+            {
+                l |= ((long) (0xFF & get())) << (56 - i*8);
+            }
+            return l;
+        }
+
+        public long readDatetime()
+        {
+            return readUint64();
+        }
+
+        private static String decode(byte[] bytes, int offset, int length, Encoding encoding)
+        {
+            return encoding.GetString(bytes, offset, length);
+        }
+
+        private static String decode(byte[] bytes, Encoding encoding)
+        {
+            return decode(bytes, 0, bytes.Length, encoding);
+        }
+
+        public String readStr8()
+        {
+            short size = readUint8();
+            Binary bin = get(size);
+            String str;
+            if (! str8cache.TryGetValue(bin, out str))
+            {
+                str = decode(bin.array(), bin.offset(), bin.size(), Encoding.UTF8);
+                str8cache.Add(bin, str);
+            }
+            return str;
+        }
+
+        public String readStr16()
+        {
+            int size = readUint16();
+            byte[] bytes = new byte[size];
+            get(bytes);
+            return decode(bytes, Encoding.UTF8);
+        }
+
+        public byte[] readVbin8()
+        {
+            int size = readUint8();
+            byte[] bytes = new byte[size];
+            get(bytes);
+            return bytes;
+        }
+
+        public byte[] readVbin16()
+        {
+            int size = readUint16();
+            byte[] bytes = new byte[size];
+            get(bytes);
+            return bytes;
+        }
+
+        public byte[] readVbin32()
+        {
+            int size = (int) readUint32();
+            byte[] bytes = new byte[size];
+            get(bytes);
+            return bytes;
+        }
+
+        public RangeSet readSequenceSet()
+        {
+            int count = readUint16()/8;
+            if (count == 0)
+            {
+                return null;
+            }
+            RangeSet ranges = new RangeSet();
+            for (int i = 0; i < count; i++)
+            {
+                ranges.add(readSequenceNo(), readSequenceNo());
+            }
+            return ranges;
+        }
+
+        public RangeSet readByteRanges()
+        {
+            throw new Exception("not implemented");
+        }
+
+        public UUID readUuid()
+        {
+            long msb = readUint64();
+            long lsb = readUint64();
+            return new UUID(msb, lsb);
+        }
+
+        public String readContent()
+        {
+            throw new Exception("Deprecated");
+        }
+
+        public Struct readStruct(int type)
+        {
+            Struct st = Struct.create(type);
+            int width = st.getSizeWidth();
+            if (width > 0)
+            {
+                long size = readSize(width);
+                if (size == 0)
+                {
+                    return null;
+                }
+            }
+            if (type > 0)
+            {
+                int code = readUint16();
+                Debug.Assert(code == type);
+            }
+            st.read(this);
+            return st;
+        }
+
+        public Struct readStruct32()
+        {
+            long size = readUint32();
+            if (size == 0)
+            {
+                return null;
+            }
+            int type = readUint16();
+            Struct result = Struct.create(type);
+            result.read(this);
+            return result;
+        }
+
+        public Dictionary<String, Object> readMap()
+        {
+            long size = readUint32();
+
+            if (size == 0)
+            {
+                return null;
+            }
+
+            long count = readUint32();
+
+            Dictionary<String, Object> result = new Dictionary<String, Object>();
+            for (int i = 0; i < count; i++)
+            {
+                String key = readStr8();
+                byte code = get();
+                QpidType t = getType(code);
+                Object value = read(t);
+                result.Add(key, value);
+            }
+
+            return result;
+        }
+
+        public List<Object> readList()
+        {
+            long size = readUint32();
+
+            if (size == 0)
+            {
+                return null;
+            }
+
+            long count = readUint32();
+
+            List<Object> result = new List<Object>();
+            for (int i = 0; i < count; i++)
+            {
+                byte code = get();
+                QpidType t = getType(code);
+                Object value = read(t);
+                result.Add(value);
+            }
+            return result;
+        }
+
+        public List<Object> readArray()
+        {
+            long size = readUint32();
+
+            if (size == 0)
+            {
+                return null;
+            }
+
+            byte code = get();
+            QpidType t = getType(code);
+            long count = readUint32();
+
+            List<Object> result = new List<Object>();
+            for (int i = 0; i < count; i++)
+            {
+                Object value = read(t);
+                result.Add(value);
+            }
+            return result;
+        }
+
+        private QpidType getType(byte code)
+        {
+            return QpidType.get(code);
+        }
+
+        private long readSize(QpidType t)
+        {
+            return t.Fixed ? t.Width : readSize(t.Width);
+        }
+
+        private long readSize(int width)
+        {
+            switch (width)
+            {
+                case 1:
+                    return readUint8();
+                case 2:
+                    return readUint16();
+                case 4:
+                    return readUint32();
+                default:
+                    throw new Exception("illegal width: " + width);
+            }
+        }
+
+        private byte[] readBytes(QpidType t)
+        {
+            long size = readSize(t);
+            byte[] result = new byte[(int) size];
+            get(result);
+            return result;
+        }
+
+        private Object read(QpidType t)
+        {
+            switch (t.Code)
+            {
+                case Code.BIN8:
+                case Code.UINT8:
+                    return readUint8();
+                case Code.INT8:
+                    return get();
+                case Code.CHAR:
+                    return (char) get();
+                case Code.BOOLEAN:
+                    return get() > 0;
+
+                case Code.BIN16:
+                case Code.UINT16:
+                    return readUint16();
+                case Code.INT16:
+                    return (short) readUint16();
+
+                case Code.BIN32:
+                case Code.UINT32:
+                    return readUint32();
+
+                case Code.CHAR_UTF32:
+                case Code.INT32:
+                    return (int) readUint32();
+
+                case Code.FLOAT:
+                    return (float) readUint32();
+
+                case Code.BIN64:
+                case Code.UINT64:
+                case Code.INT64:
+                case Code.DATETIME:
+                    return readUint64();
+
+                case Code.DOUBLE:
+                    return (double) readUint64();
+                case Code.UUID:
+                    return readUuid();
+                case Code.STR8:
+                    return readStr8();
+                case Code.STR16:
+                    return readStr16();
+                case Code.STR8_LATIN:
+                case Code.STR8_UTF16:
+                case Code.STR16_LATIN:
+                case Code.STR16_UTF16:
+                    // XXX: need to do character conversion
+                    return Encoding.UTF8.GetString(readBytes(t));
+
+                case Code.MAP:
+                    return readMap();
+                case Code.LIST:
+                    return readList();
+                case Code.ARRAY:
+                    return readArray();
+                case Code.STRUCT32:
+                    return readStruct32();
+
+                case Code.BIN40:
+                case Code.DEC32:
+                case Code.BIN72:
+                case Code.DEC64:
+                    // XXX: what types are we supposed to use here?
+                    return readBytes(t);
+
+                case Code.VOID:
+                    return null;
+
+                default:
+                    return readBytes(t);
+            }
+        }
+    }
+}
\ No newline at end of file

Added: incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/AbstractEncoder.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/AbstractEncoder.cs?rev=693060&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/AbstractEncoder.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/AbstractEncoder.cs Mon Sep  8 04:46:01 2008
@@ -0,0 +1,582 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Text;
+using org.apache.qpid.transport.codec;
+using org.apache.qpid.transport.util;
+
+namespace org.apache.qpid.transport.codec
+{
+    /// <summary> 
+    /// AbstractEncoder
+    /// </summary>
+    public abstract class AbstractEncoder : Encoder
+    {
+        private static readonly Dictionary<Type, Code> ENCODINGS = new Dictionary<Type, Code>();
+        private readonly Dictionary<String, byte[]> str8cache = new Dictionary<String, byte[]>();
+
+        static AbstractEncoder()
+        {
+            ENCODINGS.Add(typeof (Boolean), Code.BOOLEAN);
+            ENCODINGS.Add(typeof (String), Code.STR16);
+            ENCODINGS.Add(typeof (long), Code.INT64);
+            ENCODINGS.Add(typeof (int), Code.INT32);
+            ENCODINGS.Add(typeof (short), Code.INT16);
+            ENCODINGS.Add(typeof (Byte), Code.INT8);
+            ENCODINGS.Add(typeof (Dictionary<String, Object>), Code.MAP);
+            ENCODINGS.Add(typeof (List<Object>), Code.LIST);
+            ENCODINGS.Add(typeof (float), Code.FLOAT);
+            ENCODINGS.Add(typeof (Double), Code.DOUBLE);
+            ENCODINGS.Add(typeof (char), Code.CHAR);
+            ENCODINGS.Add(typeof (byte[]), Code.VBIN32);
+        }
+
+        protected abstract void doPut(byte b);
+
+        protected abstract void doPut(MemoryStream src);
+
+
+        protected void put(byte b)
+        {
+            doPut(b);
+        }
+
+        protected void put(MemoryStream src)
+        {
+            doPut(src);
+        }
+
+        protected virtual void put(byte[] bytes)
+        {
+            put(new MemoryStream(bytes));
+        }
+
+        protected abstract int beginSize8();
+        protected abstract void endSize8(int pos);
+
+        protected abstract int beginSize16();
+        protected abstract void endSize16(int pos);
+
+        protected abstract int beginSize32();
+        protected abstract void endSize32(int pos);
+
+        public virtual void writeUint8(short b)
+        {
+            Debug.Assert(b < 0x100);
+            put((byte) b);
+        }
+
+        public virtual void writeUint16(int s)
+        {
+            Debug.Assert(s < 0x10000);
+            put((byte) Functions.lsb(s >> 8));
+            put((byte) Functions.lsb(s));
+        }
+
+        public virtual void writeUint32(long i)
+        {
+            Debug.Assert(i < 0x100000000L);
+            put((byte) Functions.lsb(i >> 24));
+            put((byte) Functions.lsb(i >> 16));
+            put((byte) Functions.lsb(i >> 8));
+            put((byte) Functions.lsb(i));
+        }
+
+        public void writeSequenceNo(int i)
+        {
+            writeUint32(i);
+        }
+
+        public virtual void writeUint64(long l)
+        {
+            for (int i = 0; i < 8; i++)
+            {
+                put((byte) Functions.lsb(l >> (56 - i*8)));
+            }
+        }
+
+
+        public void writeDatetime(long l)
+        {
+            writeUint64(l);
+        }
+
+        private static byte[] encode(String s, Encoding encoding)
+        {
+            return encoding.GetBytes(s);
+        }
+
+        public void writeStr8(String s)
+        {
+            if (s == null)
+            {
+                s = "";
+            }
+
+            byte[] bytes;
+            if (! str8cache.ContainsKey(s))
+            {
+                bytes = encode(s, Encoding.UTF8);
+                str8cache.Add(s, bytes);
+            }
+            else
+            {
+                bytes = str8cache[s];
+            }
+            writeUint8((short) bytes.Length);
+            put(bytes);
+        }
+
+        public void writeStr16(String s)
+        {
+            if (s == null)
+            {
+                s = "";
+            }
+
+            byte[] bytes = encode(s, Encoding.UTF8);
+            writeUint16(bytes.Length);
+            put(bytes);
+        }
+
+        public void writeVbin8(byte[] bytes)
+        {
+            if (bytes == null)
+            {
+                bytes = new byte[0];
+            }
+            if (bytes.Length > 255)
+            {
+                throw new Exception("array too long: " + bytes.Length);
+            }
+            writeUint8((short) bytes.Length);
+            put(bytes);
+        }
+
+        public void writeVbin16(byte[] bytes)
+        {
+            if (bytes == null)
+            {
+                bytes = new byte[0];
+            }
+            writeUint16(bytes.Length);
+            put(bytes);
+        }
+
+        public void writeVbin32(byte[] bytes)
+        {
+            if (bytes == null)
+            {
+                bytes = new byte[0];
+            }
+            writeUint32(bytes.Length);
+            put(bytes);
+        }
+
+        public void writeSequenceSet(RangeSet ranges)
+        {
+            if (ranges == null)
+            {
+                writeUint16(0);
+            }
+            else
+            {
+                writeUint16(ranges.size()*8);
+                foreach (Range range in ranges)
+                {
+                    writeSequenceNo(range.Lower);
+                    writeSequenceNo(range.Upper);
+                }
+            }
+        }
+
+        public void writeByteRanges(RangeSet ranges)
+        {
+            throw new Exception("not implemented");
+        }
+
+        public void writeUuid(UUID uuid)
+        {
+            long msb = 0;
+            long lsb = 0;
+            if (uuid != null)
+            {
+                msb = uuid.MostSignificantBits;
+                lsb = uuid.LeastSignificantBits;
+            }
+            writeUint64(msb);
+            writeUint64(lsb);
+        }
+
+        public void writeStruct(int type, Struct s)
+        {
+            if (s == null)
+            {
+                s = Struct.create(type);
+            }
+
+            int width = s.getSizeWidth();
+            int pos = -1;
+            if (width > 0)
+            {
+                pos = beginSize(width);
+            }
+
+            if (type > 0)
+            {
+                writeUint16(type);
+            }
+
+            s.write(this);
+
+            if (width > 0)
+            {
+                endSize(width, pos);
+            }
+        }
+
+        public void writeStruct32(Struct s)
+        {
+            if (s == null)
+            {
+                writeUint32(0);
+            }
+            else
+            {
+                int pos = beginSize32();
+                writeUint16(s.getEncodedType());
+                s.write(this);
+                endSize32(pos);
+            }
+        }
+
+        private Code encoding(Object value)
+        {
+            if (value == null)
+            {
+                return Code.VOID;
+            }
+
+            Type klass = value.GetType();
+            Code type = resolve(klass);
+
+            if (type == null)
+            {
+                throw new Exception
+                    ("unable to resolve type: " + klass + ", " + value);
+            }
+            else
+            {
+                return type;
+            }
+        }
+
+        private static Code resolve(Type klass)
+        {
+            Code type = ENCODINGS[klass];
+            if (type != null)
+            {
+                return type;
+            }
+            Type sup = klass.BaseType;
+            if (sup != null)
+            {
+                type = resolve(sup);
+
+                if (type != null)
+                {
+                    return type;
+                }
+            }
+            foreach (Type iface in klass.GetInterfaces())
+            {
+                type = resolve(iface);
+                if (type != null)
+                {
+                    return type;
+                }
+            }
+            return Code.VOID;
+        }
+
+        public void writeMap(Dictionary<String, Object> map)
+        {
+            int pos = beginSize32();
+            if (map != null)
+            {
+                writeUint32(map.Count);
+                writeMapEntries(map);
+            }
+            endSize32(pos);
+        }
+
+        protected void writeMapEntries(Dictionary<String, Object> map)
+        {
+            foreach (KeyValuePair<String, Object> entry in map)
+            {
+                String key = entry.Key;
+                Object value = entry.Value;
+                Code type = encoding(value);
+                writeStr8(key);
+                put((byte) type);
+                write(type, value);
+            }
+        }
+
+        public void writeList(List<Object> list)
+        {
+            int pos = beginSize32();
+            if (list != null)
+            {
+                writeUint32(list.Count);
+                writeListEntries(list);
+            }
+            endSize32(pos);
+        }
+
+        protected void writeListEntries(List<Object> list)
+        {
+            foreach (Object value in list)
+            {
+                Code type = encoding(value);
+                put((byte) type);
+                write(type, value);
+            }
+        }
+
+        public void writeArray(List<Object> array)
+        {
+            int pos = beginSize32();
+            if (array != null)
+            {
+                writeArrayEntries(array);
+            }
+            endSize32(pos);
+        }
+
+        protected void writeArrayEntries(List<Object> array)
+        {
+            Code type;
+
+            if (array.Count == 0)
+            {
+                return;
+            }
+            else
+            {
+                type = encoding(array[0]);
+            }
+            put((byte) type);
+            writeUint32(array.Count);
+
+            foreach (Object value in array)
+            {
+                write(type, value);
+            }
+        }
+
+        private void writeSize(QpidType t, int size)
+        {
+            if (t.Fixed)
+            {
+                if (size != t.width)
+                {
+                    throw new Exception("size does not match fixed width " + t.width + ": " + size);
+                }
+            }
+            else
+            {
+                writeSize(t.width, size);
+            }
+        }
+
+        private void writeSize(int width, int size)
+        {
+            // XXX: should check lengths
+            switch (width)
+            {
+                case 1:
+                    writeUint8((short) size);
+                    break;
+                case 2:
+                    writeUint16(size);
+                    break;
+                case 4:
+                    writeUint32(size);
+                    break;
+                default:
+                    throw new Exception("illegal width: " + width);
+            }
+        }
+
+        private int beginSize(int width)
+        {
+            switch (width)
+            {
+                case 1:
+                    return beginSize8();
+                case 2:
+                    return beginSize16();
+                case 4:
+                    return beginSize32();
+                default:
+                    throw new Exception("illegal width: " + width);
+            }
+        }
+
+        private void endSize(int width, int pos)
+        {
+            switch (width)
+            {
+                case 1:
+                    endSize8(pos);
+                    break;
+                case 2:
+                    endSize16(pos);
+                    break;
+                case 4:
+                    endSize32(pos);
+                    break;
+                default:
+                    throw new Exception("illegal width: " + width);
+            }
+        }
+
+        private void writeBytes(QpidType t, byte[] bytes)
+        {
+            writeSize(t, bytes.Length);
+            put(bytes);
+        }
+
+        private void write(Code t, Object value)
+        {
+            switch (t)
+            {
+                case Code.BIN8:
+                case Code.UINT8:
+                    writeUint8((short) value);
+                    break;
+                case Code.INT8:
+                    put((Byte) value);
+                    break;
+                case Code.CHAR:
+                    put((byte) value);
+                    break;
+                case Code.BOOLEAN:
+                    if ((bool) value)
+                    {
+                        put(1);
+                    }
+                    else
+                    {
+                        put(0);
+                    }
+
+                    break;
+
+                case Code.BIN16:
+                case Code.UINT16:
+                    writeUint16((int) value);
+                    break;
+
+                case Code.INT16:
+                    writeUint16((short) value);
+                    break;
+
+                case Code.BIN32:
+                case Code.UINT32:
+                    writeUint32((long) value);
+                    break;
+
+                case Code.CHAR_UTF32:
+                case Code.INT32:
+                    writeUint32((int) value);
+                    break;
+
+                case Code.FLOAT:
+                    writeUint32((long) value);
+                    break;
+
+                case Code.BIN64:
+                case Code.UINT64:
+                case Code.INT64:
+                case Code.DATETIME:
+                    writeUint64((long) value);
+                    break;
+
+                case Code.DOUBLE:
+                    writeUint64((long) value);
+                    break;
+
+                case Code.UUID:
+                    writeUuid((UUID) value);
+                    break;
+
+                case Code.STR8:
+                    writeStr8((string) value);
+                    break;
+
+                case Code.STR16:
+                    writeStr16((string) value);
+                    break;
+
+                case Code.STR8_LATIN:
+                case Code.STR8_UTF16:
+                case Code.STR16_LATIN:
+                case Code.STR16_UTF16:
+                    // XXX: need to do character conversion
+                    writeBytes(QpidType.get((byte) t), encode((string) value, Encoding.Unicode));
+                    break;
+
+                case Code.MAP:
+                    writeMap((Dictionary<String, Object>) value);
+                    break;
+                case Code.LIST:
+                    writeList((List<Object>) value);
+                    break;
+                case Code.ARRAY:
+                    writeList((List<Object>) value);
+                    break;
+                case Code.STRUCT32:
+                    writeStruct32((Struct) value);
+                    break;
+
+                case Code.BIN40:
+                case Code.DEC32:
+                case Code.BIN72:
+                case Code.DEC64:
+                    // XXX: what types are we supposed to use here?
+                    writeBytes(QpidType.get((byte) t), (byte[]) value);
+                    break;
+
+                case Code.VOID:
+                    break;
+
+                default:
+                    writeBytes(QpidType.get((byte) t), (byte[]) value);
+                    break;
+            }
+        }
+    }
+}
\ No newline at end of file

Added: incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/Decoder.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/Decoder.cs?rev=693060&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/Decoder.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/Decoder.cs Mon Sep  8 04:46:01 2008
@@ -0,0 +1,65 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+
+using System;
+using System.Collections.Generic;
+using org.apache.qpid.transport.util;
+
+namespace org.apache.qpid.transport.codec
+{		
+	/// <summary> 
+	/// Decoder
+	/// </summary>
+	
+	public interface Decoder
+	{
+		
+		bool hasRemaining();
+		
+		short readUint8();
+		int readUint16();
+		long readUint32();
+		long readUint64();
+		
+		long readDatetime();
+	    
+        UUID readUuid();
+		
+		int readSequenceNo();
+		RangeSet readSequenceSet(); // XXX
+		RangeSet readByteRanges(); // XXX
+		
+		String readStr8();
+		String readStr16();
+		
+		byte[] readVbin8();
+		byte[] readVbin16();
+		byte[] readVbin32();
+		
+		Struct readStruct32();
+        Dictionary<String, Object> readMap();
+        List<Object> readList();
+        List<Object> readArray();
+
+        Struct readStruct(int type);
+	}
+	
+}
\ No newline at end of file

Added: incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/Encodable.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/Encodable.cs?rev=693060&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/Encodable.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/Encodable.cs Mon Sep  8 04:46:01 2008
@@ -0,0 +1,37 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+
+namespace org.apache.qpid.transport.codec
+{
+	
+	
+	/// <summary> 
+    /// Encodable
+	/// </summary>
+		
+	public interface Encodable
+	{
+		
+		void  write(Encoder enc);
+		
+		void  read(Decoder dec);
+	}
+}
\ No newline at end of file

Added: incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/Encoder.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/Encoder.cs?rev=693060&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/Encoder.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/Encoder.cs Mon Sep  8 04:46:01 2008
@@ -0,0 +1,62 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+
+using System;
+using System.Collections.Generic;
+using org.apache.qpid.transport.util;
+using RangeSet = org.apache.qpid.transport.RangeSet;
+using Struct = org.apache.qpid.transport.Struct;
+namespace org.apache.qpid.transport.codec
+{		
+	/// <summary> 
+    /// Encoder
+	/// </summary>
+	
+	public interface Encoder
+	{
+		
+		void  writeUint8(short b);
+		void  writeUint16(int s);
+		void  writeUint32(long i);
+		void  writeUint64(long l);
+		
+		void  writeDatetime(long l);
+		void  writeUuid(UUID uuid);
+		
+		void  writeSequenceNo(int s);
+		void  writeSequenceSet(RangeSet ranges); // XXX
+		void  writeByteRanges(RangeSet ranges); // XXX
+		
+		void  writeStr8(string s);
+		void  writeStr16(string s);
+		
+		void  writeVbin8(byte[] bytes);
+		void  writeVbin16(byte[] bytes);
+		void  writeVbin32(byte[] bytes);
+		
+		void writeStruct32(Struct s);
+        void writeMap(Dictionary<String, Object> map);
+        void writeList(List<Object> list);
+        void writeArray(List<Object> array);
+
+        void writeStruct(int type, Struct s);
+	}
+}
\ No newline at end of file

Added: incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/MSDecoder.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/MSDecoder.cs?rev=693060&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/MSDecoder.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/client-010/client/transport/codec/MSDecoder.cs Mon Sep  8 04:46:01 2008
@@ -0,0 +1,82 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+
+using System;
+using System.IO;
+using System.Text;
+using org.apache.qpid.transport.util;
+
+namespace org.apache.qpid.transport.codec
+{
+	
+	
+	/// <summary> 
+	/// MSDecoder
+	/// 
+	/// </summary>
+	
+	
+	public sealed class MSDecoder:AbstractDecoder
+	{
+
+	    private BinaryReader reader;
+
+        public void init(MemoryStream st)
+		{            
+            reader = new BinaryReader(st, Encoding.BigEndianUnicode);
+		}
+		
+		protected override byte doGet()
+		{
+		    return reader.ReadByte();
+		}
+
+        protected override void doGet(byte[] bytes)
+		{
+            reader.Read(bytes, 0, bytes.Length);
+		}
+	
+		public override bool hasRemaining()
+		{
+		    return (reader.BaseStream.Position < reader.BaseStream.Length);
+		}
+
+        public override short readUint8()
+		{
+			return (short) (0xFF & reader.ReadByte());
+		}
+
+        public override int readUint16()
+		{
+		    return ByteEncoder.GetBigEndian((UInt16) reader.ReadInt16());
+		}
+
+        public override long readUint32()
+		{
+            return ByteEncoder.GetBigEndian((UInt32) reader.ReadInt32());
+		}
+
+        public override long readUint64()
+		{
+		    return (long) ByteEncoder.GetBigEndian((Double) reader.ReadInt64());            
+		}
+	}
+}
\ No newline at end of file