-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathConfig.cs
62 lines (55 loc) · 1.56 KB
/
Config.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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
namespace WebScreenSaver
{
internal static class Config
{
public static string Path
{
get
{
return System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetCallingAssembly().Location),
"url.txt");
}
}
public static IEnumerable<string> Urls
{
get
{
return from url in UrlText
where !url.StartsWith("#")
select url;
}
}
public static IEnumerable<string> UrlText
{
get
{
IEnumerable<string> urls = null;
if (File.Exists(Path))
{
urls = from url in File.ReadAllLines(Path)
where !String.IsNullOrEmpty(url)
select url.Trim();
}
return urls;
}
}
public static UrlList UrlList
{
get { return new UrlList(Urls); }
}
public static WebpageView CurrentView
{
get { return new WebpageView(UrlList); }
}
public static void Save(IEnumerable<string> urls)
{
string text = urls.Aggregate(String.Empty, (current, url) => current + (url + Environment.NewLine));
File.WriteAllText(Path, text);
}
}
}