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.Windows.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;
11using Csla.Core;
12
13namespace Csla.Windows
14{
19 {
20 private static IPrincipal _principal;
21
26 public override IPrincipal GetUser()
27 {
28 if (_principal == null)
29 {
30 if (ApplicationContext.AuthenticationType != "Windows")
31 SetUser(new System.Security.Claims.ClaimsPrincipal());
32 else
33#pragma warning disable CA1416 // Validate platform compatibility
34 SetUser(new WindowsPrincipal(WindowsIdentity.GetCurrent()));
35#pragma warning restore CA1416 // Validate platform compatibility
36 }
37 return _principal;
38 }
39
44 public override void SetUser(IPrincipal principal)
45 {
46 _principal = principal;
47 Thread.CurrentPrincipal = principal;
48 }
49 }
50}
ApplicationContextManager for Windows Forms applications
override IPrincipal GetUser()
Gets the current principal.
override void SetUser(IPrincipal principal)
Sets the current principal.