ps-projects - PS.Primitives 2.11.0

Common development primitives and useful tools

PM> Install-Package PS.Primitives -Version 2.11.0 -Source https://www.myget.org/F/ps-projects/api/v3/index.json

Copy to clipboard

> nuget.exe install PS.Primitives -Version 2.11.0 -Source https://www.myget.org/F/ps-projects/api/v3/index.json

Copy to clipboard

> dotnet add package PS.Primitives --version 2.11.0 --source https://www.myget.org/F/ps-projects/api/v3/index.json

Copy to clipboard
<PackageReference Include="PS.Primitives" Version="2.11.0" />
Copy to clipboard
source https://www.myget.org/F/ps-projects/api/v3/index.json

nuget PS.Primitives  ~> 2.11.0
Copy to clipboard

> choco install PS.Primitives --version 2.11.0 --source https://www.myget.org/F/ps-projects/api/v2

Copy to clipboard
Import-Module PowerShellGet
Register-PSRepository -Name "ps-projects" -SourceLocation "https://www.myget.org/F/ps-projects/api/v2"
Install-Module -Name "PS.Primitives" -RequiredVersion "2.11.0" -Repository "ps-projects" 
Copy to clipboard

Build

Branch Build status
Master Build Status
CI Build Status

Packages

Name Master CI
PS.Primitives NuGet version (PS.Primitives) MyGet version (PS.Primitives)
PS.WPF NuGet version (PS.WPF) MyGet version (PS.WPF)
PS.MVVM NuGet version (PS.MVVM) MyGet version (PS.MVVM)
PS.MVVM.WPF NuGet version (PS.MVVM.WPF) MyGet version (PS.MVVM.WPF)
PS.IoC NuGet version (PS.IoC) MyGet version (PS.IoC)
PS.IoC.Autofac NuGet version (PS.IoC.Autofac) MyGet version (PS.IoC.Autofac)
PS.IoC.Microsoft.DependencyInjection NuGet version (PS.IoC.Microsoft.DependencyInjection) MyGet version (PS.IoC.Microsoft.DependencyInjection)
PS.Windows.Interop NuGet version (PS.Windows.Interop) MyGet version (PS.Windows.Interop)

Description

Lightweight and fast MVVM framework. This framework is designed to be generic, allowing for flexibility and adaptability. However, all future implementations will be specifically tailored for WPF (Windows Presentation Foundation).

Tutorial

Quick tutorial documentation can be found here:

  1. Registration and Usage
  2. Template, Style, Container
  3. Model resolver
  4. IoC

How It Works

To ensure the correct resolution of any element, it's essential to register it. There are two primary items to be aware of when working with this system:

ViewModel Type Registration

The core key for registration is the ViewModel Type. This allows you to register payload items for the ViewModel type you're testing, whether it's of the same type or inherited from it.

Elements for View Rendering

There are three main kinds of elements that play a role in view rendering:

  1. DataTemplate for DataTemplateSelector:

    • DataTemplate: A DataTemplate is used in WPF to define the visual representation of data. It describes how data should be displayed, allowing developers to create a template that defines how data objects are rendered in UI elements like ListBox, ComboBox, and more.

      Usage Example:

      service.AssociateTemplate<ShellViewModel>(dataTemplateInstance);
      
    • DataTemplateSelector: This is a class in WPF that lets you choose a DataTemplate based on custom logic. It becomes particularly useful when you have multiple templates and you want to select one based on the properties of the data object.

  2. Style for StyleSelector:

    • Style: Styles in WPF empower developers and designers to establish a consistent appearance across their applications. By defining the look and feel of UI elements, styles help in creating visually compelling and uniform effects across the application.

      Usage Example:

      service.AssociateStyle<ShellViewModel>(XamlResources.ShellWindowStyle);
      
    • StyleSelector: This class in WPF is used to apply styles based on custom logic. It determines how a style is selected for a row or an item, contingent on specific conditions.

  3. ItemContainerTemplate for ItemContainerTemplateSelector:

    • ItemContainerTemplate: This template in WPF provides the blueprint for producing a container for an ItemsControl object. It essentially dictates how each item's container should be structured and styled within controls like ListBox or ComboBox.

      Usage Example:

      service.AssociateContainer<ShellViewModel>(itemContainerTemplateInstance);
      
    • ItemContainerTemplateSelector: This selector allows for the application of custom logic to pick an ItemContainerTemplate.

