Beispiel #1
0
    static void Main2()
    {
        SelectionStatement s = new SelectionStatement();

        // s.CheckNumber();
        s.CheckNumber();
    }
    static void Main2()
    {
        SelectionStatement obj1 = new SelectionStatement();

        obj1.LearnIfElse();
        obj1.LearnSwitch();
    }
    static void Main2()
    {
        SelectionStatement ss = new SelectionStatement();

        //ss.LearnIfElse();
        ss.LearnSwitch();
    }
Beispiel #4
0
 static Statement()
 {
     Declaration = new DeclarationStatement();
     Jump        = new JumpStatement();
     Selection   = new SelectionStatement();
     Iteration   = new IterationStatement();
     Expression  = new ExpressionStatement();
 }
    static void Main4()
    {
        SelectionStatement s1 = new SelectionStatement();
        // s1.LearnIfElse();
        // s1.LearnSwitch();
        IterationStatement i1 = new IterationStatement();

        i1.LearnForLoop();
        i1.LearnWhileLoop();
    }
    static void Main()
    {
        SelectionStatement  ss         = new SelectionStatement();
        ItterationStatement itteration = new ItterationStatement();

        itteration.LearnLoop();
        ss.LearnIfelse();
        ss.LearnSwitch();
        itteration.LearnWhile();
    }
Beispiel #7
0
        static void Main()
        {
            //Console.Write("Enter your name:");
            //string name = Console.ReadLine();
            //Console.Write("Hi," + name);
            SelectionStatement selectionStatement = new SelectionStatement();

            //selectionStatement.LearnIfElse();
            selectionStatement.LearnSwitchCases();
        }
Beispiel #8
0
        // [39] SelectionStatement = 'if' '(' Expression ')' Statement ['else' Statement] | 'switch' '(' Expression ')' Statement.
        private bool IsSelectionStatement(out SelectionStatement selectionStatement)
        {
            selectionStatement = new SelectionStatement();
            if (CheckToken(SyntaxKind.IfKeyword))
            {
                if (!CheckToken(SyntaxKind.OpenBraceToken))
                {
                    return(false);
                }
                if (!IsExpression(out var expression))
                {
                    return(false);
                }
                if (!CheckToken(SyntaxKind.ClosingBraceToken))
                {
                    return(false);
                }
                if (!IsStatement(out var ifStatement))
                {
                    return(false);
                }
                if (CheckToken(SyntaxKind.ElseKeyword))
                {
                    if (!IsStatement(out var elseStatement))
                    {
                        return(false);
                    }
                }

                return(true);
            }
            else if (CheckToken(SyntaxKind.SwitchKeyword))
            {
                if (!CheckToken(SyntaxKind.OpenBraceToken))
                {
                    return(false);
                }
                if (!IsExpression(out var expression))
                {
                    return(false);
                }
                if (!CheckToken(SyntaxKind.ClosingBraceToken))
                {
                    return(false);
                }
                if (!IsStatement(out var switchStatement))
                {
                    return(false);
                }

                return(true);
            }

            return(false);
        }
 public void SetUp()
 {
     conditional = new SelectionStatement();
 }
    static void Main1()
    {
        SelectionStatement ss = new SelectionStatement();

        ss.LearnIfElse();
    }
Beispiel #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="element"></param>
 /// <param name="evp"></param>
 public override void Visit(SelectionStatement element, EvaluationParam evp)
 {
     throw new NotImplementedException();
 }
Beispiel #12
0
    static void Main3()
    {
        SelectionStatement s = new SelectionStatement();

        s.LearnSwitchStatements();
    }
Beispiel #13
0
 public override void Visit(SelectionStatement element)
 {
     throw new NotImplementedException();
 }
Beispiel #14
0
        protected override void Initialize(bool initData)
        {
            base.Initialize(initData);

            if (initData)
            {
                _entireTableQueryController  = new EntireTableQueryController();
                _queryDesignerController     = new QueryDesignerController();
                _arbitrarySqlQueryController = new ArbitrarySqlQueryController();
                _connectionStringList        = new SelectableListNodeList(_staticConnectionStringList);

                var  connectionString        = _doc.ConnectionString;
                bool isConnectionStringValid = IsConnectionStringValid(ref connectionString);
                _connectionStringValidIndicator = new StringValidIndicator(connectionString, isConnectionStringValid);

                _tabItemList = new SelectableListNodeList();

                _currentlySelectedController = _arbitrarySqlQueryController;

                // Decide which tab to show - if entireTableName at the end is not null, then show the entire table tab
                string entireTableName = null;
                if (!string.IsNullOrEmpty(SelectionStatement))
                {
                    var tokens = SelectionStatement.Split(new char[] { '\r', '\n', ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                    if (tokens.Length == 4 && tokens[0].ToUpperInvariant() == "SELECT" && tokens[1].ToUpperInvariant() == "*" && tokens[2].ToUpperInvariant() == "FROM")
                    {
                        entireTableName = tokens[3];
                        _currentlySelectedController = _entireTableQueryController;
                    }
                }
                else
                {
                    _currentlySelectedController = _entireTableQueryController;
                }

                _entireTableQueryController.TableName = entireTableName;
                if (isConnectionStringValid)
                {
                    _entireTableQueryController.ConnectionString = connectionString;
                }
                _tabItemList.Add(new SelectableListNode("Single table", _entireTableQueryController, object.ReferenceEquals(_entireTableQueryController, _currentlySelectedController)));

                // Query designer controller
                if (isConnectionStringValid)
                {
                    _queryDesignerController.ConnectionString = connectionString;
                }
                _tabItemList.Add(new SelectableListNode("Query builder", _queryDesignerController, object.ReferenceEquals(_queryDesignerController, _currentlySelectedController)));

                // Arbitrary SQL controller
                if (isConnectionStringValid)
                {
                    _arbitrarySqlQueryController.ConnectionString = connectionString;
                }
                _arbitrarySqlQueryController.SelectionStatement = SelectionStatement;
                _tabItemList.Add(new SelectableListNode("Arbitrary Sql statement", _arbitrarySqlQueryController, object.ReferenceEquals(_arbitrarySqlQueryController, _currentlySelectedController)));

                ConnectionString = connectionString;
            }
            if (null != _view)
            {
                _view.SetConnectionListSource(_connectionStringList, ConnectionString.OriginalConnectionString);
                _view.SetConnectionStatus(_connectionStringValidIndicator.IsConnectionStringValid);

                if (null == _entireTableQueryController.ViewObject)
                {
                    Current.Gui.FindAndAttachControlTo(_entireTableQueryController);
                }

                if (null == _queryDesignerController.ViewObject)
                {
                    Current.Gui.FindAndAttachControlTo(_queryDesignerController);
                }

                if (null == _arbitrarySqlQueryController.ViewObject)
                {
                    Current.Gui.FindAndAttachControlTo(_arbitrarySqlQueryController);
                }

                _view.SetTabItemsSource(_tabItemList);
            }
        }