/// <summary>
        ///
        /// </summary>
        /// <param name="applicationData"></param>
        /// <param name="form"></param>
        public static void Load(ApplicationData applicationData, Form form)
        {
            FoundationContract.Requires <ArgumentException>(applicationData != null);
            FoundationContract.Requires <ArgumentException>(form != null);

            var             type     = form.GetType();
            var             nodeName = ConfigurationNodeName.FromType(type);
            var             node     = applicationData.CreateNode(nodeName);
            FormWindowState windowState;

            node.Attributes.TryGetAttributeValue("WindowState", FormWindowState.Normal, out windowState);
            form.WindowState = windowState;

            if (windowState == FormWindowState.Normal)
            {
                if (node.Attributes.ContainsKey("Left"))
                {
                    form.StartPosition = FormStartPosition.Manual;
                    var attributes = node.Attributes;
                    form.Left = attributes["Left"].GetValue <int>();
                    form.Top  = attributes["Top"].GetValue <int>();
                    var width  = attributes["Width"].GetValue <int>();
                    var height = attributes["Height"].GetValue <int>();
                    form.ClientSize = new Size(width, height);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="form"></param>
        /// <param name="applicationData"></param>
        public static void Save(
            Form form,
            ApplicationData applicationData)
        {
            var type       = form.GetType();
            var nodeName   = ConfigurationNodeName.FromType(type);
            var node       = applicationData.CreateNode(nodeName);
            var attributes = node.Attributes;

            if (form.WindowState == FormWindowState.Minimized)
            {
                form.WindowState = FormWindowState.Normal;
            }

            attributes.SetAttributeValue("WindowState", form.WindowState);
            attributes.SetAttributeValue("Left", form.Left);
            attributes.SetAttributeValue("Top", form.Top);
            attributes.SetAttributeValue("Width", form.ClientSize.Width);
            attributes.SetAttributeValue("Height", form.ClientSize.Height);
        }
        GetCompletionResponse IProvider.GetCompletion(ConnectionBase connection, IDbTransaction transaction, string text, int position)
        {
            var response = new GetCompletionResponse();

            string[] items        = null;
            var      sqlStatement = new SqlParser(text);

            sqlStatement.FindToken(position, out var previousToken, out var currentToken);

            if (currentToken != null)
            {
                response.StartPosition = currentToken.StartPosition;
                response.Length        = currentToken.EndPosition - currentToken.StartPosition + 1;
            }
            else
            {
                response.StartPosition = position;
                response.Length        = 0;
            }

            var    sqlObject   = sqlStatement.FindSqlObject(previousToken, currentToken);
            string commandText = null;
            var    cs          = new OracleConnectionStringBuilder(connection.ConnectionString);
            var    userId      = cs.UserID;

            if (sqlObject != null)
            {
                string[] parts;
                string   owner;

                switch (sqlObject.Type)
                {
                case SqlObjectTypes.Table:
                    var oracleName = new OracleName(userId, sqlObject.Name);
                    commandText          = $@"select	TABLE_NAME
from	SYS.ALL_TABLES
where	OWNER	= '{oracleName.Owner}'	
order by TABLE_NAME";
                    sqlObject.ParentName = oracleName.Owner;
                    break;

                case SqlObjectTypes.Table | SqlObjectTypes.View | SqlObjectTypes.Function:
                    var name = sqlObject.Name;

                    if (name != null)
                    {
                        parts = name.Split('.');

                        if (parts.Length > 1)
                        {
                            owner = parts[0].ToUpper();
                            sqlObject.ParentName = owner;
                            name = parts[1];
                        }
                        else
                        {
                            owner = userId;
                            sqlObject.ParentName = owner;
                        }
                    }
                    else
                    {
                        owner = userId;
                        sqlObject.ParentName = owner;
                    }

                    commandText =
                        $@"select	OBJECT_NAME
from	SYS.ALL_OBJECTS
where	OWNER	= '{owner}'
	and OBJECT_TYPE in('TABLE','VIEW')
order by OBJECT_NAME";
                    sqlObject.Name = null;

                    break;

                case SqlObjectTypes.Column:
                    var parentName = sqlObject.ParentName;

                    if (parentName != null)
                    {
                        parts = parentName.Split('.');
                        string tableName;

                        if (parts.Length == 2)
                        {
                            owner     = parts[0].ToUpper();
                            tableName = parts[1].ToUpper();
                        }
                        else
                        {
                            owner                = userId;
                            tableName            = sqlObject.ParentName.ToUpper();
                            sqlObject.ParentName = owner + '.' + tableName;
                        }

                        commandText =
                            $@"select	COLUMN_NAME
from	SYS.ALL_TAB_COLUMNS
where	OWNER = '{owner}'
	and TABLE_NAME = '{tableName}'
order by COLUMN_ID";
                    }

                    break;

                case SqlObjectTypes.Function:
                    oracleName  = new OracleName(userId, sqlObject.ParentName);
                    commandText =
                        $@"select	OBJECT_NAME
from	SYS.ALL_OBJECTS
where	OWNER	= '{oracleName.Owner
                                }'
	and OBJECT_TYPE	= 'FUNCTION'
order by OBJECT_NAME";
                    sqlObject.ParentName = oracleName.Owner;
                    break;

                //case SqlObjectTypes.Procedure:
                //    oracleName = new OracleName( userId, sqlObject.Name );
                //    break;

                default:
                    break;
                }
            }

            if (commandText != null)
            {
                var sb = new StringBuilder();
                sb.Append(_objectExplorer.SchemasNode.Connection.DataSource);
                sb.Append('.');
                sb.Append(sqlObject.Type);
                sb.Append('.');
                var parentName = sqlObject.ParentName;

                if (parentName != null)
                {
                    sb.Append(parentName.ToUpper());
                }

                var name = sqlObject.Name;

                if (!string.IsNullOrEmpty(name))
                {
                    sb.Append('.');
                    sb.Append(name.ToUpper());
                }

                var key             = sb.ToString();
                var applicationData = DataCommanderApplication.Instance.ApplicationData;
                var folderName      = ConfigurationNodeName.FromType(typeof(OracleProvider)) + ConfigurationNode.Delimiter + "CompletionCache";
                var folder          = applicationData.CreateNode(folderName);
                var contains        = folder.Attributes.TryGetAttributeValue(key, out items);
                response.FromCache = contains;

                if (!contains)
                {
                    var executor = connection.Connection.CreateCommandExecutor();
                    var table    = executor.ExecuteDataTable(new ExecuteReaderRequest(commandText));
                    var count    = table.Rows.Count;
                    items = new string[count];

                    for (var i = 0; i < count; i++)
                    {
                        items[i] = (string)table.Rows[i][0];
                    }

                    folder.Attributes.Add(key, items, null);
                }
            }

            //			SqlStatement sqlStatement = new SqlStatement(text);
            //			SqlObject sqlObject = sqlStatement.FindSqlObject(position);
            //			string commandText = null;
            //
            //			switch (sqlObject.Type)
            //			{
            //				case SqlObjectType.TableOrView:
            //					string owner = connection.Database;
            //					commandText = string.Format("select * from (select table_name from all_tables where owner = '{0}' union select view_name from all_views where owner = '{0}') order by 1",owner);
            //					break;
            //			}

            //      string commandText;
            //
            //      switch (word)
            //      {
            //        case "from":
            //          commandText = "select * from (select table_name from all_tables where owner = '{0}' union select view_name from all_views where owner = '{0}') order by 1";
            //          commandText = string.Format(commandText,objectBrowser.SchemasNode.SelectedSchema);
            //          break;
            //
            //        case "table":
            //        case "update":
            //          commandText = string.Format("select table_name from all_tables where owner='{0}'",connection.DataSource);
            //          break;
            //
            //        default:
            //          commandText = null;
            //          break;
            //      }
            //
            //      string[] items = null;
            //
            //      if (commandText != null)
            //      {
            //        string key = objectBrowser.SchemasNode.Connection.DataSource + "." +
            //          objectBrowser.SchemasNode.SelectedSchema + '.' + word;
            //
            //        Folder appData = Application.Instance.ApplicationData.CurrentType;
            //
            //        if (appData.SubFolders.Contains("CompletionCache"))
            //        {
            //          appData = (Folder)appData.SubFolders["CompletionCache"];
            //        }
            //        else
            //        {
            //          Folder folder = new Folder(appData,"CompletionCache");
            //        }
            //
            //        bool containsKey = appData.Properties.ContainsKey(key);
            //
            //        if (containsKey)
            //        {
            //          items = (string[])appData.Properties[key];
            //        }
            //        else
            //        {
            //            Cursor.Current = Cursors.WaitCursor;
            //            ArrayList list = new ArrayList();
            //            IDataReader dataReader = DataHelper.ExecuteReader(commandText,connection.Wrapped);
            //
            //            while (dataReader.Read())
            //              list.Add(dataReader.GetString(0));
            //
            //            items = new string[list.Count];
            //            list.CopyTo(items);
            //
            //            appData.Properties[key] = items;
            //
            //            Cursor.Current = Cursors.Default;
            //        }
            //      }
            //
            //      return items;

            throw new NotImplementedException();

            //response.Items = items;
            //return response;
        }