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.
DashboardFactory.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="DashboardFactory.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Creates a dashboard instance based on configuration</summary>
7//-----------------------------------------------------------------------
8using System;
10
12{
16 public static class DashboardFactory
17 {
18 private static IDashboard _dashboard;
19
24 public static IDashboard GetDashboard()
25 {
26 IDashboard result = null;
27 if (_dashboard == null)
28 {
29 var typeName = ConfigurationManager.AppSettings["CslaDashboardType"];
30 if (!string.IsNullOrWhiteSpace(typeName))
31 {
32 if (typeName == "Dashboard")
33 result = new Dashboard();
34 else if (typeName == "NullDashboard")
35 result = new NullDashboard();
36 else
37 result = (IDashboard)Reflection.MethodCaller.CreateInstance(Type.GetType(typeName));
38 }
39 else
40 {
41 result = new NullDashboard();
42 }
43 _dashboard = result;
44 }
45 else
46 {
47 result = _dashboard;
48 }
49 return result;
50 }
51
55 [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
56 public static void Reset()
57 {
58 _dashboard?.Dispose();
59 _dashboard = null;
60 DataPortal.Dashboard = GetDashboard();
61 }
62 }
63}