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/ApplicationContextManager.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="ApplicationContextManager.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Provides consistent context information between the client</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Security.Principal;
10using System.Threading;
12
13namespace Csla.Xaml
14{
19 {
20 private static IPrincipal _principal = null;
21 private static ApplicationContext applicationContext;
22
27 protected override void OnApplicationContextSet() => applicationContext = base.ApplicationContext;
28
33 {
34 if (applicationContext == null)
35 throw new InvalidOperationException($"{nameof(applicationContext)} == null");
36 return applicationContext;
37 }
38
43 public override IPrincipal GetUser()
44 {
45 if (_principal == null)
46 {
48#pragma warning disable CA1416 // Validate platform compatibility
49 SetUser(new WindowsPrincipal(WindowsIdentity.GetCurrent()));
50#pragma warning restore CA1416 // Validate platform compatibility
51 else
52 SetUser(new System.Security.Claims.ClaimsPrincipal());
53 }
54 return _principal;
55 }
56
61 public override void SetUser(IPrincipal principal)
62 {
63 _principal = principal;
64 Thread.CurrentPrincipal = principal;
65 }
66 }
67}
Provides consistent context information between the client and server DataPortal objects.
ApplicationContext(ApplicationContextAccessor applicationContextAccessor)
Creates a new instance of the type
static string AuthenticationType
Gets the authentication type being used by the CSLA .NET framework.
ApplicationContextManager for WPF applications
override void OnApplicationContextSet()
Method called when the ApplicationContext property has been set to a new value.
override void SetUser(IPrincipal principal)
Sets the current principal.
static ApplicationContext GetApplicationContext()
Gets the current ApplicationContext.
override IPrincipal GetUser()
Gets the current principal.