Skip to content

Latest commit

 

History

History
164 lines (133 loc) · 2.82 KB

Features.md

File metadata and controls

164 lines (133 loc) · 2.82 KB

Intro

This work is heavily inspired by the Caliburn.Micro framework. Which is one of the nicest frameworks, I had ever the pleasure to use. It is also named the after the character Caliban in Shakespeare's play The Tempest (hence the projects symbol). As the writer Russell Hoban put it:

Caliban is one of the hungry ideas, he's always looking for someone to word him into being ... Caliban is a necessary idea.

Which seems very fitting.

Features

Dependency Injection

Compose your app with loosely coupled objects that will inject by creation.

new Bootstrap().Register<IBattery, Battery>();

Properties

public IBattery? Battery { get; init; }

Constructors

public class Remote
{
    public Remote(IBattery battery)
    {
        ...
    }
}

Event Aggregating

Communicate between view models with event aggregating.

Publisher

public class Remote
{
    public Remote(IEventAggregator events)
    {
        events.Publish(new BatteryLowEvent());
    }
}

Subscriber

public class Television : IHandle<BatteryLowEvent>
{
    public Television(IEventAggregator events)
    {
        events.Subscribe<BatteryLowEvent>(this);
    }

    public void Handle(BatteryLowEvent event)
    {
        ...
    }
}

Automatic Binding

Apply methods and properties between your view and view model automatically and guard them.

Methods

<Button x:Name="DoSomething"/>
public bool CanDoSomething => true;

public void DoSomething()
{
    ...
}

Properties

<TextBox x:Name="SomeInput"/>
private string _someInput = "";

public string SomeInput
{
    get => _someInput;
    set => SetProperty(ref _someInput, value);
}

Conductor Composition

Decouple view models with the built in composition pattern.

<ContentControl x:Name="ActiveItem"/>
public class EditorViewModel : ViewModel.Single
{
    public async Task NewTabAsync()
    {
        await ActivateItem(new TabViewModel());
    }
}

View, ViewModel and Model Matching

Match your views, view models and models automatically by consistent naming alone.

public class MainView
{
    ...
}
public class MainViewModel
{
    ...
}
public class MainModel
{
    ...
}

Implicit Model Members

Write concise code by using implicit model members.

public class SheepModel : Model
{
    public int Count
    {
        get => Get<int>();
        set => Set<int>(value);
    }
}

Service Locator

Use registered services with the supplied service locator.

Register Service

new Bootstrap().Register<ILogger>(new Logger());

Locate Service

var logger = IoC.Get<ILogger>();

Documentation

There is also the full API Documentation available (generated by DefaultDocumentation).