forked from BeyondDimension/SteamTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuthExtensions.cs
More file actions
39 lines (37 loc) · 1.07 KB
/
AuthExtensions.cs
File metadata and controls
39 lines (37 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using Android.App;
using System.Application.Services;
// ReSharper disable once CheckNamespace
namespace System
{
public static class AuthExtensions
{
/// <summary>
/// 当未登录账号时,将关闭当前活动,返回是否已登录
/// </summary>
/// <param name="activity"></param>
/// <returns></returns>
public static bool IsAuthenticated(this Activity activity)
{
var value = UserService.Current.IsAuthenticated;
if (!value)
{
activity.Finish();
}
return value;
}
/// <summary>
/// 当已登录账号时,将关闭当前活动,返回是否已登录
/// </summary>
/// <param name="activity"></param>
/// <returns></returns>
public static bool IsNotAuthenticated(this Activity activity)
{
var value = UserService.Current.IsAuthenticated;
if (value)
{
activity.Finish();
}
return value;
}
}
}