public DataListTranslatedPayloadTO ConvertFrom(IBinaryDataList payload, out ErrorResultTO errors)
        {
            if(payload == null)
            {
                throw new ArgumentNullException("payload");
            }

            StringBuilder result = new StringBuilder("<" + RootTag + ">");
            errors = new ErrorResultTO();

            var itemKeys = payload.FetchAllKeys();

            foreach(var key in itemKeys)
            {
                IBinaryDataListEntry entry;
                string error;
                if(payload.TryGetEntry(key, out entry, out error))
                {
                    if(entry.IsRecordset && (entry.ColumnIODirection == enDev2ColumnArgumentDirection.Input || entry.ColumnIODirection == enDev2ColumnArgumentDirection.Both))
                    {
                        DoRecordSetAppending(errors, entry, result);
                    }
                    else
                    {
                        var fName = entry.Namespace;
                        var val = entry.FetchScalar();
                        if(val != null && (entry.ColumnIODirection == enDev2ColumnArgumentDirection.Input || entry.ColumnIODirection == enDev2ColumnArgumentDirection.Both))
                        {
                            DoScalarAppending(result, fName, val);
                        }
                    }
                }

            }

            result.Append("</" + RootTag + ">");

            DataListTranslatedPayloadTO tmp = new DataListTranslatedPayloadTO(result.ToString());

            return tmp;
        }
        public DataListTranslatedPayloadTO ConvertFrom(IBinaryDataList payload, out ErrorResultTO errors)
        {
            if(payload == null)
            {
                throw new ArgumentNullException("payload");
            }

            StringBuilder result = new StringBuilder("<" + RootTag + ">");
            errors = new ErrorResultTO();

            var entries = payload.FetchAllEntries();

            foreach(var entry in entries)
            {
                if(entry.IsRecordset)
                {
                    AddEntryToBuilder(result, entry);
                    result.Append(">");
                    foreach(var col in entry.Columns)
                    {
                        result.Append("<");
                        result.Append(col.ColumnName);
                        result.Append(" " + Description + "=\"");
                        result.Append(col.ColumnDescription);
                        result.Append("\" ");
                        result.Append(IsEditable + "=\"");
                        result.Append(col.IsEditable);
                        result.Append("\" ");
                        // Travis.Frisinger - Added Column direction
                        result.Append(GlobalConstants.DataListIoColDirection + "=\"");
                        result.Append(col.ColumnIODirection);
                        result.Append("\" ");
                        result.Append("/>");
                    }

                    result.Append("</");
                    result.Append(entry.Namespace);
                    result.Append(">");
                }
                else
                {
                    AddEntryToBuilder(result, entry);
                    result.Append("/>");
                }
            }

            result.Append("</" + RootTag + ">");

            DataListTranslatedPayloadTO tmp = new DataListTranslatedPayloadTO(result.ToString());

            return tmp;
        }
        public DataListTranslatedPayloadTO ConvertFrom(IBinaryDataList payload, out ErrorResultTO errors)
        {
            if(payload == null)
            {
                throw new ArgumentNullException("payload");
            }

            TranslatorUtils tu = new TranslatorUtils();

            StringBuilder result = new StringBuilder("<" + RootTag + ">");
            errors = new ErrorResultTO();

            IList<string> itemKeys = payload.FetchAllUserKeys();

            foreach(string key in itemKeys)
            {
                IBinaryDataListEntry entry;
                string error;
                if(payload.TryGetEntry(key, out entry, out error))
                {

                    if(entry.IsRecordset && !entry.IsEmpty())
                    {

                        var idxItr = entry.FetchRecordsetIndexes();

                        while(idxItr.HasMore())
                        {
                            var i = idxItr.FetchNextIndex();
                            IList<IBinaryDataListItem> rowData = entry.FetchRecordAt(i, out error);
                            errors.AddError(error);

                            result.Append("<");
                            result.Append(entry.Namespace);
                            result.Append(">");

                            foreach(IBinaryDataListItem col in rowData)
                            {
                                string fName = col.FieldName;

                                result.Append("<");
                                result.Append(fName);
                                result.Append(">");
                                try
                                {
                                    result.Append(tu.FullCleanForEmit(col.TheValue));
                                }
                                // ReSharper disable EmptyGeneralCatchClause
                                catch(Exception)
                                // ReSharper restore EmptyGeneralCatchClause
                                {
                                }
                                result.Append("</");
                                result.Append(fName);
                                result.Append(">");
                            }

                            result.Append("</");
                            result.Append(entry.Namespace);
                            result.Append(">");
                        }

                    }
                    else if(!entry.IsRecordset)
                    {
                        string fName = entry.Namespace;
                        IBinaryDataListItem val = entry.FetchScalar();
                        if(val != null)
                        {
                            result.Append("<");
                            result.Append(fName);
                            result.Append(">");
                            try
                            {
                                result.Append(tu.FullCleanForEmit(val.TheValue));
                            }
                            // ReSharper disable EmptyGeneralCatchClause
                            catch(Exception)
                            // ReSharper restore EmptyGeneralCatchClause
                            {
                            }
                            result.Append("</");
                            result.Append(fName);
                            result.Append(">");
                        }
                    }
                }

            }

            result.Append("</" + RootTag + ">");

            DataListTranslatedPayloadTO tmp = new DataListTranslatedPayloadTO(result.ToString());

            return tmp;
        }
        public DataListTranslatedPayloadTO ConvertFrom(IBinaryDataList payload, out ErrorResultTO errors)
        {
            if(payload == null)
            {
                throw new ArgumentNullException("payload");
            }

            TranslatorUtils tu = new TranslatorUtils();

            StringBuilder result = new StringBuilder("<" + RootTag + ">");
            errors = new ErrorResultTO();

            var itemKeys = payload.FetchAllKeys();

            foreach(string key in itemKeys)
            {
                IBinaryDataListEntry entry;
                string error;
                if(payload.TryGetEntry(key, out entry, out error))
                {

                    if(entry.IsRecordset)
                    {
                        var idxItr = entry.FetchRecordsetIndexes();

                        while(idxItr.HasMore() && !entry.IsEmpty())
                        {

                            while(idxItr.HasMore())
                            {

                                int i = idxItr.FetchNextIndex();

                                IList<IBinaryDataListItem> rowData = entry.FetchRecordAt(i, out error);
                                errors.AddError(error);
                                result.Append("<");
                                result.Append(entry.Namespace);
                                result.Append(">");

                                foreach(IBinaryDataListItem col in rowData)
                                {
                                    string fName = col.FieldName;

                                    result.Append("<");
                                    result.Append(fName);
                                    result.Append(">");

                                    // Travis.Frisinger 04.02.2013
                                    if(!col.IsDeferredRead)
                                    {
                                        try
                                        {
                                            result.Append(tu.CleanForEmit(col.TheValue));
                                        }
                                        catch(Exception e)
                                        {
                                            Dev2Logger.Log.Error(e);
                                        }
                                    }
                                    else
                                    {
                                        // deferred read, just print the location
                                        result.Append(!string.IsNullOrEmpty(col.TheValue) ? col.FetchDeferredLocation() : string.Empty);
                                    }
                                    result.Append("</");
                                    result.Append(fName);
                                    result.Append(">");
                                }

                                result.Append("</");
                                result.Append(entry.Namespace);
                                result.Append(">");
                            }
                        }
                    }
                    else
                    {
                        string fName = entry.Namespace;
                        IBinaryDataListItem val = entry.FetchScalar();
                        if(val != null)
                        {
                            result.Append("<");
                            result.Append(fName);
                            result.Append(">");
                            // Travis.Frisinger 04.02.2013
                            if(!val.IsDeferredRead)
                            {
                                // Dev2System.FormView is our html region, pass it by ;)
                                try
                                {
                                    result.Append(!entry.IsManagmentServicePayload ? tu.CleanForEmit(val.TheValue) : val.TheValue);
                                }
                                catch(Exception e)
                                {
                                    Dev2Logger.Log.Error(e);
                                }

                            }
                            else
                            {
                                // deferred read, just print the location
                                result.Append(val.FetchDeferredLocation());
                            }
                            result.Append("</");
                            result.Append(fName);
                            result.Append(">");
                        }
                    }
                }

            }

            result.Append("</" + RootTag + ">");

            DataListTranslatedPayloadTO tmp = new DataListTranslatedPayloadTO(result.ToString());

            return tmp;
        }
        /// <summary>
        /// Converts from a binary representation in the standard format to the specified <see cref="Format" />.
        /// </summary>
        /// <param name="input">The binary representation of the datalist.</param>
        /// <param name="errors">The errors.</param>
        /// <returns>
        /// An array of bytes that represent the datalist in the specified <see cref="Format" />
        /// </returns>
        /// <exception cref="System.ArgumentNullException">input</exception>
        public DataListTranslatedPayloadTO ConvertFrom(IBinaryDataList input, out ErrorResultTO errors)
        {
            errors = new ErrorResultTO();
            if(input == null) throw new ArgumentNullException("input");

            IList<string> itemKeys = input.FetchAllUserKeys();
            errors = new ErrorResultTO();

            StringBuilder result = new StringBuilder("{");
            int keyCnt = 0;

            foreach(string key in itemKeys)
            {
                IBinaryDataListEntry entry;

                // This check was never here - this means this method has no testing and was never sane ;)

                string error;
                if(input.TryGetEntry(key, out entry, out error))
                {
                    if(entry.IsRecordset)
                    {
                        result.Append(ProcessRecordSet(entry, out error));
                        errors.AddError(error);
                    }
                    else
                    {
                        result.Append(ProcessScalar(entry));
                    }
                }

                errors.AddError(error);

                // wack in , for field separator ;)
                keyCnt++;
                if(keyCnt < itemKeys.Count)
                {
                    result.Append(",");
                }
            }

            result.Append("}");

            DataListTranslatedPayloadTO tmp = new DataListTranslatedPayloadTO(result.ToString());

            return tmp;
        }