Exemplo n.º 1
0
 public void OnRequest(PingRequest request)
 {
     ConsoleDisplay.RequestPacket(
         request.Packet,
         (DisplayConfig.UseInputtedAddress | DisplayConfig.UseResolvedAddress ? Attributes.InputtedAddress : Attributes.ResolvedAddress),
         request.SequenceNumber);
 }
Exemplo n.º 2
0
        } // CreateRepositoryAndPerformInitialCommit

        private static void DisplayPvcsSourcesForIssue(PvcsCompleteSystemArchiveDetail pvcsCompleteSystemArchiveDetail, string selectedIssueNumber)
        {
            SortedSet <string> additionalIssueNumberCollection = new SortedSet <string>();

            pvcsCompleteSystemArchiveDetail.CheckDescendents(selectedIssueNumber, "System_Test",
                                                             additionalIssueNumberCollection);

            if (additionalIssueNumberCollection.Count == 0)
            {
                Console.WriteLine();
                Console.WriteLine("*** No Issue Numbers in addtion to {0} were found", selectedIssueNumber);
            }
            else
            {
                string heading = String.Format("Issue Numbers Found in Addition to {0}", selectedIssueNumber);
                Console.WriteLine();
                ConsoleDisplay.WritelineWithUnderline(heading);
                foreach (string issueNumber in additionalIssueNumberCollection)
                {
                    Console.WriteLine("{0}{1}", ConsoleDisplay.Indent(1), issueNumber);
                }
            }

            string promotionGroup = "System_Test";

            Console.WriteLine();
            string promotionHeading = String.Format("Promotion List for Issue Number {0} at {1}",
                                                    selectedIssueNumber, promotionGroup);

            ConsoleDisplay.WritelineWithUnderline(promotionHeading);
            pvcsCompleteSystemArchiveDetail.GeneratePromotionListForIssue(selectedIssueNumber, promotionGroup);

            // Assume already at User_Test. Bad but good enough for now (forever?)
            pvcsCompleteSystemArchiveDetail.CheckBuriedPromotionGroup("System_Test");
        } // DisplayPvcsSourcesForIssue
Exemplo n.º 3
0
        public void OnReply(PingReply response)
        {
            // Determine what form the response address is going to be displayed in
            // TODO: Move this when lookup refactor is done
            string responseAddress = response.Endpoint.ToString();

            if (DisplayConfig.UseResolvedAddress)
            {
                // Returned address normally have port at the end (eg 8.8.8.8:0) so we need to remove that before trying to query the DNS
                string responseIP = responseAddress.ToString().Split(':')[0];

                // Resolve the ip and store as the response address
                responseAddress = Helper.RunWithCancellationToken(() => Lookup.QueryHost(responseIP), Token);
            }
            else if (DisplayConfig.UseInputtedAddress)
            {
                responseAddress = Attributes.InputtedAddress;
            }

            ConsoleDisplay.ReplyPacket(
                response.Packet,
                responseAddress,
                response.SequenceNumber,
                response.RoundTripTime,
                response.BytesRead);

            if (Attributes.BeepMode == 2)
            {
                try { Console.Beep(); }
                catch (Exception) { } // Silently continue if Console.Beep errors
            }
        }
Exemplo n.º 4
0
        public MainView(MainViewModel viewModel)
        {
            DataContext = viewModel;
            _viewModel  = viewModel;
            ConsoleDisplay.Add(new MenuItem()
            {
                Command = _viewModel.GetFilePathCommand, Header = "1. Choose .dll file from filesystem"
            });
            ConsoleDisplay.Add(new MenuItem()
            {
                Command = _viewModel.LoadMetadataCommand, Header = "2. Load .dll or .xml assembly"
            });

            // TODO view message saying "File selected to serialize is wrong"
            ConsoleDisplay.Add(new MenuItem()
            {
                Command = _viewModel.SaveDataCommand, Header = "3. Serialize loaded data"
            });
            ConsoleDisplay.Add(new MenuItem()
            {
                Command = new RelayCommand(() =>
                {
                    ConsoleTreeView.TreeItems = _viewModel.MetadataTree.ToList();
                    ConsoleTreeView.Display();
                }, () => _viewModel.MetadataTree.ToList()?.Any() == true),
                Header = "4. List assembly of selected .dll or .xml"
            });
            ConsoleDisplay.Add(new MenuItem()
            {
                Command = new RelayCommand(() => Environment.Exit(0)), Header = "q. Exit"
            });
        }
    public void ConsoleApplicationTest()
    {
        var reader  = new StringReader("create 2 2\npoint 0 0\nquit\n");
        var writer  = new StringWriter();
        var display = new ConsoleDisplay(writer);
        var source  = new ConsoleCommandSource(reader);

        new Repl(source, display).Start();

        Assert.AreEqual(
            new List <string>
        {
            "xxxx",
            "x  x",
            "x  x",
            "xxxx",
            "",
            "xxxx",
            "xx x",
            "x  x",
            "xxxx",
            "",
            "Good bye!"
        }, Unlines(writer.ToString().Trim()));
    }
