Integrating DI Containers
public interface ICalcService
{
double Add(double x, double y);
}
public class CalcService : ICalcService
{
public double Add(double x, double y) => x + y;
}public class MainPageState : IState
{
public double X { get; set; }
public double Y { get; set; }
public double Result { get; set; }
}
public class MainPage : RxComponent<MainPageState>
{
public override VisualNode Render()
{
return new RxNavigationPage()
{
new RxContentPage()
{
new RxStackLayout()
{
NumericEntry(State.X, v => SetState(s => s.X = v)),
new RxLabel(" + ")
.FontSize(NamedSize.Large)
.VCenter(),
NumericEntry(State.Y, v => SetState(s => s.Y = v)),
new RxButton(" + ")
.OnClick(OnAdd),
new RxLabel(State.Result.ToString())
.FontSize(NamedSize.Large)
.VCenter()
}
.Spacing(10)
.VCenter()
.HCenter()
.WithHorizontalOrientation()
}
.Title("DI Container Sample")
};
}
private void OnAdd()
{
}
private RxEntry NumericEntry(double value, Action<double> onSet)
=> new RxEntry(value.ToString())
.OnAfterTextChanged(s => onSet(double.Parse(s)))
.Keyboard(Keyboard.Numeric)
.VCenter();
}


Last updated