Пример #1
0
        /// <summary>
        /// Writes an exception to the console.
        /// </summary>
        /// <param name="obj">The object the exception originated from. Can be null.</param>
        /// <param name="ex">The exception being written.</param>
        /// <param name="message">The message to write before the exception.</param>
        /// <param name="args">Optional arguments to use when formatting the message.</param>
        public static void WriteException(object obj, Exception ex, string message, params object[] args)
        {
            if (Options.Instance.DebugLevels.Contains(DebugLevels.Exception) && IsValid(obj))
            {
                var sb = new StringBuilder();
                if (!isLastWriteALine)
                {
                    isLastWriteALine = true;
                    ConsoleBase.WriteLine();
                }

                var header = GetMessageHeader(obj, true, true);

                message = Formatters.GetColorFormattedString(ConsoleBase.Colors.Exception, message, args);

                sb.AppendFormat("{0}{1}", header, message);

                int exceptionIndex = 0;

                var exceptionFormat = ConsoleBase.Colors.Exception;

                while (ex != null)
                {
                    exceptionIndex++;
                    sb.Append(exceptionFormat.FormatText(false, "{1}--------Exception {0}--------{1}", exceptionIndex, ConsoleBase.NewLine));
                    sb.AppendFormat("{0}", ex.ToString().Replace(Environment.NewLine, ConsoleBase.NewLine));
                    sb.Append(exceptionFormat.FormatText(true, "{0}-----------------------------", ConsoleBase.NewLine));
                    ex = ex.InnerException;
                }

                ForceWriteLine(
                    Formatters.GetColorFormattedString(ConsoleBase.Colors.Exception, sb.ToString()));
            }
        }
Пример #2
0
 /// <summary>
 /// Writes an uncategorized message to the console, with no header and no additional color formatting applied.
 /// </summary>
 /// <param name="message">The message to write.</param>
 /// <param name="args">Optional arguments to use when formatting the message.</param>
 public static void WriteLine(string message, params object[] args)
 {
     if (Options.Instance.DebugLevels.Contains(DebugLevels.Uncategorized))
     {
         isLastWriteALine = true;
         ConsoleBase.WriteLine(message, args);
     }
 }
        /// <summary>
        /// Dumps the specified object to the console.
        /// </summary>
        /// <param name="obj">The object to dump to the console.</param>
        public static void Dump(this object obj)
        {
            if (Crestron.SimplSharp.CrestronEnvironment.ProgramCompatibility == Crestron.SimplSharp.eCrestronSeries.Series3)
            {
                ConsoleBase.WriteLine();
            }

            ConsoleBase.WriteNoHeader(Terminal.Formatting.Formatters.FormatObjectForConsole(obj));
        }
Пример #4
0
        /// <summary>
        /// Dumps the specified object to the console.
        /// </summary>
        /// <param name="obj">The object to format details about.</param>
        /// <param name="maxDepth">The maximum number of times to recurse on complex objects.
        /// <para>A value of 1 would indicate dumping the top-level properties on the object provided,
        /// while ignoring properties that are complex objects with additional properties of their own.</para>
        /// <para>A value of 0 indicates no max depth.</para>
        /// </param>
        /// <param name="useFullTypeNames"><see langword="true"/> to use an object's fully qualified
        /// name, otherwise just the short name.</param>
        /// <typeparam name="T">The type of the object being dumped.</typeparam>
        /// <returns>The object being dumped.</returns>
        public static T Dump <T>(this T obj, int maxDepth, bool useFullTypeNames)
        {
            if (Crestron.SimplSharp.CrestronEnvironment.ProgramCompatibility == Crestron.SimplSharp.eCrestronSeries.Series3)
            {
                ConsoleBase.WriteLine();
            }

            ConsoleBase.WriteNoHeader(Terminal.Formatting.Formatters.FormatObjectForConsole(obj, maxDepth, useFullTypeNames));
            return(obj);
        }
Пример #5
0
 public void SampleTable(
     [Operand("min", "Sets the minimum width the cells can be.")] int minWidth)
 {
     ConsoleBase.WriteLine();
     ConsoleBase.WriteLineNoHeader(Table.Create()
                                   .SetMinimumColumnWidth(minWidth)
                                   .AddColumnWithHeader("Device", "Touchpanel", "DSP", "Codec", "Display 1", "Display 2")
                                   .AddColumnWithHeader("Status", "Online", "Online", "Offline", "Offline", "Online")
                                   .FormatHeaders(ConsoleBase.Colors.BrightYellow, HorizontalAlignment.Center)
                                   .FormatColumn(0, ConsoleBase.Colors.BrightCyan, HorizontalAlignment.Right)
                                   .ForEachCellInColumn(1, c => c.Color = c.Contents == "Offline" ? ConsoleBase.Colors.BrightRed : ConsoleBase.Colors.BrightGreen).ToString());
 }
        public void When_ConsoleBaseOptionalHeader_IsNotEmpty_PrefixWritten()
        {
            ConsoleBase.WriteLine();
            var expectedHeader = "[OptionalHeader]";

            ConsoleBase.OptionalHeader = expectedHeader;
            var expectedContents = "Test Message";

            Debug.WriteLine("");
            Debug.WriteLine(this, Evands.Pellucid.Terminal.ColorCode.None, expectedContents);
            var msg = writer.Messages.Last();

            Trace.WriteLine(msg);
            Assert.IsTrue(msg.Contains(expectedHeader), "Starts incorrectly.");
            Assert.IsTrue(msg.Contains(expectedContents), "Doesn't contain message.");
        }