Generic Association

For a more streamlined approach, you can use a generic method to associate all the elements at once:

Usage Example:

service.Associate<ShellViewModel>(
    template: dataTemplateInstance,
    style: XamlResources.ShellWindowStyle,
    container: itemContainerTemplateInstance);

Core Features

  • Built-in Selectors: The framework provides native selectors for Data, Style, and Container. These selectors facilitate efficient data binding, style management, and container operations in WPF contexts.

  • DI Framework Integration: PS.Framework integrates seamlessly with established Dependency Injection (DI) frameworks, specifically Autofac and Microsoft dependency injection. This integration allows for dependency resolution and inversion of control, leading to modular and testable code structures.

  • Scalability: PS.Framework is scalable, catering to both small-scale utilities and large enterprise applications. It ensures consistent performance and responsiveness across varying project sizes.

  • Toolset: The framework includes a suite of tools and services that enhance WPF development, reducing boilerplate and improving efficiency.

MVVM Services

In essence, the PS.MVVM project provides tools and services to facilitate the implementation of the MVVM pattern, making it easier for developers to separate their application's logic from its presentation.

BroadcastService

This service provides functionality to broadcast events to subscribers. It maintains a list of subscriptions and allows for broadcasting events to these subscribers. The service provides methods to subscribe and unsubscribe from events. It uses a synchronization context to ensure thread safety.

CommandService

This service deals with commands in the MVVM pattern. It maintains a registry of commands and provides methods to add commands, create views of commands, and find commands. The service can handle activation of commands and provides event handling capabilities.

ModelResolverService

This service provides functionality to resolve models. It maintains storage for observable model collections and observable model objects. The service provides methods to retrieve these observable collections and objects.

ViewResolverService

This service is responsible for resolving views. It maintains associations between consumer service types, view models, and regions. The service provides methods to associate views and find associated views.

MVVM WPF Adaptation

The PS.MVVM.WPF project within the PS.Framework repository provides a set of components, services, and view models tailored for WPF applications, particularly for implementing the MVVM (Model-View-ViewModel) pattern. Here's a brief overview of the components:

Resolvers

In the MVVM architecture within WPF applications, resolvers play a pivotal role in dynamic UI determination. They ensure the appropriate visual elements are chosen based on the underlying data contexts.

  1. BaseResolver:

    • An abstract generic base class tailored for service interactions within XAML. It provides foundational mechanisms for consistent service retrieval across derived resolvers.
  2. BaseViewResolver:

    • A specialized XAML resolver for operations with the IViewResolverService. The service interacts with three distinct selectors:
      • StyleResolver: Works with WPF's StyleSelector, determining the right style for views.
      • ContainerResolver: Engages with ItemContainerTemplateSelector, ensuring the correct container for items in collection controls.
      • TemplateResolver: Operates with DataTemplateSelector, selecting the appropriate data template based on the data context.

WindowService:

Service offers methods to display windows, either in a standard or modal fashion, based on the associated view model. This ensures a clear separation of concerns between the view and its underlying logic, adhering to the principles of the MVVM pattern.

  • .NETFramework 4.6.1
    • System.ComponentModel.Annotations (>= 5.0.0)
  • .NETFramework 6.0
    • System.ComponentModel.Annotations (>= 5.0.0)
  • .NETStandard 2.0
    • System.ComponentModel.Annotations (>= 5.0.0)
  • .NETFramework 4.6.1: 4.6.1.0
  • .NETFramework 6.0: 6.0.0.0
  • .NETStandard 2.0: 2.0.0.0

Owners

BlackGad

Authors

Volodymyr Shkolka

Project URL

https://github.com/BlackGad/PS.Framework

License

Unknown

Tags

Framework MVVM IoC Primitives Standard WPF

Info

131 total downloads
3 downloads for version 2.11.0
Download (173.36 KB)
Found on the current feed only

Package history

