コード例 #1
0
        protected override void Run()
        {
            FormatManager.WriteFormatted("<default>Enter Command: </default>");
            var input = Console.ReadLine();

            if (input == "version")
            {
                Console.WriteLine("Beta 0.1");
            }
            else if (input == "memory get")
            {
                Console.WriteLine("Memory: " + MemoryManager.GetFreeMemory() + " Bytes Free, " + MemoryManager.GetUsedMemory() + " Bytes in use");
            }
            else if (input == "memory allocate")
            {
                if (input.Substring(15).Contains("1") || input.Substring(15).Contains("2") || input.Substring(15).Contains("3") || input.Substring(15).Contains("4") || input.Substring(15).Contains("5") || input.Substring(15).Contains("6") || input.Substring(15).Contains("7") || input.Substring(15).Contains("8") || input.Substring(15).Contains("9") || input.Substring(15).Contains("0"))
                {
                    uint allocate;
                    UInt32.TryParse(input.Substring(15), out allocate);
                    if (allocate < MemoryManager.GetFreeMemory())
                    {
                        allocatedBlocks.Add(new ManagedMemoryBlock(allocate));
                        Console.WriteLine("Allocated " + allocate + " Bytes");
                    }
                    else
                    {
                        Console.WriteLine("<red>Not enough memory available</red>");
                    }
                }
                else
                {
                    FormatManager.WriteFormattedLine("<red>Error: No value passed</red>");
                }
            }
            else if (input == "clear")
            {
                Console.Clear();
            }
            else if (input == "shutdown")
            {
                Sys.Power.Shutdown();
            }
            else if (input == "reboot")
            {
                Sys.Power.Reboot();
            }
            else if (input == "help")
            {
                Console.WriteLine("Availible Commands");
                Console.WriteLine();
                Console.WriteLine("version - prints version of os");
                Console.WriteLine("memory get - returns current available memory");
                Console.WriteLine("memory allocate <bytes> - allocates a block of memory");
                Console.WriteLine("clear - clears console");
                Console.WriteLine("shutdown - shuts down the computer");
                Console.WriteLine("reboot - reboots the computer");
                Console.WriteLine("help - prints this guide");
            }
            else
            {
                FormatManager.WriteFormattedLine("<red>Invalid Command: Try using the help command</red>");
            }
        }