PardusLabs.NuFlexiArch
1.0.9.2
Scope has been reduced
dotnet add package PardusLabs.NuFlexiArch --version 1.0.9.2
NuGet\Install-Package PardusLabs.NuFlexiArch -Version 1.0.9.2
<PackageReference Include="PardusLabs.NuFlexiArch" Version="1.0.9.2" />
<PackageVersion Include="PardusLabs.NuFlexiArch" Version="1.0.9.2" />
<PackageReference Include="PardusLabs.NuFlexiArch" />
paket add PardusLabs.NuFlexiArch --version 1.0.9.2
#r "nuget: PardusLabs.NuFlexiArch, 1.0.9.2"
#addin nuget:?package=PardusLabs.NuFlexiArch&version=1.0.9.2
#tool nuget:?package=PardusLabs.NuFlexiArch&version=1.0.9.2
NuFlexiArch / JSVNuFlexiArch Framework
Overview
The NuFlexiArch/JSVNuFlexiArch framework is a modular, extensible architecture designed for managing component state, data transformation, and rendering across various platforms. While many of the provided implementations are browser-based, the core design is platform-agnostic and can be adapted to desktop, command-line, or server-side environments.
Architecture and Design
Core Abstractions
Component Base Classes and Interfaces:
AComponent
&ATextInput
:
Provide a common foundation for UI components, handling metadata (viaComponentMetadata
) and state management using Data Transfer Objects (DTOs) likeTextInputStateDto
.- State Management:
Each component can serialize and deserialize its state to/from JSON. This allows for easy persistence and restoration of component state.
Transformers and Registries:
ITransformer
&JSVTransformer
:
Define methods for converting between JSON, DTOs, and view representations.ITransformerRegistry
&TransformerRegistry
:
Manage multiple transformer implementations. This allows dynamic lookup and invocation of transformation logic based on a unique registry key.
Rendering Components:
IComponent
&IComponentRenderer
:
Define contracts for rendering components asynchronously.JSVComponentRenderer
:
Implements rendering logic that integrates with ASP.NET Core’s HTML helpers, wrapping rendered content in HTML structures.- Default Renderer (e.g.,
BlackHole
):
Provides a fallback or no-operation renderer when no specific rendering logic is required.
Extensibility and Modularity
- Pluggable Architecture:
The framework is built so that new component types, transformers, and renderers can be easily added or swapped. This is achieved by:- Using abstract classes and interfaces to decouple the core logic.
- Allowing different implementations for state handling, transformation, and rendering.
- Platform Agnosticism:
Although many implementations (like DOM manipulation and ASP.NET Core integration) target browsers, the abstraction layers ensure that the same principles can be applied to other platforms (e.g., desktop applications or CLI tools).
Modules and Code Organization
NuFlexiArch:
Contains the core abstractions such asAComponent
,TransformerDto
, and related interfaces (ITransformer
,ITransformerRegistry
).MyViewLib:
Implements concrete UI components likeJSVTextInput
andTextInputRenderer
, along with state management classes likeTextInputStateDto
and its serializer context.JSVNuFlexiArch:
Provides browser-specific implementations:- Transformers: Implemented by extending
JSVTransformer
. - Component Rendering: Implemented in
JSVComponentRenderer
and helper classes such asJSVComponentHelpers
. - Component Initialization: Includes static methods (e.g.,
IJSVComponent.InitializeFromJson
) to create and initialize components from JSON data.
- Transformers: Implemented by extending
Usage
Initializing Components
Components can be instantiated and initialized from JSON data using the static method in the IJSVComponent
interface. This method:
- Deserializes metadata and state JSON strings.
- Uses reflection to instantiate the appropriate component.
- Sets the component’s state based on the deserialized DTO.
Rendering Components
- Rendering Flow:
Each component implementsGetRenderer()
, returning anIComponentRenderer
instance that handles its rendering. The renderer builds the HTML (or other presentation formats) by wrapping the component content with predefined HTML structures (e.g.,<div>
elements with unique IDs). - Asynchronous Rendering:
Rendering is performed asynchronously, which is particularly beneficial for web applications that need to interact with dynamic data sources or perform client-side updates.
State Management and Transformation
- State Serialization/Deserialization:
Components maintain their state in DTOs (such asTextInputStateDto
). These can be easily serialized to JSON for persistence or transmission, and deserialized back to restore state. - Data Transformation:
The transformer mechanism allows converting data between different formats (e.g., JSON to DTO, DTO to view-friendly formats) using custom transformer implementations and a registry for dynamic lookup.
Extending the Framework
- Adding New Components:
ExtendAComponent
(or specialized classes likeATextInput
) to create new components with custom state and rendering logic. - Implementing Custom Transformers:
Create new transformer classes by extendingJSVTransformer
or implementingITransformer
to handle unique data transformation needs. - Custom Rendering:
Develop custom renderers by implementingIComponentRenderer
or extendingJSVComponentRenderer
for different platforms or presentation requirements.
Platform Considerations
While the provided implementations are focused on browser-based applications (utilizing ASP.NET Core and browser-specific APIs), the framework's design is intentionally abstract. This allows:
- Desktop or CLI Applications:
Replacing browser-specific logic with desktop UI frameworks (e.g., WPF, WinForms) or text-based rendering. - Server-Side Processing:
Utilizing the state and transformation logic for API responses or backend data processing without any UI.
Conclusion
The NuFlexiArch/JSVNuFlexiArch framework offers a robust solution for building dynamic, stateful, and modular UI components. With its clear separation of concerns, pluggable architecture, and support for multiple platforms, the framework is well-suited for applications ranging from modern web interfaces to desktop and command-line tools.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|