You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by sc...@apache.org on 2009/01/30 23:25:07 UTC

svn commit: r739432 [4/9] - in /incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp: ./ Msg/ Support/ Transport/ Transport/Filter/ Transport/Fmt/ Transport/Fmt/Binary/ Util/

Added: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Filter/Logger.cs
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Filter/Logger.cs?rev=739432&view=auto
==============================================================================
--- incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Filter/Logger.cs (added)
+++ incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Filter/Logger.cs Fri Jan 30 22:25:03 2009
@@ -0,0 +1,163 @@
+// $Id$
+// 
+// Copyright 2007-2008 Cisco Systems Inc.
+// 
+// Licensed 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.Globalization;
+using System.IO;
+using Org.Apache.Etch.Bindings.Csharp.Msg;
+using Org.Apache.Etch.Bindings.Csharp.Util;
+
+namespace Org.Apache.Etch.Bindings.Csharp.Transport.Filter
+{
+    public class Logger : AbstractMessageFilter
+    {
+
+        private const String FILE_PATH = "Logger.filePath";
+
+        private String fileName = null;
+
+        private TextWriter writer = null;
+
+        public static bool testFlag = false;
+
+        private string testRenamedFileName = null;
+
+        enum Direction
+        {
+            UP, DOWN
+        }
+
+        public Logger(TransportMessage transport, URL uri, Resources resources)
+            : base(transport, uri, resources)
+        {
+            InitializeLogger(uri);
+           
+        }
+
+        private void InitializeLogger(URL uri)
+        {
+            string newFullFileName;
+            fileName = uri.GetTerm(FILE_PATH);
+            if (fileName == null)
+            {
+                fileName = "Log.txt";
+            }
+            
+            if (!testFlag)
+            {
+                if (File.Exists(fileName))
+                {
+                    //      string newFileName = Path.GetFileNameWithoutExtension(fileName) + DateTime.Now.ToString("yyyy.MM.dd.HH.mm.ss", CultureInfo.CreateSpecificCulture("en-US")) + Path.GetExtension(fileName);
+                    //    newFullFileName = Path.Combine(new FileInfo(fileName).DirectoryName, newFileName);
+                    newFullFileName = GenerateNewFileName(fileName, new FileInfo(fileName).DirectoryName);
+                    File.Move(fileName, newFullFileName);
+                    File.Delete(fileName);
+                }
+                writer = TextWriter.Synchronized(new StreamWriter(fileName));
+            }
+            else
+            {
+                testRenamedFileName = GenerateNewFileName(fileName,null);
+            }
+        }
+
+        private string GenerateNewFileName(string fileName, string pathName )
+        {
+            if (pathName == null)
+                pathName = "";
+            string newFileName = Path.GetFileNameWithoutExtension(fileName) + DateTime.Now.ToString("yyyy.MM.dd.HH.mm.ss", CultureInfo.CreateSpecificCulture("en-US")) + Path.GetExtension(fileName);
+            string newFullFileName = Path.Combine(pathName, newFileName);
+            return newFullFileName;
+        }
+
+        public override string ToString()
+        {
+            return "Logger/" + transport;
+        }
+
+        public string GetFileName()
+        {
+            return fileName;
+        }
+
+        public string GetTestRenamedFileName()
+        {
+            return testRenamedFileName;
+        }
+
+        public override bool SessionMessage(Who sender, Message msg)
+        {
+            WriteToFile(Direction.UP, sender, msg.ToString());
+            return base.SessionMessage(sender, msg);
+        }
+
+        public override void TransportMessage(Who recipient, Message msg)
+        {
+            WriteToFile(Direction.DOWN, recipient, msg.ToString());
+            base.TransportMessage(recipient, msg);
+        }
+        protected override bool SessionUp()
+        {
+            WriteToFile(Direction.UP, null, transport.ToString());
+            return true;
+        }
+
+        protected override bool SessionDown()
+        {
+            WriteToFile(Direction.DOWN, null, transport.ToString());
+            return true;
+        }
+
+        private void WriteToFile(Direction direction, Who msgOrigin, String msg)
+        {
+            if (writer == null)
+                return;
+            try
+            {
+                lock (writer)
+                {
+                    writer.Write(DateTime.Now.ToString("HH:mm:ss.fff", CultureInfo.CreateSpecificCulture("en-US")));
+                    writer.Write(": ");
+                    writer.Write(ConvertDirToString(direction));
+                    writer.Write(": ");
+                    if (msgOrigin != null)
+                    {
+                        writer.Write(msgOrigin.ToString());
+                        writer.Write(": ");
+                    }
+                    writer.Write(msg);
+                    writer.WriteLine();
+                    writer.Flush();
+                }
+            }
+            catch (Exception e)
+            {
+                writer.Close();
+                throw e;
+            }
+
+        }
+
+        private String ConvertDirToString(Direction dir)
+        {
+            if (Direction.DOWN == dir)
+                return "Outgoing";
+            return "Incoming";
+        }
+
+
+    }
+}

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Filter/Logger.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Filter/Logger.cs
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Filter/PwAuth.cs
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Filter/PwAuth.cs?rev=739432&view=auto
==============================================================================
--- incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Filter/PwAuth.cs (added)
+++ incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Filter/PwAuth.cs Fri Jan 30 22:25:03 2009
@@ -0,0 +1,362 @@
+// $Id$
+// 
+// Copyright 2007-2008 Cisco Systems Inc.
+// 
+// Licensed 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.Etch.Bindings.Csharp.Msg;
+using Org.Apache.Etch.Bindings.Csharp.Support;
+using Org.Apache.Etch.Bindings.Csharp.Util;
+
+namespace Org.Apache.Etch.Bindings.Csharp.Transport.Filter
+{
+    /// <summary>
+    /// PwAuth is a message filter which watches for Session.UP and attempts to
+    /// authenticate the user by sending a message to the server with the name and
+    /// password in it. If the server responds, the session is notified with the
+    /// user name. If the server responds negatively, the session is notified of the
+    /// failure (using a PwAuthFail event). A transport control may also be sent to
+    /// force a login or logout or to set the name or password. The name and password
+    /// are initialized from the uri, or prompted for if not specified.
+    /// </summary>
+    public class PwAuth : AbstractMessageFilter
+    {
+
+
+
+        /// <summary>
+        /// client sessionQuery: return user name to use for authentication.
+        /// transportQuery: return the current user name (on server it has been validated).
+        /// client transportControl: set user name to use for authentication.
+        /// </summary>
+
+        public const String USER = "PwAuth.user";
+
+
+
+        /// <summary>
+        /// client sessionQuery: return password to use for authentication.
+        /// transportQuery: return the current password (on server it has been validated).
+        /// client transportControl: set password to use for authentication.
+        /// </summary>
+        /// 
+        public const String PASSWORD = "PwAuth.password";
+
+        /// <summary>
+        /// client transportControl: send authentication request
+        /// </summary>
+        private const String AUTHENTICATE = "PwAuth.authenticate";
+
+        public PwAuth(TransportMessage transport, URL uri, Resources resources)
+            : base(transport, uri, resources)
+        {
+
+            server = (Boolean)transport.TransportQuery(TransportConsts.IS_SERVER);
+
+            if (!server)
+            {
+                user = uri.User;
+                password = uri.Password;
+            }
+
+            //		Log.report( "KeepAliveInstalled",
+            //			"delay", delay, "count", count, "server", server );
+
+            vf = (ValueFactory)resources.Get(TransportConsts.VALUE_FACTORY);
+
+            mt_request = new XType("_Etch_PwAuthReq");
+            mt_response = new XType("_Etch_PwAuthResp");
+
+            vf.AddType(mt_request);
+            vf.AddType(mt_response);
+
+            mf_user = new Field("user");
+            mf_password = new Field("password");
+            mf_ok = new Field("ok");
+            mf_status = new Field("status");
+
+            mt_request.PutValidator(mf_user, Validator_string.Get(0));
+            mt_request.PutValidator(mf_password, Validator_string.Get(0));
+            mt_request.SetResult(mt_response);
+            mt_request.Lock();
+
+            mt_response.PutValidator(mf_ok, Validator_boolean.Get(0));
+            mt_response.PutValidator(mf_status, Validator_string.Get(0));
+            mt_response.Lock();
+        }
+
+        private String user;
+
+        private String password;
+
+        private readonly bool server;
+
+        private readonly ValueFactory vf;
+
+        private readonly Field mf_user;
+
+        private readonly Field mf_password;
+
+        private readonly Field mf_ok;
+
+        private readonly Field mf_status;
+
+        private readonly XType mt_request;
+
+        private readonly XType mt_response;
+
+        public bool GetServer()
+        {
+            return server;
+        }
+
+        public override bool SessionMessage(Who sender, Message msg)
+        {
+            if (msg.IsType(mt_request))
+            {
+                HandlePwAuthReq(sender, msg);
+                return true;
+            }
+
+            if (msg.IsType(mt_response))
+            {
+                HandlePwAuthResp(sender, msg);
+                return true;
+            }
+
+            return base.SessionMessage(sender, msg);
+        }
+
+
+        protected override bool SessionUp()
+        {
+            if (!server)
+            {
+                // client: send authentication request.
+                SendPwAuthReq();
+            }
+            return true;
+        }
+
+
+        protected override bool SessionDown()
+        {
+            if (server)
+            {
+                // make sure that server session's idea of user is cleared.
+                SessionNotifyUser(null, null);
+            }
+
+            return true;
+        }
+
+        private void SendPwAuthReq()
+        {
+            if (user == null)
+            {
+                user = (String)session.SessionQuery(USER);
+                if (user == null)
+                    throw new Exception("PwAuth: user == null");
+            }
+
+            if (password == null)
+            {
+                password = (String)session.SessionQuery(PASSWORD);
+                if (password == null)
+                    throw new Exception("PwAuth: password == null");
+            }
+
+            Message msg = new Message(mt_request, vf);
+            msg.Add(mf_user, user);
+            msg.Add(mf_password, password);
+            transport.TransportMessage(null, msg);
+        }
+
+        private void HandlePwAuthReq(Who sender, Message msg)
+        {
+            if (!server)
+            {
+                // we're a client that got a request, likely we're talking to a
+                // server that is confused.
+                return;
+            }
+
+            Console.WriteLine(" Sender: " + sender);
+            Console.WriteLine(" Message: " + msg);
+
+            String u = (String)msg.Get(mf_user);
+            String p = (String)msg.Get(mf_password);
+
+            try
+            {
+                OkStatus as1 = (OkStatus)SessionQuery(new UserPassword(u, p));
+
+                if (as1.ok)
+                    SessionNotifyUser(u, p);
+                else
+                    SessionNotifyUser(null, null);
+
+                sendPwAuthResp(sender, msg, as1.ok, as1.status);
+            }
+            catch (Exception e)
+            {
+                SessionNotifyUser(null, null);
+                sendPwAuthResp(sender, msg, false, e.ToString());
+                throw e;
+            }
+        }
+
+        private void sendPwAuthResp(Who recipient, Message msg, bool result, String status)
+        {
+            Message rmsg = msg.Reply();
+            rmsg.Add(mf_ok, result);
+            rmsg.Add(mf_status, status);
+            transport.TransportMessage(recipient, rmsg);
+        }
+
+        private void HandlePwAuthResp(Who sender, Message msg)
+        {
+            if (server)
+            {
+                // we're a server that got a response, likely we're talking to a
+                // client that is confused.
+                return;
+            }
+
+            // Log.report( "GotPwAuthResp", "sender", sender, "msg", msg );
+
+            bool result = (Boolean)msg.Get(mf_ok);
+            String status = (String)msg.Get(mf_status);
+
+            session.SessionNotify(new OkStatus(result, status));
+        }
+
+
+        public override object TransportQuery(Object query)
+        {
+            if ((string)query == USER)
+                return user;
+
+            if ((string)query == PASSWORD)
+                return password;
+
+            return base.TransportQuery(query);
+        }
+
+
+        public override void TransportControl(Object control, Object value)
+        {
+            if ((string)control == USER)
+            {
+                CheckNotServer();
+                user = (String)value;
+                return;
+            }
+
+            if ((string)control == PASSWORD)
+            {
+                CheckNotServer();
+                password = (String)value;
+                return;
+            }
+
+            if ((string)control == AUTHENTICATE)
+            {
+                CheckNotServer();
+                SendPwAuthReq();
+                return;
+            }
+
+            base.TransportControl(control, value);
+        }
+
+        private void CheckNotServer()
+        {
+            if (server)
+                throw new Exception("control not permitted by server");
+        }
+
+
+        private void SessionNotifyUser(String user, String password)
+        {
+            this.user = user;
+            this.password = password;
+            session.SessionNotify(new UserPassword(user, password));
+        }
+
+        /// <summary>
+        /// Server session query response to AuthUserPassword.
+        /// </summary>
+        public class OkStatus
+        {
+            /// <summary>Constructs the AuthOkStatus.</summary>
+            /// <param name="ok">true if user / password valid.</param>
+            /// <param name="status">message related to ok.</param>
+            public OkStatus(bool ok, String status)
+            {
+                this.ok = ok;
+                this.status = status;
+            }
+
+
+            public override String ToString()
+            {
+                return String.Format("AuthOkStatus( %s, %s )", ok, status);
+            }
+
+            // true if the user / password matched 
+            public readonly bool ok;
+
+            // message related to ok
+            public readonly String status;
+        }
+
+        /// <summary>
+        /// Server session query to get AuthOkStatus, also server session event
+        /// to report changes in authentication status.
+        /// </summary>
+        public class UserPassword
+        {
+
+            /// <summary>Constructs the CheckAuth.</summary>
+            /// <param name="user">name to check</param>
+            /// <param name="password">password of the user</param>
+            public UserPassword(String user, String password)
+            {
+                this.user = user;
+                this.password = password;
+            }
+
+
+            public override String ToString()
+            {
+                return String.Format("AuthUserPassword( %s )", user);
+            }
+
+            // The user name to check
+            public readonly String user;
+
+            // The password of the user
+            public readonly String password;
+        }
+
+
+        public override string ToString()
+        {
+            return "PwAuth/" + transport;
+        }
+    }
+
+
+}

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Filter/PwAuth.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Filter/PwAuth.cs
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedData.cs
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedData.cs?rev=739432&view=auto
==============================================================================
--- incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedData.cs (added)
+++ incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedData.cs Fri Jan 30 22:25:03 2009
@@ -0,0 +1,244 @@
+// $Id$
+// 
+// Copyright 2007-2008 Cisco Systems Inc.
+// 
+// Licensed 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.Etch.Bindings.Csharp.Msg;
+
+namespace Org.Apache.Etch.Bindings.Csharp.Transport.Fmt.Binary
+{
+    /// <summary>
+    /// Common elements for binary tagged data input and output.
+    /// </summary>
+    public class BinaryTaggedData : TaggedData
+    {
+        /// <summary>
+        /// Sentinel which marks the end of a struct or array item list
+        /// in a binary input or output stream.
+        /// </summary>
+
+        public class SentinelObject
+        {
+            public override string ToString()
+            {
+                return "NONE";
+            }
+        }
+        public static readonly SentinelObject NONE = new SentinelObject();
+
+
+        /// <summary>
+        /// This is the current version of the protocol.
+        /// </summary>
+        public const sbyte VERSION = 3;
+
+        public BinaryTaggedData()
+        {
+            // do nothing
+        }
+
+        /// <summary>
+        /// Constructs the BinaryTaggedData.
+        /// </summary>
+        /// <param name="vf"></param>
+        public BinaryTaggedData(ValueFactory vf)
+            : base(vf)
+        {
+        }
+
+
+        public override sbyte CheckValue(object value)
+        {
+            if (value == null)
+                return TypeCode.NULL;
+            else if (value == NONE)
+                return TypeCode.NONE;
+
+            Type type = value.GetType();
+
+            if (value is long)
+                return CheckLong((long)value);
+
+            else if (value is Int32)
+                return CheckInteger((Int32)value);
+
+            else if (value is short)
+                return CheckShort((short)value);
+
+            else if (value is SByte)
+                return CheckByte((sbyte)value);
+
+            else if (value is Double)
+                return (sbyte)TypeCode.DOUBLE;
+
+            else if (value is float)
+                return (sbyte)TypeCode.FLOAT;
+
+            else if (value is String)
+            {
+                String s = (String)value;
+                if (s.Length == 0)
+                    return TypeCode.EMPTY_STRING;
+
+                return TypeCode.STRING;
+            }
+
+            else if (value is Boolean)
+            {
+                if ((Boolean)value)
+                    return TypeCode.BOOLEAN_TRUE;
+
+                return TypeCode.BOOLEAN_FALSE;
+            }
+
+            else if (value is StructValue)
+                return TypeCode.CUSTOM;
+
+
+            else if (value is Array)
+            {
+                Array a = (Array)value;
+                //if (a.GetType() == typeof(Int32[]))
+                //    return TypeCode.INTS;
+                //if (a.GetType() == typeof(Int16[]))
+                //    return TypeCode.SHORTS;
+                //if (a.GetType() == typeof(Boolean[]))
+                //    return TypeCode.BOOLS;
+                if (a.GetType() == typeof(SByte[]))
+                    return TypeCode.BYTES;
+                //if (a.GetType() == typeof(Int64[]))
+                //    return TypeCode.LONGS;
+                //if (a.GetType() == typeof(Single[]))
+                //    return TypeCode.FLOATS;
+                //if (a.GetType() == typeof(Double[]))
+                //    return TypeCode.DOUBLES;
+                return TypeCode.ARRAY;
+
+            }
+
+            return TypeCode.CUSTOM;
+
+        }
+
+        public override sbyte GetNativeTypeCode(Type c)
+        {
+            if (c == typeof(Boolean))
+                return TypeCode.BOOLEAN_TRUE;
+
+            if (c == typeof(SByte))
+                return TypeCode.BYTE;
+
+            if (c == typeof(short))
+                return TypeCode.SHORT;
+
+            if (c == typeof(int))
+                return TypeCode.INT;
+
+            if (c == typeof(long))
+                return TypeCode.LONG;
+
+            if (c == typeof(float))
+                return TypeCode.FLOAT;
+
+            if (c == typeof(double))
+                return TypeCode.DOUBLE;
+
+            if (c == typeof(string))
+                return TypeCode.STRING;
+
+            if (c == typeof(Object))
+                return TypeCode.ANY;
+
+            return TypeCode.CUSTOM;
+        }
+
+        public override XType GetCustomStructType(Type c)
+        {
+            return vf.GetCustomStructType(c);
+        }
+
+
+
+        public override Type GetNativeType(sbyte type)
+        {
+            switch (type)
+            {
+                case TypeCode.BOOLEAN_TRUE:
+                case TypeCode.BOOLEAN_FALSE:
+                    return typeof(Boolean);
+
+                case TypeCode.BYTE:
+                    return typeof(sbyte);
+
+                case TypeCode.SHORT:
+                    return typeof(short);
+
+                case TypeCode.INT:
+                    return typeof(int);
+
+                case TypeCode.LONG:
+                    return typeof(long);
+
+                case TypeCode.FLOAT:
+                    return typeof(float);
+
+                case TypeCode.DOUBLE:
+                    return typeof(double);
+
+                case TypeCode.EMPTY_STRING:
+                case TypeCode.STRING:
+                    return typeof(string);
+
+                case TypeCode.ANY:
+                    return typeof(Object);
+
+                default:
+                    throw new Exception("unsupported native type " + type);
+            }
+        }
+
+        private static sbyte CheckByte(sbyte v)
+        {
+            if (v >= TypeCode.MIN_TINY_INT && v <= TypeCode.MAX_TINY_INT)
+                return v;
+            return TypeCode.BYTE;
+        }
+
+        private static sbyte CheckShort(short v)
+        {
+            if (v >= SByte.MinValue && v <= SByte.MaxValue)
+                return CheckByte((sbyte)v);
+
+            return TypeCode.SHORT;
+        }
+
+        private static sbyte CheckInteger(int v)
+        {
+            if (v >= short.MinValue && v <= short.MaxValue)
+                return CheckShort((short)v);
+
+            return TypeCode.INT;
+        }
+
+        private static sbyte CheckLong(long v)
+        {
+            if (v >= int.MinValue && v <= int.MaxValue)
+                return CheckInteger((int)v);
+
+            return TypeCode.LONG;
+        }
+
+    }
+}

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedData.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedData.cs
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedDataFormatFactory.cs
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedDataFormatFactory.cs?rev=739432&view=auto
==============================================================================
--- incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedDataFormatFactory.cs (added)
+++ incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedDataFormatFactory.cs Fri Jan 30 22:25:03 2009
@@ -0,0 +1,35 @@
+// $Id$
+// 
+// Copyright 2007-2008 Cisco Systems Inc.
+// 
+// Licensed 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.Etch.Bindings.Csharp.Transport.Fmt.Binary
+ 
+{
+    public class BinaryTaggedDataFormatFactory : FormatFactory
+    {
+        
+        public BinaryTaggedDataFormatFactory() {}
+        
+        public override TaggedDataInput NewTaggedDataInput( Org.Apache.Etch.Bindings.Csharp.Msg.ValueFactory vf, string uri )
+        {
+            return new BinaryTaggedDataInput( vf, uri );
+        }
+
+        public override TaggedDataOutput NewTaggedDataOutput( Org.Apache.Etch.Bindings.Csharp.Msg.ValueFactory vf, string uri )
+        {
+            return new BinaryTaggedDataOutput( vf, uri );
+        }
+    }
+}

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedDataFormatFactory.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedDataFormatFactory.cs
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedDataInput.cs
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedDataInput.cs?rev=739432&view=auto
==============================================================================
--- incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedDataInput.cs (added)
+++ incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedDataInput.cs Fri Jan 30 22:25:03 2009
@@ -0,0 +1,395 @@
+// $Id$
+// 
+// Copyright 2007-2008 Cisco Systems Inc.
+// 
+// Licensed 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.Etch.Bindings.Csharp.Msg;
+using Org.Apache.Etch.Bindings.Csharp.Support;
+using Org.Apache.Etch.Bindings.Csharp.Util;
+
+namespace Org.Apache.Etch.Bindings.Csharp.Transport.Fmt.Binary
+{
+    /// <summary>
+    /// TaggedDataInputStream has methods to support reading little-endian integer
+    /// and floating point data types as well as tagged values from an input
+    /// stream.
+    /// </summary>
+    public class BinaryTaggedDataInput : BinaryTaggedData, TaggedDataInput
+    {
+        /// <summary>
+        /// Constructs the BinaryTaggedDataInput.
+        /// </summary>
+        /// <param name="vf">the value factory for the service.</param>
+        /// <param name="uri">the uri used to construct the transport stack.</param>
+        public BinaryTaggedDataInput( ValueFactory vf, string uri )
+            : base( vf )
+        {
+            // do nothing.
+        }
+
+        /////////////////////////////
+        // TaggedDataInput methods //
+        /////////////////////////////
+
+
+        public Message ReadMessage(FlexBuffer buf1)
+        {
+            buf = buf1;
+            
+            // lengthBudget is how many array elements total are reasonable to
+            // allocate while parsing this message. the largest value comes as each
+            // byte of the incoming message turned into an array element. the total
+            // will always be lower than this as often it takes multiple bytes to
+            // make a single array element. so, each time we make an array, we
+            // deduct the specified length from lengthBudget. if the result is
+            // negative, then either the incoming message is misformed or someone is
+            // trying to spoof us.
+            
+            lengthBudget = buf.Avail();
+
+            try
+            {
+                Message msg = StartMessage();
+                ReadKeysAndValues(msg);
+                EndMessage(msg);
+                return msg;
+            }
+            finally
+            {
+                buf = null;
+                lengthBudget = 0;
+            }
+        }
+
+        private FlexBuffer buf;
+
+        private int lengthBudget;
+
+        private StructValue ReadStruct()
+        {
+            StructValue sv = StartStruct();
+            ReadKeysAndValues( sv );
+            EndStruct( sv );
+            return sv;
+
+        }
+
+        private ArrayValue ReadArray( Validator v )
+        {
+            ArrayValue av = StartArray();
+            ReadValues( av, v );
+            EndArray( av );
+            return av;
+        }
+
+
+        private void ReadKeysAndValues( StructValue sv )
+        {
+            XType t = sv.GetXType;
+
+            while ( true )
+            {
+                Field key = ReadField( t );
+                if (key == null)
+                    break;
+
+                //Object obj = ReadValue( intValidator, true );
+                //if ( obj == NONE )
+                //    break;
+
+                //int id = ( int ) obj;
+                //Field key = t.GetField( id );
+                //if (key == null)
+                //    key = new Field(id, id.ToString());
+
+                Validator v = t.GetValidator( key );
+                if (v != null)
+                {
+                    sv.Add(key, ReadValue(v));
+                }
+                else
+                {
+                    // read the value but ignore it.
+                    Object obj = ReadValue(Validator_object.Get(0));
+                    if (false)
+                        sv.Add( key, obj );
+                }
+            }
+        }
+
+        private void ReadValues( ArrayValue av, Validator v )
+        {
+            Validator ev = v.ElementValidator();
+            while ( true )
+            {
+                Object value = ReadValue( ev, true );
+                if ( value == NONE )
+                    break;
+
+                av.Add( value );
+            }
+        }
+
+        ////////////////////////
+        // Main input methods //
+        ////////////////////////
+
+        private Message StartMessage()
+        {
+            sbyte version = buf.GetByte();
+			
+			if (version != VERSION)
+				throw new IOException(
+					"binary tagged data version mismatch: got "+version+" expected "+VERSION );
+
+            XType t = ReadType();
+            int length = ReadLength();
+
+            return new Message(t, vf, length);
+        }
+
+        private void EndMessage( Message msg )
+        {
+            // nothing to do., readKeysAndValues swallowed the NONE.
+        }
+
+        private StructValue StartStruct() 
+	    {
+            XType t = ReadType();
+            int length = ReadLength();
+
+            return new StructValue(t, vf, length);
+	    }
+
+        private void EndStruct( StructValue sv )
+        {
+            // nothing to do, readKeysAndValues swallowed the NONE.
+        }
+
+        private ArrayValue StartArray()
+        {
+            sbyte type = buf.GetByte();
+
+            XType customStructType;
+            if(type == TypeCode.CUSTOM || type == TypeCode.STRUCT)
+                customStructType = ReadType();
+            else
+                customStructType = null;
+
+            int dim = ReadIntegerValue();
+            if (dim <= 0 || dim > Validator.MAX_NDIMS)
+                throw new ArgumentException("dim <= 0 || dim > Validator.MAX_NDIMS");
+
+            int length = ReadLength();
+
+            Object array = AllocateArrayValue( type, customStructType, dim, length );
+
+            return new ArrayValue( array, type, customStructType, dim );
+        }
+
+        private void EndArray(ArrayValue array)
+        {
+            array.Compact();
+        }
+
+        private XType ReadType()
+        {
+            Object obj = ReadValue(intOrStrValidator, false);
+            if (obj is int)
+            {
+                int id = (int)obj;
+                XType type = vf.GetType(id);
+
+                if (type == null)
+                    type = new XType(id, id.ToString());
+
+                return type;
+            }
+
+            String name = (String)obj;
+            XType ntype = vf.GetType(name);
+
+            if (ntype == null)
+                ntype = new XType(name);
+
+            return ntype;
+        }
+
+        private Field ReadField( XType type )
+        {
+            Object obj = ReadValue(intOrStrValidator, true);
+
+            if (obj == NONE)
+                return null;
+
+            if (obj is int)
+            {
+                int id = (int)obj;
+                Field field = type.GetField(id);
+
+                if (field == null)
+                    field = new Field(id, id.ToString());
+
+                return field;
+            }
+
+            String name = (String)obj;
+            Field nfield = type.GetField(name);
+
+            if (nfield == null)
+                nfield = new Field(name);
+
+            return nfield;
+        }
+        
+        private readonly Validator intOrStrValidator =
+		    new ComboValidator( Validator_int.Get( 0 ), Validator_string.Get( 0 ) );
+
+        private int ReadLength()
+        {
+            int length = ReadIntegerValue();
+
+            if (length < 0 || length > lengthBudget)
+                throw new ArgumentException(
+                    "length < 0 || length > lengthBudget");
+            
+            lengthBudget -= length;
+
+            return length;
+        }
+
+        private int ReadIntegerValue() 
+	    {
+            return (int)ReadValue(intValidator);
+	    }
+
+        private readonly Validator intValidator = Validator_int.Get( 0 );
+
+        ///////////////////////////
+        // LOCAL UTILITY METHODS //
+        ///////////////////////////
+
+        private Object ValidateValue(Validator v, Object value)
+        {
+            // v == null more or less implies that a field is not known
+            // for a type. thus we don't care about the field value as
+            // we are going to ignore it. therefore, return null.
+
+            if (v == null)
+                return null;
+
+            if (value == null)
+                return null;
+
+            return v.ValidateValue(value);
+        }
+
+        private Object ValidateValue( Validator v, Boolean noneOk, Object value )
+        {
+            if (noneOk && value == NONE)
+                return value;
+
+            return ValidateValue(v, value);
+        }
+
+        private Object ReadValue( Validator v )
+        {
+            return ReadValue( v, false );
+        }
+
+        private Object ReadValue( Validator v, Boolean noneOk )
+        {
+            sbyte type = buf.GetByte();
+
+            switch ( type )
+            {
+                case TypeCode.NULL:
+                    return ValidateValue( v, null );
+
+                case TypeCode.NONE:
+                    return ValidateValue(v, noneOk, NONE);
+
+                case TypeCode.BOOLEAN_FALSE:
+                    return ValidateValue( v, false );
+
+                case TypeCode.BOOLEAN_TRUE:
+                    return ValidateValue( v, true );
+
+                case TypeCode.BYTE:
+                    return  ValidateValue( v, buf.GetByte() );
+
+                case TypeCode.SHORT:
+                    return  ValidateValue( v, buf.GetShort() );
+
+                case TypeCode.INT:
+                    return  ValidateValue( v, buf.GetInt() );
+
+                case TypeCode.LONG:
+                    return ValidateValue( v, buf.GetLong() );
+
+                case TypeCode.FLOAT:
+                    return ValidateValue( v, buf.GetFloat() );
+
+                case TypeCode.DOUBLE:
+                    return ValidateValue( v, buf.GetDouble() );
+
+                case TypeCode.BYTES:
+                    return ValidateValue( v, ReadSbytes() );
+
+                case TypeCode.EMPTY_STRING:
+                    return ValidateValue( v, "" );
+
+                case TypeCode.STRING:
+                    return ValidateValue( v, Encoding.UTF8.GetString( ReadBytes() ) );
+
+                //case TypeCode.BOOLS:
+                //case TypeCode.SHORTS:
+                //case TypeCode.INTS:
+                //case TypeCode.LONGS:
+                //case TypeCode.FLOATS:
+                //case TypeCode.DOUBLES:
+                case TypeCode.ARRAY:
+                    return ValidateValue( v, FromArrayValue( ReadArray( v ) ) );
+
+                case TypeCode.STRUCT:
+                case TypeCode.CUSTOM:
+                    return ValidateValue( v, vf.ImportCustomValue( ReadStruct() ) );
+
+                default:
+                    if (type >= TypeCode.MIN_TINY_INT && type <= TypeCode.MAX_TINY_INT)
+                        return ValidateValue(v, type);
+                    throw new Exception( "unsupported type code "+type );
+            }
+        }
+
+        private byte[] ReadBytes()
+        {
+            int length = ReadLength();
+            byte[] b = new byte[ length ];
+            buf.GetFully( b );
+            return b;
+        }
+
+        private sbyte[] ReadSbytes()
+        {
+            int length = ReadLength();
+            sbyte[] b = new sbyte[length];
+            buf.GetFully((byte[])(Array)b);
+            return b;
+        }
+    }
+}

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedDataInput.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedDataInput.cs
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedDataOutput.cs
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedDataOutput.cs?rev=739432&view=auto
==============================================================================
--- incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedDataOutput.cs (added)
+++ incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedDataOutput.cs Fri Jan 30 22:25:03 2009
@@ -0,0 +1,361 @@
+// $Id$
+// 
+// Copyright 2007-2008 Cisco Systems Inc.
+// 
+// Licensed 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 Org.Apache.Etch.Bindings.Csharp.Msg;
+using Org.Apache.Etch.Bindings.Csharp.Support;
+using Org.Apache.Etch.Bindings.Csharp.Util;
+
+namespace Org.Apache.Etch.Bindings.Csharp.Transport.Fmt.Binary
+{
+    /// <summary>
+    /// An implementation of TaggedDataOutput which uses a binary encoding.
+    /// </summary>
+    public sealed class BinaryTaggedDataOutput : BinaryTaggedData, TaggedDataOutput
+    {
+        /// <summary>
+        /// Name of uri parameter which controls whether we write ints or strings
+        /// for types and fields.
+        /// </summary>
+        public const String STRING_TYPE_AND_FIELD =
+		    "BinaryTaggedDataOutput.stringTypeAndField";
+
+        /// <summary>
+        /// Constructs the BinaryTaggedDataOutput with a null buffer.
+        /// </summary>
+        /// <param name="vf">the value factory for the service.</param>
+        /// <param name="uri">the uri used to construct the transport stack.</param>
+        public BinaryTaggedDataOutput(ValueFactory vf, string uri)
+            : base(vf)
+        {
+            this.level = vf.GetLevel();
+            URL u = new URL(uri);
+            stringTypeAndField = u.GetBooleanTerm(STRING_TYPE_AND_FIELD, false);
+        }
+
+        private readonly Validator.Level level;
+
+        private readonly bool stringTypeAndField;
+
+        //////////////////////////////
+        // TaggedDataOutput methods //
+        //////////////////////////////
+
+        #region TaggedDataOutput methods
+
+        public void WriteMessage(Message msg, FlexBuffer buf)
+        {
+            try
+            {
+                this.buf = buf;
+                StartMessage(msg);
+                WriteKeysAndValues(msg);
+                EndMessage(msg);
+            }
+            finally
+            {
+                this.buf = null;
+            }
+        }
+
+        private FlexBuffer buf;
+
+        private void WriteStruct(StructValue sv)
+        {
+            StartStruct(sv);
+            WriteKeysAndValues(sv);
+            EndStruct(sv);
+        }
+
+        private void WriteArray(ArrayValue av, Validator v)
+        {
+            StartArray(av);
+            WriteValues(av, v);
+            EndArray(av);
+        }
+
+        private void WriteKeysAndValues(StructValue sv)
+        {
+            XType t = sv.GetXType;
+            foreach (KeyValuePair<Field, Object> me in sv)
+            {
+                Field f = me.Key;
+                WriteField(f);
+                WriteValue(t.GetValidator(f), me.Value);
+            }
+        }
+
+        private void WriteValues(ArrayValue av, Validator v)
+        {
+            Validator ev = v.ElementValidator();
+            foreach (Object value in av)
+                WriteValue(ev, value);
+        }
+
+
+        /////////////////////////
+        // Main output methods //
+        /////////////////////////
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="msg"></param>
+        /// Exception:
+        ///     throws Exception
+        private void StartMessage(Message msg)
+        {
+            // since message is top-level, no type code is written to
+            // indicate a message is starting. we do write a version number
+            // to indicate this version of the binary tagged data output
+            buf.PutByte(VERSION);
+            StartStruct(msg);
+            //       WriteType( msg.GetXType );
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="msg"></param>
+        /// Exception:
+        ///     throws Exception
+        private void EndMessage(Message msg)
+        {
+            EndStruct(msg);
+
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="sv"></param>
+        /// Exception:
+        ///     throws Exception
+        private void StartStruct(StructValue sv)
+        {
+            // the caller has already written a type code to indicate a
+            // struct is starting.
+            WriteType(sv.GetXType);
+            WriteIntValue(sv.Count);
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="sv"></param>
+        /// Exception:
+        ///     throws Exception
+        private void EndStruct(StructValue sv)
+        {
+            WriteNoneValue();
+        }
+
+        private readonly IList<StructValue> structs = new List<StructValue>();
+
+        private void StartArray(ArrayValue array)
+        {
+            // the caller has already written a type code to indicate an
+            // array is starting.
+            sbyte type = array.Type;
+            buf.PutByte(type);
+            if (type == TypeCode.CUSTOM)
+                WriteType(array.CustomStructType);
+            WriteIntValue(array.Dim);
+            WriteIntValue(array.Size());
+
+        }
+
+        private void WriteType(XType type)
+        {
+            if (stringTypeAndField)
+                WriteStringValue(type.Name);
+            else
+                WriteIntValue(type.Id);
+        }
+
+        private void WriteField(Field field)
+        {
+            if (stringTypeAndField)
+                WriteStringValue(field.Name);
+            else
+                WriteIntValue(field.Id);
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="array"></param>
+        /// Exception:
+        ///     throws Exception
+        private void EndArray(ArrayValue array)
+        {
+            WriteNoneValue();
+        }
+
+        private void WriteIntValue(int value)
+        {
+            WriteValue(intValidator, value);
+        }
+
+        private readonly Validator intValidator = Validator_int.Get(0);
+
+        private void WriteStringValue(String value)
+        {
+            WriteValue(stringValidator, value);
+        }
+
+        private readonly Validator stringValidator = Validator_string.Get(0);
+
+        private void WriteNoneValue()
+        {
+            WriteValue(noneValidator, NONE);
+        }
+
+        private readonly Validator noneValidator = Validator_none.Get();
+
+        #endregion
+
+        ///////////////////////////
+        // LOCAL UTILITY METHODS //
+        ///////////////////////////
+
+        #region Local Utility Methods
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="v">the validator for this value, or none if there
+        /// isn't one</param>
+        /// <param name="value"></param>
+        /// Exception:
+        ///     throws Exception
+        private void WriteValue(Validator v, Object value)
+        {
+            sbyte typeCode = CheckValue(value);
+
+            if (level != Validator.Level.NONE && value != null)
+            {
+                if (level == Validator.Level.FULL && v == null)
+                    throw new ArgumentException("validator missing");
+                
+                if (v != null && !v.Validate(value))
+                    throw new ArgumentException( String.Format(
+                        "validator {0} failed for value {1}", v, value));
+            }
+
+            buf.PutByte(typeCode);
+
+            switch (typeCode)
+            {
+                case TypeCode.NULL:
+                case TypeCode.BOOLEAN_FALSE:
+                case TypeCode.BOOLEAN_TRUE:
+                case TypeCode.EMPTY_STRING:
+                case TypeCode.NONE:
+                    return;
+
+                case TypeCode.BYTE:
+                    buf.PutByte((Convert.ToSByte(value)));
+                    return;
+                case TypeCode.SHORT:
+                    buf.PutShort(Convert.ToInt16(value));
+                    return;
+
+                case TypeCode.INT:
+                    buf.PutInt(Convert.ToInt32(value));
+                    return;
+
+                case TypeCode.LONG:
+                    buf.PutLong(Convert.ToInt64(value));
+                    return;
+
+                case TypeCode.FLOAT:
+                    buf.PutFloat(Convert.ToSingle(value));
+                    return;
+
+                case TypeCode.DOUBLE:
+                    buf.PutDouble(Convert.ToDouble(value));
+                    return;
+
+                case TypeCode.BYTES:
+                    WriteBytes((sbyte[])value);
+                    return;
+
+                // reserved for future use
+                //case TypeCode.BOOLS:
+                //case TypeCode.SHORTS:
+                //case TypeCode.INTS:
+                //case TypeCode.LONGS:
+                //case TypeCode.FLOATS:
+                //case TypeCode.DOUBLES:
+                case TypeCode.ARRAY:
+                    WriteArray(ToArrayValue(value, v), v);
+                    return;
+
+                case TypeCode.STRING:
+                    WriteBytes(Encoding.UTF8.GetBytes((String)value));
+                    return;
+
+                case TypeCode.CUSTOM:
+                    {
+                        StructValue sv = vf.ExportCustomValue(value);
+                        if (sv == null)
+                            throw new Exception("unsupported type " + value.GetType());
+
+                        WriteStruct(sv);
+                        return;
+                    }
+
+                default:
+                    // type is either "tiny" integer or unused...
+                    if (typeCode >= TypeCode.MIN_TINY_INT && typeCode <= TypeCode.MAX_TINY_INT)
+                        return;
+
+                    throw new Exception("unsupported typecode " + typeCode);
+            }
+        }
+
+        /// <summary>
+        /// Writes a value (signed or unsigned) to the output stream.
+        /// </summary>
+        /// <param name="value">the value to write to the output stream.</param>
+        /// Exception:
+        ///     throws Exception if there's a problem with the output stream
+        private void WriteBytes(sbyte[] value)
+        {
+            int n = value.Length;
+            WriteIntValue(n);
+            buf.Put((byte[])(Array)value, 0, n);
+        }
+
+        /// <summary>
+        /// Writes a value (signed or unsigned) to the output stream.
+        /// </summary>
+        /// <param name="value">the value to write to the output stream.</param>
+        /// Exception:
+        ///     throws Exception if there's a problem with the output stream
+        private void WriteBytes(byte[] value)
+        {
+            int n = value.Length;
+            WriteIntValue(n);
+            buf.Put(value, 0, n);
+        }
+
+        #endregion Local utility methods
+    }
+}

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedDataOutput.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/BinaryTaggedDataOutput.cs
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/Validator_none.cs
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/Validator_none.cs?rev=739432&view=auto
==============================================================================
--- incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/Validator_none.cs (added)
+++ incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/Validator_none.cs Fri Jan 30 22:25:03 2009
@@ -0,0 +1,65 @@
+// $Id$
+// 
+// Copyright 2007-2008 Cisco Systems Inc.
+// 
+// Licensed 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.Etch.Bindings.Csharp.Msg;
+
+namespace Org.Apache.Etch.Bindings.Csharp.Transport.Fmt.Binary
+{
+    /// <summary>
+    /// A validator for the special end of list marker,
+    /// </summary>
+    public class Validator_none : Validator
+    {
+        public static Validator_none Get()
+        {
+            if ( validator == null )
+                validator = new Validator_none();
+            return validator;
+        }
+
+        private static Validator_none validator;
+
+        /// <summary>
+        /// constructs the validator
+        /// </summary>
+        public Validator_none()
+        {
+            //nothing to do
+        }
+
+        public override Validator ElementValidator()
+        {
+        
+            throw new ArgumentException("not an array");
+        }
+
+        public override bool Validate( Object value )
+        {
+            return value == BinaryTaggedData.NONE;
+        }
+
+      
+
+        public override object ValidateValue(object value)
+        {
+            if (Validate(value))
+                return value;
+
+            throw new Exception("value not appropriate for none: " + value);
+        }
+    }
+}

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/Validator_none.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/Binary/Validator_none.cs
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/ByteToSbyteConverter.cs
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/ByteToSbyteConverter.cs?rev=739432&view=auto
==============================================================================
--- incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/ByteToSbyteConverter.cs (added)
+++ incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/ByteToSbyteConverter.cs Fri Jan 30 22:25:03 2009
@@ -0,0 +1,52 @@
+// $Id$
+// 
+// Copyright 2007-2008 Cisco Systems Inc.
+// 
+// Licensed 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.Etch.Bindings.Csharp.Transport.Fmt
+{
+    /// <summary>
+    /// Class that provides methods for : 
+    /// 1) Converting a single value from byte to sbyte.
+    /// 2) Converting a single value for sbyte to byte.
+    /// 3) Converting an array of values of the 2 above.
+    /// </summary>
+    public static class ByteConverter
+    {
+        /// <summary>
+        /// Converts a byte value to an sbyte value.
+        /// </summary>
+        /// <param name="value"></param>
+        /// <returns></returns>
+        public static sbyte ByteToSbyte( byte value )
+        {
+            sbyte convertedValue = 0;
+
+            if ( value > 127 )
+                convertedValue = ( sbyte ) ( 127 - value );
+
+            return convertedValue;
+        }
+
+        public static byte SbyteToByte( sbyte value )
+        {
+            byte convertedValue = 0;
+
+            if ( value < 0 )
+                convertedValue = ( byte ) ( 127 - value );
+
+            return convertedValue;
+        }
+    }
+}

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/ByteToSbyteConverter.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/ByteToSbyteConverter.cs
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/TaggedData.cs
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/TaggedData.cs?rev=739432&view=auto
==============================================================================
--- incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/TaggedData.cs (added)
+++ incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/TaggedData.cs Fri Jan 30 22:25:03 2009
@@ -0,0 +1,200 @@
+// $Id$
+// 
+// Copyright 2007-2008 Cisco Systems Inc.
+// 
+// Licensed 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.Etch.Bindings.Csharp.Msg;
+using Org.Apache.Etch.Bindings.Csharp.Support;
+
+namespace Org.Apache.Etch.Bindings.Csharp.Transport.Fmt
+{
+    /// <summary>
+    /// Common interface for various types of tagged data input and output.
+    /// </summary>
+    abstract public class TaggedData
+    {
+        public TaggedData()
+        { 
+        }
+
+        /// <summary>
+        /// Constructs the TaggedData.
+        /// </summary>
+        /// <param name="vf"></param>
+        public TaggedData( ValueFactory vf )
+        {
+            this.vf = vf;
+        }
+
+        /// <summary>
+        /// The value factory to use for tagged input and output.
+        /// </summary>
+        protected readonly ValueFactory vf;
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <returns>the value factory to use for tagged input and output.</returns>
+        public ValueFactory GetValueFactory()
+        {
+            return vf;
+        }
+
+
+        protected ArrayValue ToArrayValue( Object value, Validator v )
+        {
+
+            Type c = value.GetType();
+            int dim = 0;
+
+            while ( c.IsArray )
+            {
+                dim++;
+                c = c.GetElementType();
+            }
+            
+            // now we want the type code for c, and if the type code is custom,
+            // we'll also want the struct type code.
+
+            sbyte typeCode = GetNativeTypeCode( c );
+
+            XType customStructType;
+            if (typeCode == TypeCode.CUSTOM || typeCode == TypeCode.STRUCT)
+            {
+                customStructType = GetCustomStructType(c);
+
+                if (customStructType == null && c == typeof(StructValue))
+			    {
+				    Validator_StructValue x = FindStructValueValidator( v );
+                    if (x != null)
+                        customStructType = x.GetXType();
+			    }
+			
+			if (customStructType == null )
+				throw new ArgumentException(" In tagged Data" );
+   
+            }
+               
+            else
+                customStructType = null;
+
+            return new ArrayValue( value, typeCode, customStructType, dim );
+        }
+
+        private Validator_StructValue FindStructValueValidator( Validator v )
+	    {
+		    if (v is Validator_StructValue)
+			return (Validator_StructValue) v;
+		
+		    if (v is ComboValidator)
+		    {
+			    ComboValidator x = (ComboValidator) v;
+			    Validator_StructValue y = FindStructValueValidator( x.A() );
+			
+			    if (y != null)
+				    return y;
+			
+		    	 return FindStructValueValidator( x.B() );
+		    }
+		
+		    return null;
+	    }
+
+        protected Object FromArrayValue( ArrayValue av )
+        {
+            return av.GetArray();
+        }
+
+        protected Object AllocateArrayValue( sbyte typeCode, XType customStructType,
+            int dim, int length )
+        {
+            Type clss = GetComponentType( typeCode, customStructType, dim );
+            if ( clss == null )
+                throw new ArgumentException(String.Format(
+                    "could not get array for {0}, {1}, {2}",
+                    typeCode, customStructType, dim));
+            
+            return Array.CreateInstance( clss, length );
+        }
+
+        private Type GetComponentType( sbyte typeCode, XType customStructType, int dim )
+        {
+            Type c;
+            if (typeCode == TypeCode.CUSTOM || typeCode == TypeCode.STRUCT)
+            {
+                //    c = GetCustomType( customStructType );
+                c = customStructType.GetComponentType();
+                if (c == null)
+                    c = typeof (StructValue);
+            }
+                
+            else
+                c = GetNativeType(typeCode);
+            //Console.WriteLine( "c = " + c );
+            if ( c == null )
+                return null;
+
+            if ( dim == 0 )
+                return c;
+
+            int[] dims;
+
+            while ( dim > 0 )
+            {
+                dims = new int[ dim ];
+                if ( dim > 1 )
+                    c = c.MakeArrayType();
+                dim--;
+            }
+
+            //Object o = Array.CreateInstance( c, 1 );
+
+            //c = ( ( Array ) o ).GetType();
+            //Console.WriteLine( "type= "+c );
+            return c;
+        }
+
+        /// <summary>
+        /// Returns the type code for the specified class. This
+	    /// is needed when we have an array and we have determine
+	    /// the base type and now we're fixing to serialize it.
+	    /// We use the base type code to reconstitute it on the
+	    /// other side. So we don't return a perfect code the way
+	    /// checkValue does, but rather just something that let's
+	    /// us recreate the appropriate array type on import.
+        /// </summary>
+        /// <param name="c"></param>
+        /// <returns>a type code for the specified class.</returns>
+        abstract public sbyte GetNativeTypeCode( Type c );
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="c"></param>
+        /// <returns>a struct type for the specified custom class.</returns>
+        abstract public XType GetCustomStructType( Type c );
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="type"></param>
+        /// <returns>the class for a specified (native) type code.</returns>
+        abstract public Type GetNativeType( sbyte type );
+
+        
+
+        abstract public sbyte CheckValue( Object value );
+    }
+}

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/TaggedData.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/TaggedData.cs
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/TypeCode.cs
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/TypeCode.cs?rev=739432&view=auto
==============================================================================
--- incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/TypeCode.cs (added)
+++ incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/TypeCode.cs Fri Jan 30 22:25:03 2009
@@ -0,0 +1,182 @@
+// $Id$
+// 
+// Copyright 2007-2008 Cisco Systems Inc.
+// 
+// Licensed 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.Etch.Bindings.Csharp.Transport.Fmt
+{
+    /// <summary>
+    /// Values denoting types of encoded values. There are two value ranges:
+    /// 
+    ///  -128 to -65: codes for defined types.
+    /// -64 to 127: tiny integer values.
+    ///            
+    /// Tiny integers are completely encoded within the type byte.
+    /// </summary>
+    public class TypeCode
+    {
+        /// <summary>
+        /// A code denoting a null value.
+        /// </summary>
+        public const sbyte NULL = -128;
+
+        /// <summary>
+        /// A code denoting no value. 
+        /// For example, an array is a sequence of values (some of which may
+	    /// be NULL), terminated by a NONE.
+        /// </summary>
+        public const sbyte NONE = -127;
+
+
+        /// <summary>
+        /// A code denoting a false boolean value.
+        /// </summary>
+        public const sbyte BOOLEAN_FALSE = -126;
+
+        /// <summary>
+        /// A code denoting a true boolean value.
+        /// </summary>
+        public const sbyte BOOLEAN_TRUE = -125;
+
+        /// <summary>
+        /// A code denoting a signed const sbyte.
+        /// </summary>
+        public const sbyte BYTE = -124;
+
+        /// <summary>
+        /// A code denoting a single const sbyte signed short.
+        /// </summary>
+        public const sbyte SHORT = -123;
+
+        /// <summary>
+        /// A code denoting a four sbyte signed integer.
+        /// </summary>
+        public const sbyte INT = -122;
+             
+        /// <summary>
+        /// A code denoting an eight const sbyte signed long, lsb first.
+        /// </summary>
+        public const sbyte LONG = -121;
+
+        /// <summary>
+        /// A code denoting a four const sbyte ieee floating format number.
+        /// </summary>
+        public const sbyte FLOAT = -120;
+
+        /// <summary>
+        /// A code denoting an eight const sbyte ieee floating format number.
+        /// </summary>
+        public const sbyte DOUBLE = -119;
+
+        //// Arrays /////
+
+        /// <summary>
+        /// A code denoting an array of booleans.
+        /// </summary>
+        //public const sbyte BOOLS = -118;
+
+        /// <summary>
+        /// A code denoting an array of bytes.
+        /// </summary>
+        public const sbyte BYTES = -117;
+
+        /// <summary>
+        /// A code denoting an array of shorts.
+        /// </summary>
+        //public const sbyte SHORTS = -116;
+
+        /// <summary>
+        /// A code denoting an array of ints.
+        /// </summary>
+        //public const sbyte INTS = -115;
+
+        /// <summary>
+        /// A code denoting an array of longs.
+        /// </summary>
+        //public const sbyte LONGS = -114;
+
+        /// <summary>
+        /// A code denoting an array of singles.
+        /// </summary>
+        //public const sbyte FLOATS = -113;
+
+        /// <summary>
+        /// A code denoting an array of doubles.
+        /// </summary>
+        //public const sbyte DOUBLES = -112;
+
+        /// <summary>
+        /// A code denoting a sequence of values.
+        /// </summary>
+        public const sbyte ARRAY = -111;
+
+
+        //// strings /////
+        
+        /// <summary>
+        /// A code denoting an empty string.
+        /// </summary>
+        public const sbyte EMPTY_STRING = -110;
+
+        /// <summary>
+        /// A code denoting a utf-8 encoded string.
+        /// </summary>
+        public const sbyte STRING = -109;
+
+        /// <summary>
+        /// A code denoting a custom value (struct, exception, enum, extern)
+	    /// from a value factory. An associated value identifies the specific
+	    /// type. The format on the wire of STRUCT and CUSTOM are the same.
+	    /// Emit CUSTOM instead of STRUCT, and accept STRUCT as if it were
+	    /// CUSTOM.
+        /// </summary>
+        public const sbyte STRUCT = -108;
+
+
+
+        /// <summary>
+        /// A code denoting a custom value (struct, exception, enum, extern)
+        /// from a value factory. An associated value identifies the specific
+        /// type. The format on the wire of STRUCT and CUSTOM are the same.
+        /// Emit CUSTOM instead of STRUCT, and accept STRUCT as if it were
+        /// CUSTOM.
+        /// </summary>
+        public const sbyte CUSTOM = -107;
+
+
+        /// <summary>
+        /// A code denoting that any value is ok (as long as we know how
+        /// to serialize it). Dynamic methods should be applied to determine
+        /// the type. This type never appears on the wire.
+        /// </summary>
+        public const sbyte ANY = -106;
+
+        ////////////////////
+        // tiny integers //
+        ////////////////////
+
+        /// <summary>
+        /// Minimum "small" integer.
+        /// </summary>
+        public const sbyte MIN_TINY_INT = -64;
+
+        /// <summary>
+        /// Maximum "small" integer. Small integers are encoded asis
+        /// (with embedded type code)
+        /// </summary>
+        public const sbyte MAX_TINY_INT = 127;
+
+        
+    }
+}

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/TypeCode.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/Fmt/TypeCode.cs
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/FormatFactory.cs
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/FormatFactory.cs?rev=739432&view=auto
==============================================================================
--- incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/FormatFactory.cs (added)
+++ incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/FormatFactory.cs Fri Jan 30 22:25:03 2009
@@ -0,0 +1,98 @@
+// $Id$
+// 
+// Copyright 2007-2008 Cisco Systems Inc.
+// 
+// Licensed 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.Etch.Bindings.Csharp.Msg;
+
+namespace Org.Apache.Etch.Bindings.Csharp.Transport
+{
+    public abstract class FormatFactory
+    {
+	    public const String BINARY = "binary";
+    	
+	    public const String XML = "xml";
+	
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="vf"></param>
+        /// <param name="uri"></param>
+        /// <returns>the tagged data input with the specified value factory and
+        /// initialized by terms from the uri.</returns>
+        abstract public TaggedDataInput NewTaggedDataInput( ValueFactory vf, string uri );
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="vf"></param>
+        /// <param name="uri"></param>
+        /// <returns>the tagged data output with the specified value factory and
+        /// initialized by terms from the uri.</returns>
+        abstract public TaggedDataOutput NewTaggedDataOutput( ValueFactory vf, string uri );
+
+        private readonly static Dictionary<String, Object> formatFactories = new Dictionary<String, Object>();
+
+        /// <summary>
+        /// Gets the named format factory.
+        /// </summary>
+        /// <param name="name">the name of a configured format factory.</param>
+        /// <returns>the named format factory, or null if it isn't defined.</returns>
+        public static FormatFactory Get( String name )
+        {
+            Object factory = formatFactories[name];
+
+            if (factory == null)
+                return null;
+            if (factory is string)
+            {
+                try
+                {
+                
+                    Type c = Type.GetType((string) factory);
+                    factory = Activator.CreateInstance(c);
+                    if (!(factory is FormatFactory))
+                        throw new ArgumentException(
+                            String.Format(" Instance for format name {0} does not implement FormatFactory {1}", name, factory));
+                    
+                 //   formatFactories.Add(name,factory);
+                   
+                }
+                catch(Exception e)
+                {
+                    throw new ArgumentException(" Could not create instance of format name " + name,e);
+                }
+            }
+           return (FormatFactory) factory;
+        }
+
+        /// <summary>
+        /// Puts a named format factory.
+        /// </summary>
+        /// <param name="name">the uri scheme of this format factory.</param>
+        /// <param name="factory">thefully qualified class name or instance
+        /// of the FormatFactory to associate with the name</param>
+        public static void Put( String name, Object factory )
+        {
+            formatFactories.Add( name, factory );
+        }
+
+        static FormatFactory()
+        {
+            Put(BINARY, "Org.Apache.Etch.Bindings.Csharp.Transport.Fmt.Binary.BinaryTaggedDataFormatFactory");
+        }
+    }
+}

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/FormatFactory.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/FormatFactory.cs
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/MailboxManager.cs
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/MailboxManager.cs?rev=739432&view=auto
==============================================================================
--- incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/MailboxManager.cs (added)
+++ incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/MailboxManager.cs Fri Jan 30 22:25:03 2009
@@ -0,0 +1,50 @@
+// $Id$
+// 
+// Copyright 2007-2008 Cisco Systems Inc.
+// 
+// Licensed 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 Org.Apache.Etch.Bindings.Csharp.Msg;
+using Org.Apache.Etch.Bindings.Csharp.Support;
+using Org.Apache.Etch.Bindings.Csharp.Util;
+
+namespace Org.Apache.Etch.Bindings.Csharp.Transport
+{
+    public interface MailboxManager : TransportMessage, SessionMessage
+    {
+        /// <summary>
+        /// Removes the mailbox from the set of mailbox receiving responses
+        /// to messages
+        /// </summary>
+        /// <param name="mb"></param>
+        
+        void Unregister(Mailbox mb);
+
+        /// <summary>
+        /// Redelivers defunct messages from a closed mailbox.
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="msg"></param>
+
+        void Redeliver(Who sender, Message msg);
+
+        /// <summary>
+        /// Begin a call sequence and return the mailbox which will receive the
+        /// response.
+        /// </summary>
+        /// <param name="recipient"></param>
+        /// <param name="msg"></param>
+        /// <returns></returns>
+        Mailbox TransportCall(Who recipient, Message msg);
+    }
+}

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/MailboxManager.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/etch/trunk/binding-csharp/runtime/src/main/csharp/Org.Apache.Etch.Bindings.Csharp/Transport/MailboxManager.cs
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"