forked from pnp/powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBrandCenterFontPipeBind.cs
More file actions
68 lines (62 loc) · 2.19 KB
/
BrandCenterFontPipeBind.cs
File metadata and controls
68 lines (62 loc) · 2.19 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using Microsoft.SharePoint.Client;
using PnP.PowerShell.Commands.Model.SharePoint.BrandCenter;
using PnP.PowerShell.Commands.Utilities;
namespace PnP.PowerShell.Commands.Base.PipeBinds
{
public sealed class BrandCenterFontPipeBind
{
public readonly Guid? _id;
public readonly string _title;
private Font _font;
public BrandCenterFontPipeBind()
{
}
public BrandCenterFontPipeBind(Guid id)
{
_id = id;
}
public BrandCenterFontPipeBind(string idOrTitle)
{
if(Guid.TryParse(idOrTitle, out Guid guidId))
{
_id = guidId;
}
else
{
_title = idOrTitle;
}
}
public BrandCenterFontPipeBind(Font font)
{
_font = font;
}
/// <summary>
/// Gets the Font represented in this pipebind
/// </summary>
/// <param name="cmdlet">The cmdlet instance to use to retrieve the Font in this pipe bind</param>
/// <param name="clientContext">ClientContext to use to communicate with SharePoint Online</param>
/// <param name="webUrl">Url to use to check the site collection Brand Center</param>
/// <param name="store">The store to check for the font. When NULL, it will check all stores.</param>
/// <exception cref="Exception">Thrown when the ContainerProperties cannot be retrieved</exception>
/// <returns>Font</returns>
public Font GetFont(BasePSCmdlet cmdlet, ClientContext clientContext, string webUrl, Store store = Store.All)
{
if (_font != null)
{
return _font;
}
else if (_id.HasValue)
{
_font = BrandCenterUtility.GetFontPackageById(cmdlet, clientContext, _id.Value, webUrl, store);
return _font;
}
else if (!string.IsNullOrEmpty(_title))
{
_font = BrandCenterUtility.GetFontPackageByTitle(cmdlet, clientContext, _title, webUrl, store);
return _font;
}
return null;
}
}
}