Ejemplo n.º 1
0
        public static TableName[] GetTableNames(ApplicationCommand cmd, PathManager mgr)
        {
            var pt = mgr.current;

            if (!(pt.Item is Locator) && !(pt.Item is TableName))
            {
                if (cmd.arg1 != null)
                {
                    PathName path = new PathName(cmd.arg1);
                    var      node = mgr.Navigate(path);
                    if (node != null)
                    {
                        var dname = mgr.GetPathFrom <DatabaseName>(node);
                        if (dname != null)
                        {
                            if (cmd.wildcard != null)
                            {
                                var m = new MatchedDatabase(dname, cmd);
                                return(m.TableNames());
                            }
                            else
                            {
                                var _tname = mgr.GetPathFrom <TableName>(node);
                                if (_tname != null)
                                {
                                    return new TableName[] { _tname }
                                }
                                ;
                                else
                                {
                                    cerr.WriteLine("invalid path");

                                    return(null);
                                }
                            }
                        }
                        else
                        {
                            cerr.WriteLine("database is unavailable");
                            return(null);
                        }
                    }
                    else
                    {
                        cerr.WriteLine("invalid path");
                        return(null);
                    }
                }
            }


            if (pt.Item is TableName)
            {
                var tname = (TableName)pt.Item;
                return(new TableName[] { tname });
            }

            return(null);
        }
Ejemplo n.º 2
0
        private bool SetSource(string source, string sourceText)
        {
            if (source == null)
            {
                cerr.WriteLine("invalid argument");
                return(false);
            }

            var path = new PathName(source);

            node = mgr.Navigate(path);
            if (node == null)
            {
                cerr.WriteLine("invalid path:" + path);
                return(false);
            }

            dname = mgr.GetPathFrom <DatabaseName>(node);
            if (dname == null)
            {
                cerr.WriteLine($"warning: {sourceText} database is unavailable");
                return(false);
            }

            var server = mgr.GetPathFrom <ServerName>(node);

            side = new Side(dname);

            T = new TableName[] { };

            if (path.wildcard != null)
            {
                var m1 = new MatchedDatabase(dname, path.wildcard)
                {
                    Includedtables = cmd.Includes,
                    Excludedtables = cmd.Excludes
                };

                T = m1.TableNames();
            }
            else
            {
                TableName tname = mgr.GetPathFrom <TableName>(node);
                if (tname == null)
                {
                    T = dname.GetTableNames();
                }
                else
                {
                    T = new TableName[] { tname };
                }
            }

            return(true);
        }