Exemplo n.º 6
0
        } // RunMonitoredCommand

        public static bool RunMonitoredCommand(string workingDirectory,
                                               string command,
                                               int indent,
                                               DebugProgress debugProgress,
                                               CommandOutputDisplayType commandOutputDisplay,
                                               List <string> standardOutputBuffer,
                                               List <string> standardErrorBuffer)
        {
            bool success = false;

            if (RunCommand(workingDirectory, command, debugProgress, commandOutputDisplay, standardOutputBuffer, standardErrorBuffer))
            {
                success = true;
                Console.WriteLine("{0}Succeeded \"{1}\"",
                                  ConsoleDisplay.Indent(indent + 1),
                                  command);
            }
            else
            {
                success = false;
                Console.WriteLine("{0}*** Failed \"{1}\"",
                                  ConsoleDisplay.Indent(indent + 1),
                                  command);
            }

            // Switch to the branch

            return(success);
        } // RunMonitoredCommand
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            Cube         cube    = new Cube();
            ICubeDisplay display = new ConsoleDisplay(cube);

            //cube.DoMove(MoveType.Right, MoveDirection.Reverse);
            //cube.DoMove(MoveType.Lower, MoveDirection.Forward);
            //cube.DoMove(MoveType.Upper, MoveDirection.Forward);
            //cube.DoMove(MoveType.Right, MoveDirection.Forward);
            //cube.DoMove(MoveType.Front, MoveDirection.Forward);
            //cube.DoMove(MoveType.Lower, MoveDirection.Forward);
            //cube.DoMove(MoveType.Left, MoveDirection.Forward);
            //cube.DoMove(MoveType.Back, MoveDirection.Forward);
            //cube.DoMove(MoveType.Upper, MoveDirection.Forward);
            //cube.DoMove(MoveType.Upper, MoveDirection.Reverse);
            //cube.DoMove(MoveType.Back, MoveDirection.Reverse);
            //cube.DoMove(MoveType.Left, MoveDirection.Reverse);
            //cube.DoMove(MoveType.Lower, MoveDirection.Reverse);
            //cube.DoMove(MoveType.Front, MoveDirection.Reverse);
            //cube.DoMove(MoveType.Right, MoveDirection.Reverse);
            //cube.DoMove(MoveType.Upper, MoveDirection.Reverse);
            //cube.DoMove(MoveType.Lower, MoveDirection.Reverse);
            //cube.DoMove(MoveType.Right, MoveDirection.Forward);

            cube.ScrambleCube();

            ConsoleKeyInfo c = Console.ReadKey();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Create a new user account. If an account is already created
        /// with the given username, it will ask you to try another username.
        /// </summary>
        public bool CreateAccount()
        {
            bool   bCreated;
            string username, password;

            ConsoleDisplay.DisplayCreateAccount();

            ConsoleDisplay.DisplayEnterUsername();
            username = Console.ReadLine();

            ConsoleDisplay.DisplayEnterPassword();
            password = ConsoleUtil.EnterPassword();

            bCreated = OnCreateUserEvent(username, password);

            if (!bCreated)
            {
                ConsoleDisplay.ErrorUsernameTaken(username);
            }
            else
            {
                mLoggedInUsername = username;
            }
            return(bCreated);
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            var mapManager = new MapManager(ConfigurationManager.AppSettings["pathToMapDirectory"], ConfigurationManager.AppSettings["pathToMapFile"]);
            var map        = new ConsoleMap(int.Parse(ConfigurationManager.AppSettings["widthField"]), int.Parse(ConfigurationManager.AppSettings["heightField"]), int.Parse(ConfigurationManager.AppSettings["timeToBoom"]));
            var Bomber     = new Model.Bomber(int.Parse(ConfigurationManager.AppSettings["liveCount"]), map.FirstPositionBomber);

            map.Load(mapManager.GetFirstMap());

            map.SetUpgradeOnMap(10, 10, 10);
            var displayConsole = new ConsoleDisplay(map);


            var gamepadConsole = new ConsoleGamePad();

            Console.CursorVisible = false;
            Task.Run(() => gamepadConsole.Start());


            var mC = new MotionController(displayConsole, gamepadConsole, map, Bomber, mapManager);

            mC.SetPositionForPerson(4, 2);
            mC.SetPositionForPerson(3, 2);
            mC.SetPositionForPerson(2, 1);
            displayConsole.DrawMap();

            //  mC.SetPositionForPerson(3, 3);
            displayConsole.ShowLive(Bomber.LiveCount);
            Console.WindowLeft = 0;
            Console.WindowTop  = 0;

            mC.Start();

            //   Console.ReadKey();
        }