Пример #7
0
 public void DumpOptions(
     [Flag("full", 'f', "Writes type names with their full name.", true)] bool full)
 {
     ConsoleBase.WriteLine();
     Evands.Pellucid.Options.Instance.Dump(full);
 }
 public void DumpOptions()
 {
     ConsoleBase.WriteLine();
     Evands.Pellucid.Options.Instance.Dump();
 }
Пример #9
0
        /// <summary>
        /// Performs initialisation of the world, such as loading configuration from disk.
        /// </summary>
        public virtual void StartUp()
        {
            this.regionData = new RegionInfo();
            try
            {
                this.localConfig = new XmlConfig(m_config);
                this.localConfig.LoadData();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            m_console.WriteLine("Main.cs:Startup() - Loading configuration");
            this.regionData.InitConfig(this.m_sandbox, this.localConfig);
            this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change


            GridServers = new Grid();
            if (m_sandbox)
            {
                GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
                GridServers.GridDll  = "OpenSim.GridInterfaces.Local.dll";

                m_console.WriteLine("Starting in Sandbox mode");
            }
            else
            {
                if (this.gridLocalAsset)
                {
                    GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
                }
                else
                {
                    GridServers.AssetDll = "OpenSim.GridInterfaces.Remote.dll";
                }
                GridServers.GridDll = "OpenSim.GridInterfaces.Remote.dll";

                m_console.WriteLine("Starting in Grid mode");
            }

            try
            {
                GridServers.Initialise();
            }
            catch (Exception e)
            {
                m_console.WriteLine(e.Message + "\nSorry, could not setup the grid interface");
                Environment.Exit(1);
            }

            startuptime = DateTime.Now;

            try
            {
                AssetCache     = new AssetCache(GridServers.AssetServer);
                InventoryCache = new InventoryCache();
            }
            catch (Exception e)
            {
                m_console.WriteLine(e.Message + "\nSorry, could not setup local cache");
                Environment.Exit(1);
            }

            //should be passing a IGenericConfig object to these so they can read the config data they want from it
            GridServers.AssetServer.SetServerInfo(regionData.AssetURL, regionData.AssetSendKey);
            IGridServer gridServer = GridServers.GridServer;

            gridServer.SetServerInfo(regionData.GridURL, regionData.GridSendKey, regionData.GridRecvKey);

            this.physManager = new OpenSim.Physics.Manager.PhysicsManager();
            this.physManager.LoadPlugins();

            this.CustomiseStartup();

            m_console.WriteLine("Main.cs:Startup() - Initialising HTTP server");
            // HttpServer = new SimCAPSHTTPServer(GridServers.GridServer, Cfg.IPListenPort);

            BaseHttpServer httpServer       = new BaseHttpServer(regionData.IPListenPort);
            LoginServer    loginServer      = null;
            LoginServer    adminLoginServer = null;

            bool sandBoxWithLoginServer = m_loginserver && m_sandbox;

            if (sandBoxWithLoginServer)
            {
                loginServer = new LoginServer(gridServer, regionData.IPListenAddr, regionData.IPListenPort, regionData.RegionLocX, regionData.RegionLocY, this.user_accounts);
                loginServer.Startup();

                if (user_accounts)
                {
                    //sandbox mode with loginserver using accounts
                    this.GridServers.UserServer = loginServer;
                    adminLoginServer            = loginServer;

                    httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod);
                }
                else
                {
                    //sandbox mode with loginserver not using accounts
                    httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod);
                }
            }

            AdminWebFront adminWebFront = new AdminWebFront("Admin", LocalWorld, InventoryCache, adminLoginServer);

            adminWebFront.LoadMethods(httpServer);

            m_console.WriteLine("Main.cs:Startup() - Starting HTTP server");
            httpServer.Start();

            MainServerListener();

            m_heartbeatTimer.Enabled  = true;
            m_heartbeatTimer.Interval = 100;
            m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
        }
Пример #10
0
 public void Test()
 {
     ConsoleBase.WriteLine("Default test command executed.");
 }
Пример #11
0
 public void VerbThree()
 {
     ConsoleBase.WriteLine("Does some default thing.");
 }
Пример #12
0
 public void VerbTwo()
 {
     ConsoleBase.WriteLine("Does some thing2.");
 }
Пример #13
0
 public void VerbOne()
 {
     ConsoleBase.WriteLine("Does some thing.");
 }
 public void TestFlagHelp(
     [Flag("fluff", "Indicates fluff.")] string fluff,
     [Flag("stuff", 's', "Indicates stuff.", true)] string stuff)
 {
     ConsoleBase.WriteLine("Fluff: '{0}' and Stuff: '{1}'.", fluff, stuff);
 }
 public void TestOperandHelp(
     [Operand("fluff", "Provides fluff.")] string fluff,
     [Operand("stuff", "Provides stuff.")] string stuff)
 {
     ConsoleBase.WriteLine("Fluff: '{0}' and Stuff: '{1}'.", fluff, stuff);
 }
 public void TestStuff(
     [Flag("fluff", 'f', "Just a fluff flag.")] bool fluff)
 {
     ConsoleBase.WriteLine("Does Fluffy Stuff.");
 }