Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      '// --- Main Application Context ---
      '// The implicit 'uc' object is the initial default.
      uCalc.DefaultInstance.DefineConstant("PI = 3.14159")
      Console.WriteLine($"Initial Count: {uCalc.DefaultCount}")
      
      '// --- A Plugin needs a temporary, isolated context ---
      Using moduleCalc As New uCalc()
         moduleCalc.IsDefault = true '// Push the new instance onto the stack.
         Console.WriteLine($"Count after module pushes new default: {uCalc.DefaultCount}")
         
         '// The module's context is now active.
         '// uCalc::DefaultInstance() would now return 'moduleCalc'.
      End Using
      
      '// When 'moduleCalc' goes out of scope, it's destroyed and automatically
      '// removed from the stack, restoring the previous default.
      
      Console.WriteLine($"Count after module instance is disposed: {uCalc.DefaultCount}")
      
      '// Verify the original default instance is active again.
      Dim result = uCalc.DefaultInstance.EvalStr("PI")
      Console.WriteLine($"Original context restored. PI = {result}")
   End Sub
End Module