Cosmos is a backronym for the C # Open Source Managed Operating System (Rus. "Managed operating system with open source code in C #"). Cosmos is not currently seeking to become a full-fledged operating system, but rather a set of tools that allow other developers to easily create their own operating systems, or, as one project manager said, act as a “Lego-type operating system.” It also functions as an abstraction layer that hides much of the work of the internal hardware.Cosmos is a constructor that allows you to completely escape from low-level programming and write in pure C #.
using System; using System.Collections.Generic; using System.Text; using Sys = Cosmos.System; namespace CSharpKernel1 { public class Kernel : Sys.Kernel { protected override void BeforeRun() { Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back."); } protected override void Run() { Console.Write("Input: "); var input = Console.ReadLine(); Console.Write("Text typed: "); Console.WriteLine(input); } } }
using System; using System.Collections.Generic; using System.Text; using Sys = Cosmos.System; namespace CSharpKernel1 { public class Kernel : Sys.Kernel { protected override void BeforeRun() /* . . */ { Console.ForegroundColor = ConsoleColor.Green; // - Console.WriteLine("Welcome to HabrOS! Type \"help\" and then press \"ENTER\" to get some help."); // Console.ForegroundColor = ConsoleColor.White; // - , . ! Console.ResetColor() ! } protected override void Run() // , . { } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ScorpionOS { class CommandPrompt { public static void Read() { // Console.Write("->"); String ln = Console.ReadLine(); // ln switch (ln) { case "help": // Console.ForegroundColor = ConsoleColor.Cyan; // - Console.WriteLine("To run a program, type name of program and press enter."); Console.WriteLine("The following commands are available:"); Console.WriteLine("help - get help\nabout - information about the operating system\nshutdown - power off the computer\nreboot - reboot the computer"); Console.ForegroundColor = ConsoleColor.White; // break; case "about": // Console.WriteLine("HabrOS ver. 0.01 beta."); break; case "shutdown": // Cosmos.Sys.Plugs.Deboot.ShutDown(); break; case "reboot": // Cosmos.Sys.Plugs.Deboot.Reboot(); break; default: // Console.ForegroundColor = ConsoleColor.Red; //, Console.WriteLine("ERROR: Command not found"); Console.ForegroundColor = ConsoleColor.White; break; } } } }
protected override void Run() { CommandPrompt.Read(); // }
Source: https://habr.com/ru/post/176815/
All Articles