CSLA.NET 5.4.2
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
Csla/Configuration/ConfigurationExtensions.cs
Go to the documentation of this file.
1#if NETSTANDARD2_0 || NET5_0
2//-----------------------------------------------------------------------
3// <copyright file="ConfigurationExtensions.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;
10using Microsoft.Extensions.Configuration;
11using Microsoft.Extensions.DependencyInjection;
12using Microsoft.Extensions.DependencyInjection.Extensions;
13
14namespace Csla.Configuration
15{
19 public static class ConfigurationExtensions
20 {
25 public static ICslaBuilder AddCsla(this IServiceCollection services)
26 {
27 return AddCsla(services, null);
28 }
29
35 public static ICslaBuilder AddCsla(this IServiceCollection services, Action<CslaConfiguration> config)
36 {
37 ApplicationContext.SetServiceCollection(services);
38 services.TryAddTransient(typeof(IDataPortal<>), typeof(DataPortal<>));
39 config?.Invoke(CslaConfiguration.Configure());
40 return new CslaBuilder(services);
41 }
42
48 public static IConfiguration ConfigureCsla(this IConfiguration config)
49 {
50 config.Bind("csla", new CslaConfigurationOptions());
51 return config;
52 }
53 }
54}
55#endif