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.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.Security.Principal;
9using System.Threading;
10
11namespace Csla.Xaml
12{
17 {
18 private static IPrincipal _principal = null;
19
24 public override IPrincipal GetUser()
25 {
26 if (_principal == null)
27 {
28 if (ApplicationContext.AuthenticationType == "Windows")
29#pragma warning disable CA1416 // Validate platform compatibility
30 SetUser(new WindowsPrincipal(WindowsIdentity.GetCurrent()));
31#pragma warning restore CA1416 // Validate platform compatibility
32 else
33 SetUser(new System.Security.Claims.ClaimsPrincipal());
34 }
35 return _principal;
36 }
37
42 public override void SetUser(IPrincipal principal)
43 {
44 _principal = principal;
45 Thread.CurrentPrincipal = principal;
46 }
47 }
48}
ApplicationContextManager for WPF applications
override void SetUser(IPrincipal principal)
Sets the current principal.
override IPrincipal GetUser()
Gets the current principal.