-
Notifications
You must be signed in to change notification settings - Fork 11
/
CmdletContext.cs
63 lines (54 loc) · 1.75 KB
/
CmdletContext.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
63
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Management.Automation.Host;
using System.Reflection;
using System.Text;
using Microsoft.SharePoint.Client;
namespace Lapointe.SharePointOnline.PowerShell
{
public sealed class CmdletContext : ClientContext
{
private PSHost m_powerShellHost;
private const string USER_AGENT_STRING_FORMAT = "SharePoint Online PowerShell by Gary Lapointe ({0})";
internal CmdletContext(string webFullUrl, PSHost host) : base(webFullUrl)
{
this.Host = host;
}
internal CmdletContext(Uri webFullUrl, PSHost host) : base(webFullUrl)
{
this.Host = host;
}
internal static string GetUserAgent()
{
return string.Format(CultureInfo.InvariantCulture, USER_AGENT_STRING_FORMAT, new object[] { ModuleVersion.FullBuildBase });
}
internal PSHost Host
{
get
{
return this.m_powerShellHost;
}
private set
{
if (value == null)
{
throw new ArgumentNullException("Host");
}
this.m_powerShellHost = value;
}
}
private class ModuleVersion
{
static ModuleVersion()
{
FullBuildVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;
FullBuildBase = new Version(FullBuildVersion).ToString(3) + ".0";
}
public static readonly string FullBuildVersion;
public static readonly string FullBuildBase;
}
}
}