/// <summary>
        /// Sets the current object.
        /// </summary>
        /// <param name="objectType">The data object type.</param>
        /// <param name="xml">The XML string.</param>
        /// <param name="version">The WITSML version.</param>
        /// <param name="bindDataGrid">True if grid can be bound with results.</param>
        /// <param name="keepGridData">True if not clearing data when querying partial results.</param>
        /// <param name="retrieveObjectSelection">if set to <c>true</c> the retrieve object selection setting is selected.</param>
        /// <param name="errorHandler">The error handler.</param>
        public void SetCurrentObject(string objectType, string xml, string version, bool bindDataGrid, bool keepGridData, bool retrieveObjectSelection, Action <WitsmlException> errorHandler)
        {
            var document   = WitsmlParser.Parse(xml);
            var family     = ObjectTypes.GetFamily(document.Root);
            var dataType   = ObjectTypes.GetObjectGroupType(objectType, family, version);
            var dataObject = WitsmlParser.Parse(dataType, document.Root);
            var collection = dataObject as IEnergisticsCollection;

            TypeDecorationManager.Register(dataType);

            CurrentObject = collection == null
                ? dataObject
                : collection.Items.Count > 1
                ? collection.Items
                : collection.Items.Count == 1
                ? collection.Items[0]
                : collection;

            if ((collection == null || collection.Items.Count == 1) && (bindDataGrid || keepGridData))
            {
                ObjectData?.SetCurrentObject(objectType, CurrentObject, keepGridData, retrieveObjectSelection, errorHandler);
            }
            else
            {
                ObjectData?.ClearDataTable();
            }
        }