Version Size Last updated Downloads Mirrored?
2.16.0 233.88 KB Sat, 11 May 2024 07:13:40 GMT 2
2.15.0 176.44 KB Sun, 08 Oct 2023 16:06:40 GMT 3
2.14.4 176.34 KB Sun, 08 Oct 2023 16:02:40 GMT 3
2.13.3 173.38 KB Wed, 12 Apr 2023 15:31:07 GMT 3
2.13.2 173.4 KB Tue, 11 Apr 2023 12:38:12 GMT 3
2.13.1 173.39 KB Sun, 09 Apr 2023 21:20:16 GMT 3
2.13.0 173.38 KB Sat, 08 Apr 2023 12:47:47 GMT 3
2.11.0 173.36 KB Thu, 15 Sep 2022 13:29:17 GMT 3
2.10.0 173.35 KB Thu, 15 Sep 2022 13:20:07 GMT 3
2.9.14 173.38 KB Thu, 15 Sep 2022 13:02:32 GMT 3
2.9.12 173.37 KB Thu, 15 Sep 2022 12:42:03 GMT 3
2.9.11 171.54 KB Mon, 12 Sep 2022 12:46:04 GMT 3
2.9.10 171.53 KB Wed, 07 Sep 2022 10:36:44 GMT 3
2.9.9 171.5 KB Wed, 07 Sep 2022 09:17:17 GMT 3
2.9.8 171.52 KB Mon, 05 Sep 2022 12:09:30 GMT 3
2.9.6 171.51 KB Mon, 05 Sep 2022 11:52:20 GMT 3
2.9.5 171.52 KB Tue, 23 Aug 2022 13:06:16 GMT 3
2.9.4 169.67 KB Fri, 19 Aug 2022 07:45:33 GMT 2
2.9.1 158.85 KB Mon, 23 May 2022 13:33:44 GMT 3
2.7.1 155.67 KB Sat, 14 May 2022 18:13:21 GMT 3
2.2.18 153.45 KB Mon, 25 Oct 2021 15:45:23 GMT 3
2.2.17 153.45 KB Mon, 25 Oct 2021 15:04:31 GMT 3
2.2.16 153.46 KB Sat, 23 Oct 2021 14:47:38 GMT 3
2.2.15 153.45 KB Fri, 22 Oct 2021 21:52:03 GMT 3
2.2.13 153.21 KB Fri, 22 Oct 2021 17:57:07 GMT 3
2.2.12 153.21 KB Sun, 17 Oct 2021 21:14:22 GMT 3
2.2.11 153.22 KB Thu, 14 Oct 2021 12:50:58 GMT 3
2.2.9 153.21 KB Wed, 13 Oct 2021 22:49:10 GMT 3
2.2.8 153.2 KB Sat, 09 Oct 2021 23:02:10 GMT 2
2.2.5 151.62 KB Sat, 02 Oct 2021 22:08:31 GMT 3
2.2.4 102.26 KB Sat, 02 Oct 2021 21:19:45 GMT 3
2.2.3 102.27 KB Wed, 29 Sep 2021 15:24:46 GMT 3
2.2.1 101.82 KB Wed, 29 Sep 2021 14:07:00 GMT 3
2.0.4 100.77 KB Sun, 21 Mar 2021 21:52:34 GMT 3
2.0.0 45.73 KB Sun, 29 Mar 2020 19:06:30 GMT 3
1.11.2 87.83 KB Sat, 23 Nov 2019 15:59:07 GMT 3
1.11.1 87.81 KB Tue, 30 Jul 2019 20:39:36 GMT 3
1.11.0 69.28 KB Sat, 27 Jul 2019 19:43:18 GMT 3
1.10.6 69.29 KB Fri, 12 Jul 2019 14:30:53 GMT 2
1.10.5 69.29 KB Thu, 11 Jul 2019 22:31:22 GMT 3
1.10.4 69.29 KB Thu, 11 Jul 2019 21:53:12 GMT 3
1.10.3 69.29 KB Thu, 11 Jul 2019 21:41:26 GMT 3
1.10.2 65.7 KB Thu, 11 Jul 2019 20:51:25 GMT 3
1.10.1 65.7 KB Thu, 11 Jul 2019 20:04:32 GMT 3
1.0.4 65.68 KB Thu, 11 Jul 2019 13:10:32 GMT 3