Developer Setup Guide

Welcome to the Beep Framework setup guide. This document will guide you through the steps necessary to integrate and utilize the Beep Framework in your development projects.

System Requirements

Before you begin, ensure your system meets the following requirements:

  • .NET Framework: Net4.8,Net 6,Net7,Net8.
  • Supported Operating Systems: Windows 7,10,11
  • IDE: Visual Studio 2019 or any compatible .NET IDE
  • Database: SQL Server, MySQL, Oracle, or other supported databases
  • Internet Connection: Required for initial setup and updates

Installation

  1. Download the Beep Framework:
  2. Recommended NuGet Components:

Sample Code

Windows Form Main Class

internal static class Program
{
    /// <summary>
    ///  The main entry point for the application.
    ///  Configures and initializes services before launching the main form.
    /// </summary>
    [STAThread]
    static void Main()
    {
        // Initializes application configurations such as high DPI settings or default font.
        ApplicationConfiguration.Initialize();

        // Creating a HostApplicationBuilder instance for configuring services.
        HostApplicationBuilder builder = Host.CreateApplicationBuilder();

        // Registering BeepService and VisManager services with the service collection.
        builder.Services.RegisterBeep(AppContext.BaseDirectory, null, TheTechIdea.Util.BeepConfigType.Application);
        builder.Services.RegisterVisManager();

        // Building the host with the configured services.
        using IHost host = builder.Build();

        // Initializing services for later use in the application.
        ServiceHelper.Initialize(host.Services);
        IBeepService beepService = host.Services.GetService<IBeepService>()!;
        IVisManager visManager = host.Services.GetService<IVisManager>()!;

        // Configuring datasource mappings, connection configurations, and query configurations.
        beepService.AddAllDataSourceMappings();
        beepService.AddAllConnectionConfigurations();
        beepService.AddAllDataSourceQueryConfigurations();

        // Preparing for asynchronous progress reporting from the assembly loader.
        var progress = new Progress<PassedArgs>(percent =>
        {
            visManager.PasstoWaitForm(percent);
        });

        // Displaying a wait form while loading assemblies from folders.
        visManager.ShowWaitForm(new PassedArgs { Messege = "Loading DLL's" });
        visManager.LoadAssemblies(beepService, progress);

        // Finalizing the initialization of services and database connections.
        visManager.CloseWaitForm();

        // Setting and displaying the main application form.
        visManager.SetMainDisplay("Frm_Main", "My ApplicationTitle", "Appicon.ico");
        visManager.ShowMainPage();

        // Disposing of services and objects on application closure.
        beepService.vis.Dispose();
        beepService.DMEEditor.Dispose();
        beepService = null;
    }
}

WPF Sample Main Class


<!-- App.xaml -->
<Application x:Class="YourNamespace.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             Startup="OnStartup">
    <!-- Application resources can be defined here -->
</Application>
// App.xaml.cs
using System;
using System.Windows;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;

namespace YourNamespace
{
    public partial class App : Application
    {
        private IHost _host;

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            _host = Host.CreateDefaultBuilder(e.Args)
                        .ConfigureServices((context, services) =>
                        {
                            // Register services here
                            services.RegisterBeep(AppContext.BaseDirectory, null, TheTechIdea.Util.BeepConfigType.Application);
                            services.RegisterVisManager();

                            // Other service registrations...
                        })
                        .Build();

            ServiceHelper.Initialize(_host.Services);
            IBeepService beepService = _host.Services.GetService<IBeepService>()!;
            IVisManager visManager = _host.Services.GetService<IVisManager>()!;

            // Additional configuration...
            beepService.AddAllDataSourceMappings();
            beepService.AddAllConnectionConfigurations();
            beepService.AddAllDataSourceQueryConfigurations();

            // Your WPF main window initialization and display logic goes here
            var mainWindow = new MainWindow(); // Replace 'MainWindow' with your main window class
            mainWindow.Show();
        }

        protected override void OnExit(ExitEventArgs e)
        {
            using (_host)
            {
                base.OnExit(e);
            }
        }
    }
}

Blazer Server

public class Program
{
    public static async Task Main(string[] args)
    {
        var builder = WebApplication.CreateBuilder(args);

        // Add services to the container.
        builder.Services.AddRazorPages();
        builder.Services.AddServerSideBlazor();

        // Register your services here
        builder.Services.RegisterBeep(builder.Configuration["AppBaseDirectory"], null, BeepConfigType.Application);
        builder.Services.RegisterVisManager();
        
        var app = builder.Build();

        // Configure the HTTP request pipeline.
        if (!app.Environment.IsDevelopment())
        {
            app.UseExceptionHandler("/Error");
            // The default HSTS value is 30 days. You may want to change this for production scenarios.
            app.UseHsts();
        }

        app.UseHttpsRedirection();
        app.UseStaticFiles();
        app.UseRouting();

        app.MapBlazorHub();
        app.MapFallbackToPage("/_Host");

        await app.RunAsync();
    }
}

BlazerWebAssembly

public class Program
{
    public static async Task Main(string[] args)
    {
        var builder = WebAssemblyHostBuilder.CreateDefault(args);

        // Add services to the container.
        builder.RootComponents.Add<App>("#app");

        // Register your services here
        builder.Services.RegisterBeep(builder.Configuration["AppBaseDirectory"], null, BeepConfigType.Application);
        builder.Services.RegisterVisManager();

        // Build and run the application
        await builder.Build().RunAsync();
    }
}

Create a Razor Component

Create a new Razor component (.razor file) where you want to use the IBeepService. Here, we’ll create a component that uses IBeepService to perform an action:

@page "/beep-example"
@inject IBeepService BeepService
<h3>Beep Example</h3>
<button class="btn btn-primary" @onclick="DoBeepAction">Perform Beep Action</button>
@if (message != null)
{
    <p>@message</p>
}
@code {
    private string message;
    private void DoBeepAction()
    {
        // Call a method from the BeepService
        var result = BeepService.PerformAction(); // Assuming this method exists
        message = result ? "Action performed successfully!" : "Failed to perform action.";
    }
}