Exemplo n.º 10
0
 public void List()
 {
     while (true)
     {
         ConsoleDisplay.Print();
         ConsoleDisplay.ReceiveInput();
     }
 }
 private void ConstArithmatickTest()
 {
     unchecked
     {
         const int E_FAIL = (int)0x80004005;
         ConsoleDisplay.ShowObject(E_FAIL, nameof(E_FAIL));
     }
 }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            Console.WriteLine("Bubble Sorting .. ");
            BubbleSort bubbleSort = new BubbleSort();

            bubbleSort.performSort();
            ConsoleDisplay.Display("Bubble Sort", bubbleSort.OutputArray);
        }
Exemplo n.º 13
0
        private void PropertyTest()
        {
            var tst = new InterfaceImplementerPair();

            ConsoleDisplay.ShowObject(tst.Test, nameof(tst));
            //tst.Test = "sam";
            //ConsoleDisplay.ShowObject(tst.Test, nameof(tst));
        }
Exemplo n.º 14
0
        }         // CheckDescendents

        public void CheckBuriedPromotionGroup(int indent, string promotionGroup)
        {
            PvcsArchiveRevisionDetail highestRevisionWithPromotionGroup = PvcsArchiveRevisionDetailCollection.HighestRevisionWithPromotionGroup(promotionGroup);

            if (highestRevisionWithPromotionGroup != null)
            {
                // A revision with this Promotion Group exists

                // Check all other higher Promotion Groups

                // Check up to but not including the specified Promotion Group
                int maximumHierarchyIndex = PvcsCompleteSystemArchiveDetail.PromotionGroupDetailCollection.HierarchyIndex(promotionGroup) - 1;

                for (int hierarchyIndex = PvcsPromotionGroupDetailCollection.DevelopmentHierarchyBaseIndex;
                     hierarchyIndex < maximumHierarchyIndex;
                     ++hierarchyIndex)
                {
                    string higherPromotionGroup = PvcsCompleteSystemArchiveDetail.PromotionGroupDetailCollection.PromotionGroupName(hierarchyIndex);
                    PvcsArchiveRevisionDetail higherRevisionWithPromotionGroup = PvcsArchiveRevisionDetailCollection.HighestRevisionWithPromotionGroup(higherPromotionGroup);
                    if (higherRevisionWithPromotionGroup != null)
                    {
                        bool specifiedPromotionGroupOnSameBranch =
                            PvcsArchiveRevisionDetailCollection.RevisionsOnTheSameBranch(
                                highestRevisionWithPromotionGroup.RevisionNumber,
                                higherRevisionWithPromotionGroup.RevisionNumber);

                        if (!specifiedPromotionGroupOnSameBranch)
                        {
                            Console.WriteLine("\"{0}\" has both {1} at r{2} and {3} at r{4}",
                                              highestRevisionWithPromotionGroup.ArchiveName,
                                              highestRevisionWithPromotionGroup.PromotionGroup,
                                              highestRevisionWithPromotionGroup.RevisionNumber,
                                              higherRevisionWithPromotionGroup.PromotionGroup,
                                              higherRevisionWithPromotionGroup.RevisionNumber);
                            Console.WriteLine("{0}Is not on the same branch", ConsoleDisplay.Indent(indent));
                        }
                        else
                        {
                            bool specifiedPromotionGroupAtHigherRevision =
                                PvcsArchiveRevisionDetailCollection.RevisionNumberIsGreater(
                                    highestRevisionWithPromotionGroup.RevisionNumber,
                                    higherRevisionWithPromotionGroup.RevisionNumber);
                            if (!specifiedPromotionGroupAtHigherRevision)
                            {
                                Console.WriteLine("\"{0}\" has both {1} at r{2} and {3} at r{4}",
                                                  highestRevisionWithPromotionGroup.ArchiveName,
                                                  highestRevisionWithPromotionGroup.PromotionGroup,
                                                  highestRevisionWithPromotionGroup.RevisionNumber,
                                                  higherRevisionWithPromotionGroup.PromotionGroup,
                                                  higherRevisionWithPromotionGroup.RevisionNumber);
                                Console.WriteLine("{0}Is not at a higher revision", ConsoleDisplay.Indent(indent));
                            }
                        }
                    }
                }
            } // A revision with this Promotion Group exists
        }
