Table of Contents

Class ViewModelRegistration

Namespace
Dmnk.Blazor.Mvvm
Assembly
Dmnk.Blazor.Mvvm.dll

Represents a mapping of a ViewModel type to a View type. Used by ViewModelRegistry to store the associations between ViewModels and Views.

You probably want to inject a number of these into DI, such that a ViewModelRegistry that is also in DI can consume them to build its mapping.

public record ViewModelRegistration : IEquatable<ViewModelRegistration>
Inheritance
ViewModelRegistration
Implements
Inherited Members

Constructors

ViewModelRegistration(ViewModelRegistration)

protected ViewModelRegistration(ViewModelRegistration original)

Parameters

original ViewModelRegistration

Properties

EqualityContract

protected virtual Type EqualityContract { get; }

Property Value

Type

ViewModelType

The type of the ViewModel. Must implement INotifyPropertyChanged.

public Type ViewModelType { get; }

Property Value

Type

ViewType

The type of the View. Must inherit from MvvmComponentBase<T> where T is the ViewModelType.

public Type ViewType { get; }

Property Value

Type

Methods

CreateOpenGeneric(Type, Type)

Creates a new instance for open generic type pairs (e.g. typeof(MyViewModel<>) and typeof(MyView<>)). No compile-time type checks are performed; invalid types will fail at runtime in ViewModelRegistry.

public static ViewModelRegistration CreateOpenGeneric(Type viewModelType, Type viewType)

Parameters

viewModelType Type
viewType Type

Returns

ViewModelRegistration

Create<TViewModel, TView>()

Creates a new instance of ViewModelRegistration.

public static ViewModelRegistration Create<TViewModel, TView>() where TViewModel : INotifyPropertyChanged where TView : MvvmComponentBase<TViewModel>

Returns

ViewModelRegistration

Type Parameters

TViewModel
TView

Equals(ViewModelRegistration?)

public virtual bool Equals(ViewModelRegistration? other)

Parameters

other ViewModelRegistration

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

PrintMembers(StringBuilder)

protected virtual bool PrintMembers(StringBuilder builder)

Parameters

builder StringBuilder

Returns

bool

ToString()

public override string ToString()

Returns

string

Operators

operator ==(ViewModelRegistration?, ViewModelRegistration?)

public static bool operator ==(ViewModelRegistration? left, ViewModelRegistration? right)

Parameters

left ViewModelRegistration
right ViewModelRegistration

Returns

bool

operator !=(ViewModelRegistration?, ViewModelRegistration?)

public static bool operator !=(ViewModelRegistration? left, ViewModelRegistration? right)

Parameters

left ViewModelRegistration
right ViewModelRegistration

Returns

bool