mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 05:05:05 +00:00
Created S# .sln and moved project to src folder
This commit is contained in:
109
ICD.Common/Utils/IcdConsole.cs
Normal file
109
ICD.Common/Utils/IcdConsole.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
#if SIMPLSHARP
|
||||
using Crestron.SimplSharp;
|
||||
#endif
|
||||
using ICD.Common.Properties;
|
||||
|
||||
namespace ICD.Common.Utils
|
||||
{
|
||||
public sealed class IcdConsole
|
||||
{
|
||||
public enum eAccessLevel
|
||||
{
|
||||
Operator = 0,
|
||||
Programmer = 1,
|
||||
Administrator = 2
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wraps CrestronConsole.ConsoleCommandResponse for S+ compatibility.
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="args"></param>
|
||||
[PublicAPI]
|
||||
public static void ConsoleCommandResponseLine(string message, params object[] args)
|
||||
{
|
||||
ConsoleCommandResponse(message + IcdEnvironment.NewLine, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wraps CrestronConsole.ConsoleCommandResponse for S+ compatibility.
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="args"></param>
|
||||
[PublicAPI]
|
||||
public static void ConsoleCommandResponse(string message, params object[] args)
|
||||
{
|
||||
message = string.Format(message, args);
|
||||
|
||||
#if SIMPLSHARP
|
||||
try
|
||||
{
|
||||
CrestronConsole.ConsoleCommandResponse(message);
|
||||
}
|
||||
catch (NotSupportedException)
|
||||
{
|
||||
CrestronConsole.Print(message);
|
||||
}
|
||||
#else
|
||||
System.Console.Write(message, args);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void PrintLine(string message)
|
||||
{
|
||||
#if SIMPLSHARP
|
||||
CrestronConsole.PrintLine(message);
|
||||
#else
|
||||
System.Console.WriteLine(message);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void PrintLine(string message, params object[] args)
|
||||
{
|
||||
#if SIMPLSHARP
|
||||
CrestronConsole.PrintLine(message, args);
|
||||
#else
|
||||
System.Console.WriteLine(message, args);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void Print(string message)
|
||||
{
|
||||
#if SIMPLSHARP
|
||||
CrestronConsole.Print(message);
|
||||
#else
|
||||
System.Console.Write(message);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void Print(string message, params object[] args)
|
||||
{
|
||||
#if SIMPLSHARP
|
||||
CrestronConsole.Print(message, args);
|
||||
#else
|
||||
System.Console.Write(message, args);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool SendControlSystemCommand(string command, ref string result)
|
||||
{
|
||||
#if SIMPLSHARP
|
||||
return CrestronConsole.SendControlSystemCommand(command, ref result);
|
||||
#else
|
||||
result = string.Empty;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void AddNewConsoleCommand(Action<string> callback, string command, string help, eAccessLevel accessLevel)
|
||||
{
|
||||
#if SIMPLSHARP
|
||||
CrestronConsole.AddNewConsoleCommand(str => callback(str), command, help, (ConsoleAccessLevelEnum)(int)accessLevel);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user