-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathPeriscopeSiteContext.cs
85 lines (79 loc) · 2.7 KB
/
PeriscopeSiteContext.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using Common;
using SitePlugin;
using SitePluginCommon;
using System;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Windows.Controls;
namespace PeriscopeSitePlugin
{
public class PeriscopeSiteContext : SiteContextBase
{
public override Guid Guid => new Guid("FB468FFA-D0E5-4423-968C-5B9E1D258730");
public override string DisplayName => "Periscope";
protected override SiteType SiteType => SiteType.Periscope;
public override IOptionsTabPage TabPanel
{
get
{
var panel = new PeriscopeOptionsPanel();
panel.SetViewModel(new PeriscopeSiteOptionsViewModel(_siteOptions));
return new PeriscopeOptionsTabPage(DisplayName, panel);
}
}
public override ICommentProvider CreateCommentProvider()
{
return new PeriscopeCommentProvider2(_server, _logger, _options, _siteOptions, _userStoreManager)
{
SiteContextGuid = Guid,
};
}
private PeriscopeSiteOptions _siteOptions;
public override void LoadOptions(string path, IIo io)
{
_siteOptions = new PeriscopeSiteOptions();
try
{
var s = io.ReadFile(path);
_siteOptions.Deserialize(s);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
_logger.LogException(ex, "", $"path={path}");
}
}
public override void SaveOptions(string path, IIo io)
{
try
{
var s = _siteOptions.Serialize();
io.WriteFile(path, s);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
_logger.LogException(ex, "", $"path={path}");
}
}
public override bool IsValidInput(string input)
{
var (channelId, liveId) = Tools.ExtractChannelNameAndLiveId(input);
return !string.IsNullOrEmpty(channelId) || !string.IsNullOrEmpty(liveId);
}
public override UserControl GetCommentPostPanel(ICommentProvider commentProvider)
{
return null;
}
private readonly ICommentOptions _options;
private readonly IDataServer _server;
private readonly ILogger _logger;
public PeriscopeSiteContext(ICommentOptions options, IDataServer server, ILogger logger, IUserStoreManager userStoreManager)
: base(options, userStoreManager, logger)
{
_options = options;
_server = server;
_logger = logger;
}
}
}