Using F # and Caliburn.Micro Together

As I understand it, Caliburn.Micro does a significant amount of automatic wiring and plumbing for the WPF convention-based project; using MVVM.

Question: Are there any C # components in Caliburn.Micro; who used some C # features? What parts of Caliburn.Micro cannot be used with F # code? What am I losing using F #?

+4
source share
2 answers

Unfortunately, Caliburn.Micro and F # do not work so well.

, Caliburn.Micro ( ), # - .

F # , - XAML. , Caliburn.Micro. , IoC , - , Application.LoadComponent ..

boostrapper , App.xaml, - . Bootstrapper<T> bool useApplication = true BootstrapperBase - F # , , , , . , F # , Caliburn.Micro - . ...

, , , IoC, , . -, .

# Caliburn.Micro " " F #. , , , F # , #, , . , .

+4

. , , . Caliburn , .

, , -, , , :

Lambda NotifyOfPropertyChange

PropertyChanged . , , - -. / . , #, :

public string SomeProp
{
    get { return someField; }
    set
    {
        someField = value;
        NotifyOfPropertyChange(() => SomeProp);
    }
}

F #. - , . - :

let notify<'a> (notifier: PropertyChangedBase) (expr: Expr<'a>) =
    let name =
        match expr with
        | PropertyGet (_, pi, _) -> pi.Name
        | _ -> failwith "Can't get property name to notify"
    notifier.NotifyOfPropertyChange(name)

:

member this.SomeProp 
    with get () = 
        someField
    and set(value) = 
        someField <- value
        notify this <@ this.SomeProp @>

, PropertyChanged, PropertyChangedBase.

+2

Source: https://habr.com/ru/post/1540135/


All Articles