refactor(demos): update machining demos and remove legacy demo message handling
Made-with: Cursor
This commit is contained in:
parent
96eb6ad050
commit
e5ea1961a5
@ -1,57 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Hi.Common;
|
|
||||||
using Hi.Common.Messages;
|
|
||||||
|
|
||||||
namespace Sample.Common;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Demonstrates common message and exception handling patterns in HiAPI applications
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// ### Source Code
|
|
||||||
/// [!code-csharp[SampleCode](~/../Hi.Sample/Common/DemoMessageAndExceptionHandling.cs)]
|
|
||||||
/// </remarks>
|
|
||||||
public static class DemoMessageAndExceptionHandling
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Demonstrates normal message handling
|
|
||||||
/// </summary>
|
|
||||||
internal static void DemoNormalMessages()
|
|
||||||
{
|
|
||||||
#region Normal_Messages
|
|
||||||
MessageUtil.ReportMessage("Operation completed successfully.");
|
|
||||||
MessageUtil.ReportWarning("Please check your input.");
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Demonstrates exception handling in synchronous code
|
|
||||||
/// </summary>
|
|
||||||
internal static void DemoSynchronousExceptionHandling()
|
|
||||||
{
|
|
||||||
#region Sync_Exception
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Your code here
|
|
||||||
throw new NotImplementedException("Demo exception");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
ExceptionUtil.ShowException(ex, null);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Demonstrates exception handling in asynchronous code
|
|
||||||
/// </summary>
|
|
||||||
internal static async Task DemoAsynchronousExceptionHandling()
|
|
||||||
{
|
|
||||||
#region Async_Exception
|
|
||||||
await Task.Run(() =>
|
|
||||||
{
|
|
||||||
// Your async operation here
|
|
||||||
throw new NotImplementedException("Demo async exception");
|
|
||||||
}).ShowIfCatched(null);
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -18,7 +18,8 @@ namespace Sample
|
|||||||
static int Main(string[] args)
|
static int Main(string[] args)
|
||||||
{
|
{
|
||||||
Console.WriteLine("HiAPI starting.");
|
Console.WriteLine("HiAPI starting.");
|
||||||
LocalApp.AppBegin();
|
using var loggerFactory = Microsoft.Extensions.Logging.LoggerFactory.Create(b => b.AddConsole());
|
||||||
|
LocalApp.AppBegin(loggerFactory.CreateLogger("Hi.Sample"));
|
||||||
|
|
||||||
Console.WriteLine("Hello World! HiAPI.");
|
Console.WriteLine("Hello World! HiAPI.");
|
||||||
|
|
||||||
|
|||||||
@ -42,7 +42,8 @@ public static class DemoBuildGeomOnlyMachiningProject
|
|||||||
|
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
LocalApp.AppBegin();
|
using var loggerFactory = Microsoft.Extensions.Logging.LoggerFactory.Create(b => b.AddConsole());
|
||||||
|
LocalApp.AppBegin(loggerFactory.CreateLogger("Hi.Sample"));
|
||||||
LocalProjectService localProjectService = new LocalProjectService();
|
LocalProjectService localProjectService = new LocalProjectService();
|
||||||
|
|
||||||
var projectPath = "C:/HiNC-Projects/NewProject/Main.hincproj";
|
var projectPath = "C:/HiNC-Projects/NewProject/Main.hincproj";
|
||||||
|
|||||||
@ -142,7 +142,8 @@ public static class DemoBuildMachiningProject
|
|||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
LocalApp.AppBegin();
|
using var loggerFactory = Microsoft.Extensions.Logging.LoggerFactory.Create(b => b.AddConsole());
|
||||||
|
LocalApp.AppBegin(loggerFactory.CreateLogger("Hi.Sample"));
|
||||||
LocalProjectService localProjectService = new LocalProjectService();
|
LocalProjectService localProjectService = new LocalProjectService();
|
||||||
|
|
||||||
var projectPath = "C:/HiNC-Projects/NewProject/Main.hincproj";
|
var projectPath = "C:/HiNC-Projects/NewProject/Main.hincproj";
|
||||||
|
|||||||
@ -21,7 +21,8 @@ public static class DemoUseMachiningProject
|
|||||||
{
|
{
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
LocalApp.AppBegin();
|
using var loggerFactory = Microsoft.Extensions.Logging.LoggerFactory.Create(b => b.AddConsole());
|
||||||
|
LocalApp.AppBegin(loggerFactory.CreateLogger("Hi.Sample"));
|
||||||
LocalProjectService localProjectService = new LocalProjectService();
|
LocalProjectService localProjectService = new LocalProjectService();
|
||||||
|
|
||||||
#region ProjectLoading
|
#region ProjectLoading
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user