-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathInternalHooks.cs
More file actions
47 lines (36 loc) · 1.39 KB
/
InternalHooks.cs
File metadata and controls
47 lines (36 loc) · 1.39 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
40
41
42
43
44
45
46
47
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System.Reflection;
namespace Microsoft.PowerShell.PSResourceGet.UtilClasses
{
public class InternalHooks
{
internal static bool InvokedFromCompat;
internal static bool EnableGPRegistryHook;
internal static bool GPEnabledStatus;
internal static string AllowedUri;
internal static string MARPrefix;
// PSContentPath testing hooks
internal static string LastUserContentPathSource;
internal static string LastUserContentPath;
public static void SetTestHook(string property, object value)
{
var fieldInfo = typeof(InternalHooks).GetField(property, BindingFlags.Static | BindingFlags.NonPublic);
fieldInfo?.SetValue(null, value);
}
public static object GetTestHook(string property)
{
var fieldInfo = typeof(InternalHooks).GetField(property, BindingFlags.Static | BindingFlags.NonPublic);
return fieldInfo?.GetValue(null);
}
public static void ClearPSContentPathHooks()
{
LastUserContentPathSource = null;
LastUserContentPath = null;
}
public static string GetUserString()
{
return Microsoft.PowerShell.PSResourceGet.Cmdlets.UserAgentInfo.UserAgentString();
}
}
}