Table of Contents

General Rules

This document describes the common patterns and conventions used throughout the HiNC GUI codebase.

Message and Exception Handling

The HiNC applications use MessageHost to display user-facing messages, and ExceptionUtil.ShowException(Exception, object) to handle exceptions with detailed treatment. All messages are displayed in the Message Section on Main Panel.

For examples of message and exception handling patterns:

  1. Normal message handling:
MessageHost.AddMessage("Operation completed successfully.");
MessageHost.AddWarning("Please check your input.");
  1. Exception handling in synchronous code:
try
{
    // Your code here
    throw new NotImplementedException("Demo exception");
}
catch (Exception ex)
{
    ExceptionUtil.ShowException(ex, null);
}
  1. Exception handling in asynchronous code:
await Task.Run(() =>
{
    // Your async operation here
    throw new NotImplementedException("Demo async exception");
}).ShowIfCatched(null);

The examples are in project Hi.Sample. See this page for git repository.

Loose Manner

The Loose Manner pattern handles rapidly-called synchronous actions where only the last call needs to be effective.

The LooseRunner class manages skippable rapid-calling synchronous actions. When an action is called rapidly, only the last call is executed while previous calls are safely skipped. The TryRun method is used to execute actions in this manner.

The LooseRunner should be disposed when its owner is disposed to ensure proper resource cleanup.

GUI File Path Assignment

See GUI File Path Assignment.

Numeric Input/Output Handling

The numeric-utils.js module handles special floating-point values (such as NaN, Infinity) in web forms. See Numeric Input/Output Utilities for details.

Webapi with hub-cleapup assistence pattern

Webapi with hub-cleapup assistence pattern

Loose Couple

If model of the UI component is null or mismatch, apply status badge instead of throwing exception to keep UI work.

Translation Remarks

See Translation Remarks.