Overview

Namespace: TheTechIdea.Beep.Winform.Controls.Integrated.Forms.Contracts
Two interfaces define the contract between BeepBlock and BeepForms (the Coordinator host). The architecture follows a strict discipline:

  • IBeepFormsHost -- A facade that BeepBlock calls. Blocks must never dereference FormsManager directly; they must use only the proxy methods on this interface. This keeps the block-layer decoupled from the forms infrastructure.
  • IBeepFormsBootstrapper -- Initializes blocks with EntityStructure metadata from live datasources.
BeepBlock -> IBeepFormsHost (BeepForms) -> IUnitofWorksManager (FormsManager) -> IDataSource
   ^--- Block must ONLY call IBeepFormsHost, never dereference FormsManager

IBeepFormsHost: Identity & State

MemberTypeDescription
FormNamestring (get/set)Forms host identifier
ActiveBlockNamestring? (get)Currently active block's name
FormsManagerIUnitofWorksManager? (get/set)WARNING: BeepBlock must NOT call this. Use proxy methods only.
DefinitionBeepFormsDefinition? (get/set)Configuration definition for the forms host
ViewStateBeepFormsViewState (get)Current display state of the forms host
BlocksIReadOnlyList<IBeepBlockView> (get)All registered block views

IBeepFormsHost: Events (11)

EventHandler TypeDescription
ActiveBlockChangedEventHandler?Active block switched (tab change, navigation)
FormsManagerChangedEventHandler?Manager reference replaced
ViewStateChangedEventHandler?View state changed (query/insert/edit modes)
BootstrapCompletedEventHandler<BeepFormsBootstrapEventArgs>?Phase 7D: async bootstrap finished. Args include success flag and error details.
TriggerExecutingEventHandler<TriggerExecutingEventArgs>?Before trigger execution (cancelable)
TriggerExecutedEventHandler<TriggerExecutedEventArgs>?After trigger execution completes
TriggerRegisteredEventHandler<TriggerRegisteredEventArgs>?Trigger was registered for a block/event
TriggerUnregisteredEventHandler<TriggerUnregisteredEventArgs>?Trigger was removed
TriggerChainCompletedEventHandler<TriggerChainCompletedEventArgs>?Full trigger chain execution completed
BlockUnitOfWorkActivityEventHandler<BeepFormsUnitOfWorkEventArgs>?UoW state change in a block (dirty, saved, rolled back)

IBeepFormsHost: Registration & Routing

MethodReturnDescription
RegisterBlock(IBeepBlockView)boolRegister a block with the forms host
UnregisterBlock(string name)boolRemove a block by name
TrySetActiveBlock(string name)boolSwitch active block by name
SyncFromManager()voidSync block state from FormsManager
InitializeAsync(CancellationToken)Task<bool>Phase 7D async bootstrap (true=success, false=some blocks failed)

IBeepFormsHost: Block/UoW Query Proxies

MethodReturnDescription
IsBlockRegistered(string)boolCheck if block name is registered
GetBlockInfo(string)DataBlockInfo?Get block configuration info
GetBlockUnitOfWork(string)IUnitofWork?Get the unit of work for a block
GetCurrentBlockItem(string)object?Get current record from block's UoW
GetDetailBlockNames(string)IEnumerable<string>Get names of detail (child) blocks
SetBlockCurrentRecordIndex(string, int)voidNavigate to a record index
IsBlockQueryAllowed(string)boolCheck if query mode is allowed for this block
GetTriggerStatistics(string)TriggerStatisticsInfo?Get trigger execution stats for a block
GetFormLevelTriggers(string)IReadOnlyList<TriggerDefinition>Form-level trigger definitions
GetBlockLevelTriggers(string)IReadOnlyList<TriggerDefinition>Block-level trigger definitions
GetRecordLevelTriggers(string)IReadOnlyList<TriggerDefinition>Record-level trigger definitions
GetItemLevelTriggers(string)IReadOnlyList<TriggerDefinition>Item-level trigger definitions
GetAvailableConnectionNames()IEnumerable<string>All available data connection name strings

IBeepFormsHost: LOV (List-of-Values) Proxies

MethodReturnDescription
HasLov(string block, string field)boolCheck if field has a LOV definition
GetLov(string block, string field)LOVDefinition?Get LOV configuration
LoadLovDataAsync(string block, string field, string? search)Task<LOVResult>Load LOV data (optional search filter)
ValidateLovValueAsync(string block, string field, object? val)Task<LOVValidationResult>Validate en entry against LOV rules
GetLovRelatedFieldValues(LOVDefinition, object?)Dictionary<string,object>?Get related field values for auto-fill
ShowLovAsync(string block, string field, string? search, CancellationToken)Task<LOVResult>Show LOV picker dialog and return selection

IBeepFormsHost: Validation & Mutation

MethodReturnDescription
ValidateBlockRecord(string, IDictionary, ValidationTiming)RecordValidationResult?Validate a record against block rules at a specific timing (BeforeSave, BeforeNavigation)
IsFieldQueryAllowed(string block, string field)boolCheck if field can be queried
SaveBlockAsync(string block)Task<bool>Save current block's UoW changes
RollbackBlockAsync(string block)Task<bool>Rollback block's UoW changes
InsertBlockRecordAsync(string block)Task<bool>Insert a new record into the block
DeleteBlockCurrentRecordAsync(string block)Task<bool>Delete current record from the block

IBeepFormsBootstrapper

public interface IBeepFormsBootstrapper
{
    Task<bool> BootstrapAsync(BeepForms forms,
        CancellationToken cancellationToken = default);
    // Populates BeepBlock instances with EntityStructure metadata
    // from a live datasource. Iterates all blocks in the
    // BeepFormsDefinition with valid ConnectionName + EntityName.
    //
    // Returns: true = all blocks populated,
    //          false = at least one block failed or was skipped.
    // Implementations must not throw; swallow failures.
}

Code Examples

// Block registration
var host = (IBeepFormsHost)myBeepForms;
host.RegisterBlock(myBlockView);
host.TrySetActiveBlock("CustomerBlock");

// Query current state
var uow = host.GetBlockUnitOfWork("CustomerBlock");
var currentItem = host.GetCurrentBlockItem("CustomerBlock");

// LOV interaction
if (host.HasLov("CustomerBlock", "Country"))
{
    var result = await host.ShowLovAsync(
        "CustomerBlock", "Country");
    if (result.Selected)
        Console.WriteLine($"Selected: {result.Value}");
}

// Save and validate
var validation = host.ValidateBlockRecord("CustomerBlock",
    myRecord, ValidationTiming.BeforeSave);
if (validation.IsValid)
    await host.SaveBlockAsync("CustomerBlock");

// Bootstrap
var bootstrapper = new MyBootstrapper();
await bootstrapper.BootstrapAsync(myBeepForms);