CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
Csla.Xaml.Shared/ConfigurationExtensions.cs
Go to the documentation of this file.
1#if !XAMARIN && !NETFX_CORE
2//-----------------------------------------------------------------------
3// <copyright file="XamlConfigurationExtensions.cs" company="Marimer LLC">
4// Copyright (c) Marimer LLC. All rights reserved.
5// Website: https://cslanet.com
6// </copyright>
7// <summary>Implement extension methods for .NET Core configuration</summary>
8//-----------------------------------------------------------------------
9using System;
11using Csla.Xaml;
12using Microsoft.Extensions.Hosting;
13
14namespace Csla.Configuration
15{
19 public static class XamlConfigurationExtensions
20 {
27 public static CslaOptions AddXaml(this CslaOptions config)
28 {
29 return AddXaml(config, null);
30 }
31
39 public static CslaOptions AddXaml(this CslaOptions config, Action<XamlOptions> options)
40 {
41 var xamlOptions = new XamlOptions();
42 options?.Invoke(xamlOptions);
43
44 // use correct mode for raising PropertyChanged events
45 ApplicationContext.PropertyChangedMode = ApplicationContext.PropertyChangedModes.Xaml;
46
47 config.Services.TryAddTransient(typeof(ViewModel<>), typeof(ViewModel<>));
48 return config;
49 }
50
56 public static IHost UseCsla(this IHost host)
57 {
58 // create instance of ApplicationContext so the
59 // Csla.Xaml.ApplicationContextManager gets a static
60 // reference for use by UI helpers.
61#pragma warning disable IDE0059 // Unnecessary assignment of a value
62 var context = host.Services.GetService(typeof(ApplicationContext));
63#pragma warning restore IDE0059 // Unnecessary assignment of a value
64 return host;
65 }
66 }
67
71 public class XamlOptions
72 {
73
74 }
75}
76#endif
Configuration options for AddXaml method
Base class used to create ViewModel objects, with pre-existing verbs for use by InvokeMethod or Invok...