Exemplo n.º 15
0
 public Game()
 {
     Board       = new Board();
     Players     = new Player[2];
     Players[0]  = new Player(true);
     Players[1]  = new Player(false);
     GameDisplay = new ConsoleDisplay();
     Clock       = new Clock();
 }
Exemplo n.º 16
0
            public bool Execute(ConsoleDisplay console, string configurationFile)
            {
                if (!lastResult.HasValue)
                {
                    lastResult = _inner.Execute(console, configurationFile);
                }

                return(lastResult.Value);
            }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            var display = new ConsoleDisplay();

            display.DisplayPrice(new Price(133750));
            Console.WriteLine("Press any key to exit...");

            Console.ReadKey();
        }
Exemplo n.º 18
0
        public void ValidateRawData_ValidData_Pass(byte[] data)
        {
            var output = new ConsoleDisplay();
            var obj    = new Validator(output);

            var result = obj.ValidateRawData(data);

            Assert.IsTrue(result);
        }
Exemplo n.º 19
0
        private void NullGuidTest()
        {
            Guid?testGuid = null;
            //var result = testGuid.IsNullOrEmpty();
            Guid guid2  = Guid.NewGuid();
            var  result = guid2.IsNullOrEmpty();

            ConsoleDisplay.ShowObject(result, nameof(result));
        }
Exemplo n.º 20
0
        static void Main(string[] args)
        {
            var memory = new MemoryRepository();
            var output = new ConsoleDisplay();
            var input  = new ConsoleController();
            var game   = new TicTacToe(memory, output, input);

            game.Start();
        }
Exemplo n.º 21
0
        public void Setup()
        {
            //arrange
            uut = new ConsoleDisplay();

            output = new StringWriter();

            Console.SetOut(output);
        }
Exemplo n.º 22
0
 public void Display(int indent)
 {
     Console.WriteLine();
     Console.WriteLine("{0}{1}", ConsoleDisplay.Indent(indent), Name);
     foreach (PvcsArchiveRevisionDetail pvcsArchiveRevisionDetail in PvcsArchiveRevisionDetailCollection)
     {
         pvcsArchiveRevisionDetail.Display(indent + 1, false);
     }
 }
Exemplo n.º 23
0
        public static bool CreateAndSwitchToBranch(string branchName, string rootWorkingDirectory, int indent, CommandOperation.DebugProgress debugProgress)
        {
            bool success = false;

            if (CheckedOutBranchIs(branchName, rootWorkingDirectory))
            {
                // Already on the specified branch
                success = true;
            }
            else
            {
                // Create the branch

                List <string> standardOutput = new List <string>();
                List <string> standardError  = new List <string>();

                string command = "git branch " + branchName;
                success = CommandOperation.RunMonitoredCommand(rootWorkingDirectory,
                                                               command,
                                                               indent,
                                                               debugProgress,
                                                               CommandOperation.CommandOutputDisplayType.StandardOutputAndStandardError,
                                                               standardOutput,
                                                               standardError);
                if (!success)
                {
                    // Check that the error was a real error and not just that the branch already existed
                    if (standardOutput.Count >= 1)
                    {
                        if (standardOutput[0].StartsWith("fatal: A branch named"))
                        {
                            Console.WriteLine("{0}The failure of the creation of branch \"{1}\" is not an error because a branch of that name already exists", ConsoleDisplay.Indent(indent), branchName);
                            success = true;
                        }
                    }
                }

                if (success)
                {
                    // Switch to the branch

                    success = CheckOutBranch(branchName, rootWorkingDirectory, indent, debugProgress);
                } // Switch to the branch
            }     // Create the branch

            if (success)
            {
                Console.WriteLine("{0}Staging to branch \"{1}\"", ConsoleDisplay.Indent(indent + 1), branchName);
            }
            else
            {
                Console.WriteLine("{0}*** Failed to switch to branch \"{1}\"", ConsoleDisplay.Indent(indent + 1), branchName);
            }

            return(success);
        } // CreateAndSwitchToBranch
