This repository has been archived by the owner on May 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
ApplicationIdentity.cs
62 lines (56 loc) · 2.82 KB
/
ApplicationIdentity.cs
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
namespace System
{
/// <summary>
/// Provides the ability to uniquely identify a manifest-activated application. This class cannot be inherited.
/// </summary>
/// <remarks>
/// The ApplicationIdentity class is used in the activation of manifest-based applications.
/// </remarks>
/// <threadsafety static="true" instance="false"/>
public sealed class ApplicationIdentity
{
internal static readonly Type RealType = typeof(ApplicationIdentity).RealType();
private static readonly Func<string, object> externalConstructor = RealType.CreateConstructor<string>();
private static readonly Func<object, string> getCodeBase = RealType.GetInstancePropertyFunction<string>(nameof(CodeBase));
private static readonly Func<object, string> getFullName = RealType.GetInstancePropertyFunction<string>(nameof(FullName));
private static readonly Func<object, string> toString = RealType.GetInstanceFunctionFunction<string>(nameof(ToString));
private readonly object applicationIdentity;
/// <summary>
/// Initializes a new instance of the <see cref="ApplicationIdentity"/> class.
/// </summary>
/// <param name="applicationIdentityFullName">The full name of the application.</param>
/// <exception cref="ArgumentNullException"><paramref name="applicationIdentityFullName"/> is <see langword="null"/>.</exception>
public ApplicationIdentity(string applicationIdentityFullName)
{
applicationIdentityFullName.NotNull(nameof(applicationIdentityFullName));
applicationIdentity = externalConstructor(applicationIdentityFullName);
}
internal ApplicationIdentity(object applicationIdentity)
{
applicationIdentity.NotNull(nameof(applicationIdentity));
applicationIdentity.InstanceOf(nameof(applicationIdentity), RealType);
this.applicationIdentity = applicationIdentity;
}
/// <summary>
/// Gets the location of the deployment manifest as a URL.
/// </summary>
/// <value>
/// The URL of the deployment manifest.
/// </value>
public string CodeBase => getCodeBase(applicationIdentity);
/// <summary>
/// Gets the full name of the application.
/// </summary>
/// <value>
/// The full name of the application, also known as the display name.
/// </value>
public string FullName => getFullName(applicationIdentity);
/// <summary>
/// Returns the full name of the manifest-activated application.
/// </summary>
/// <returns>
/// The full name of the manifest-activated application.
/// </returns>
public override string ToString() => toString(applicationIdentity);
}
}