case в case (космос c#)

Задача не из легких, не все знают эту библиотеку: Cosmos User Kit (Kernel C#)

мне нужно поместить case в case

у меня есть код:

case "@terminal":
    Console.ForegroundColor = ConsoleColor.White;
    Console.WriteLine("Next Dos [Version 1.0.1]\r\n(c) Corporation PAXINVEST (PAXINVEST Corporation). All rights are secured.");
    Console.ForegroundColor = ConsoleColor.Yellow;
    Console.Write("$comand$: ");
    Console.ForegroundColor = ConsoleColor.White;
    Commands();
    break;

мне нужно, что бы условия ввода (команда) (сase) создавалась уже существующей команде.

Каламбур выходит...

То есть, у меня есть кейс при котором меня якобы кидает в терминал

Если я сделаю просто команду для терминала, то я ее смогу вводить просто так, без префикса из предыдущей команды.

Мне нужно сделать команду в команде или построить какой то if?

Спасибо.


Отвечая на вопросы:

  1. Я не знаю причем тут метка "ядро". Я написал снизу сишарп и Kernel.
  2. вот мой код, и говорите что команды мои не в кейсе? странно, ведь все работает.
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading;
using Sys = Cosmos.System;

namespace PaxOS
{
    public class Kernel : Sys.Kernel
    {
        Sys.FileSystem.CosmosVFS fs;
        string currentdirectory = @"0:\";
        protected override void BeforeRun()
        {
            // Перед запуском
            fs = new Sys.FileSystem.CosmosVFS();
            Sys.FileSystem.VFS.VFSManager.RegisterVFS(fs);
            Thread.Sleep(2000);
            Console.Clear();
            ClearConsole();
            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.WriteLine("===================================================");
            Console.ForegroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine("        WELCOME TO NEXT-DOS OPERATION SYSTEM!");
            Console.ForegroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.WriteLine("===================================================");
            Console.ForegroundColor = ConsoleColor.White;   
        }

        protected override void Run()
        {
            // Після запуску
            Console.ForegroundColor = ConsoleColor.DarkMagenta;
            Console.Write("$NEXT-DOS$: ");
            Console.ForegroundColor = ConsoleColor.White;
            Commands();
        }
        public void Commands()
        {
            string filename = "";
            string dirname = "";
            var input = Console.ReadLine();
            switch (input)
            {
                default:
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(input + ": Unknown command");
                    Console.ForegroundColor = ConsoleColor.White;
                    break;
                case "@clearc":
                    ClearConsole();
                    break;
                case "#help":
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    Console.WriteLine("====================HELP COMMANDS=========================");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    Console.WriteLine("====================INFO COMMANDS=========================");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("           #help - help commands center");
                    Console.WriteLine("           #info - about operation system");
                    Console.WriteLine("           #datetime - current date and time");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    Console.WriteLine("=====================GLOBAL COMMANDS======================");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("           @calc - open calculator app");
                    Console.WriteLine("           @note - open notebook app");
                    Console.WriteLine("           @browser - open browser app");
                    Console.WriteLine("           @settings - open settings");
                    Console.WriteLine("           @app - open app. Use it with @app name.pck");
                    Console.WriteLine("           @explorer - manage files");
                    Console.WriteLine("           @clearc - clear console");
                    Console.WriteLine("           @terminal - open the terminal");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    Console.WriteLine("=====================SHLUSE(PREMIUM) COMMANDS==============");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    Console.WriteLine("======================SYSTEM COMMANDS=====================");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("           *shutdown - shutdown system");
                    Console.WriteLine("           *reboot - reboot system");
                    Console.ForegroundColor = ConsoleColor.White;
                    break;
                case "@terminal":
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("Next Dos [Version 1.0.1]\r\n(c) Corporation PAXINVEST (PAXINVEST Corporation). All rights are secured.");
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.Write("$comand$: ");
                    Console.ForegroundColor = ConsoleColor.White;
                    Commands();
                    break;
                case "#datetime":
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.WriteLine(DateTime.Now);
                    Console.ForegroundColor = ConsoleColor.White;
                    break;
                case "#info":
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.WriteLine("ABOUT NEXT-DOS");
                    Console.WriteLine("This operating system was made in the C#, CosmosKernel programming language. This operating system is very easy to learn. In the list of commands that can be obtained by the help command, you can find commands after entering which you will receive an appropriate response. Yes, by entering the calc (calculator) command, you can launch the calculator, etc. We would like to point out that this is the very first version. Next, we plan to release a more complete NEXT-DOS OS. Also in the future we want to implement a graphic shell for NEXT-DOS, NEXT-DOS2, NEXT-DOSme(home ver.), NEXT-DOS-AA(corp.ver.) and NEXT redistributable x32/x64/x86');\r\n ");
                    Console.ForegroundColor = ConsoleColor.White;
                    break;
                case "@calc":
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("Type a number and action(+-*/)");
                    Console.ForegroundColor = ConsoleColor.White;
                    break;
                case "*shutdown":
                    Console.ForegroundColor = ConsoleColor.DarkRed;
                    Console.WriteLine("System is going down, please wait...");
                    Thread.Sleep(2000);
                    Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("ram"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("ok");
                    Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("cpu"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("ok");
                    Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("system"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("ok");
                    Thread.Sleep(2000);
                    Cosmos.System.Power.Shutdown();
                    Console.ForegroundColor = ConsoleColor.White;
                    break;
                case "*reboot":
                    Console.ForegroundColor = ConsoleColor.DarkRed;
                    Console.WriteLine("System is going to reboot, please wait...");
                    Thread.Sleep(4000);
                    Cosmos.System.Power.Reboot();
                    Console.ForegroundColor = ConsoleColor.White;
                    break;
                case "@settings":
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    Console.WriteLine("===================================================");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("Your PC information:");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.Gray;
                    string CPUbrand = Cosmos.Core.CPU.GetCPUBrandString();
                    string CPUvendor = Cosmos.Core.CPU.GetCPUVendorName();
                    uint amount_of_ram = Cosmos.Core.CPU.GetAmountOfRAM();
                    ulong available_ram = Cosmos.Core.GCImplementation.GetAvailableRAM();
                    uint UsedRam = Cosmos.Core.GCImplementation.GetUsedRAM();
                    Console.WriteLine(@"CPU: {0}
CPU Vendor: {1}
Amount of RAM: {2}
Available RAM: {3}
Used RAM: {4}", CPUbrand, CPUvendor, amount_of_ram, available_ram, UsedRam);
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    Console.WriteLine("===================================================");
                    Console.ForegroundColor = ConsoleColor.White;
                    break;
                case "@explorer":
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("Explorer commands: +file (add file) -file (delete file) ^files (list of files) || +dir (add directory) -dir (delete directory) ^dir (list of directores)");
                    Console.ForegroundColor = ConsoleColor.White;
                    break;
                case "+file":
                    filename = Console.ReadLine();
                    fs.CreateFile(currentdirectory + filename);
                    break;
                case "+dir":
                    dirname = Console.ReadLine();
                    fs.CreateDirectory(currentdirectory + dirname);
                    break;
                case "-file":
                    Sys.FileSystem.VFS.VFSManager.DeleteFile(currentdirectory + filename);
                    break;
                case "-dir":
                    Sys.FileSystem.VFS.VFSManager.DeleteFile(currentdirectory + dirname);
                    break;
                case "^dir":
                    currentdirectory = Console.ReadLine();
                    break;
                case "dir":
                    try
                    {
                        var directory_list = Sys.FileSystem.VFS.VFSManager.GetDirectoryListing(currentdirectory);
                        foreach (var directoryEntry in directory_list)
                        {
                            try
                            {
                                var entry_type = directoryEntry.mEntryType;
                                if (entry_type == Sys.FileSystem.Listing.DirectoryEntryTypeEnum.File)
                                {
                                    Console.ForegroundColor = ConsoleColor.Magenta;
                                    Console.WriteLine("| <File>       " + directoryEntry.mName);
                                    Console.ForegroundColor = ConsoleColor.White;
                                }
                                if (entry_type == Sys.FileSystem.Listing.DirectoryEntryTypeEnum.Directory)
                                {
                                    Console.ForegroundColor = ConsoleColor.Blue;
                                    Console.WriteLine("| <Directory>      " + directoryEntry.mName);
                                    Console.ForegroundColor = ConsoleColor.White;
                                }
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine("Error: Directory not found");
                                Console.WriteLine(e.ToString());
                            }

                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                        break;
                    }
                    break;
            }
        }
        public void ClearConsole()
        {
            Console.Clear();
            Console.BackgroundColor = ConsoleColor.White;
            Console.WriteLine("NEXT-DOS OS                                                  " + DateTime.Now);
            Console.BackgroundColor = ConsoleColor.Black;
        }
    }
}

Ответы (0 шт):