Exemplo n.º 24
0
        private void EmptyQueryStringTest()
        {
            var parameters = new Dictionary <string, string>
            {
            };
            var path         = "emptyParamTest";
            var pathAndQuery = path.AddQueryString(parameters);

            ConsoleDisplay.ShowObject(pathAndQuery, nameof(pathAndQuery));
        }
Exemplo n.º 25
0
        private static async Task ConsoleDisplayDemoAsync(string[] args)
        {
            using var display = new ConsoleDisplay();

            display.DrawFrame(0, 2, 4, 4);
            display.DrawFrame(5, 2, 8, 4);

            // display.Flush();
            await Task.Delay(TimeSpan.FromSeconds(5));
        }
Exemplo n.º 26
0
        public void StringGridHasEmptyCellsByDefault()
        {
            World          world          = new World();
            ConsoleDisplay consoleDisplay = new ConsoleDisplay();

            consoleDisplay.GetStringGrid(world);
            string[,] grid = consoleDisplay.GetGrid();

            Assert.AreEqual(deadCellString, grid[0, 0]);
        }
Exemplo n.º 27
0
        public void OnTimeout(PingTimeout timeout)
        {
            ConsoleDisplay.Timeout(timeout.SequenceNumber);

            if (Attributes.BeepMode == 1)
            {
                try { Console.Beep(); }
                catch (Exception) { }
            }
        }
Exemplo n.º 28
0
        private void IPAddressTest()
        {
            var ip      = "13.68.136.211/8";
            var address = IPAddressRange.Parse(ip);

            ConsoleDisplay.ShowObject(address, nameof(address));
            var shouldPerformSSO = ShouldPerformSSO("::1");

            ConsoleDisplay.ShowObject(shouldPerformSSO, nameof(shouldPerformSSO));
        }
        private void RecoverTextPage(Document ebook, Page page)
        {
            string pageName = $"page{this.PageCounter}.xhtml";

            ebook.AddXhtmlData(pageName, File.ReadAllText(page.Path));
            ebook.AddNavPoint(page.Title.IsEmpty() ? $"Chapter {this.PageCounter}" : page.Title, pageName, this.NavCounter++);

            ConsoleDisplay.MainMessage(this._entry, $"Completed Page {this.PageCounter}");
            this.PageCounter++;
        }
Exemplo n.º 30
0
        private void UriBuilderTest()
        {
            //Uri url = new Uri("http://localhost/rest/something/browse").
            Uri url = new Uri("/Shared/Error").
                      AddQueryStringParam("page", "0").
                      AddQueryStringParam("pageSize", "200");

            ConsoleDisplay.ShowObject(url, nameof(url));
            url = url.AddQueryStringParam("id", 555.ToString());
            ConsoleDisplay.ShowObject(url, nameof(url));
        }
 public void Display(int indent, bool displayArchiveName)
 {
     if (!displayArchiveName)
     {
         Console.WriteLine("{0}{1} {2} {3} {4:6} {5}", ConsoleDisplay.Indent(indent), RevisionNumber, PromotionGroup, DeveloperId, (String.IsNullOrEmpty(IssueNumber) ? "\"\"" : IssueNumber), Description);
     }
     else
     {
         Console.WriteLine("{0}{1} {2} {3} {4} {5:6} {6}", ConsoleDisplay.Indent(indent), ArchiveName, RevisionNumber, PromotionGroup, DeveloperId, (String.IsNullOrEmpty(IssueNumber) ? "\"\"" : IssueNumber), Description);
     }
 }
 protected override Display ADisplay()
 {
     var display = new ConsoleDisplay();
     return display;
 }