Repository navigation
Expand file tree
/
Copy pathUtilities.cs
More file actions
91 lines (87 loc) · 2.57 KB
/
Copy pathUtilities.cs
File metadata and controls
91 lines (87 loc) · 2.57 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Configuration;
/// <summary>
/// Various usefull things.
/// </summary>
public static class Utilities
{
/// <summary>
/// The connection string to the database.
/// </summary>
public static string ConnStr
{
get
{
return WebConfigurationManager.ConnectionStrings["FleetLinks"].ConnectionString;
}
}
/// <summary>
/// HTML encodes as string and trims it.
/// </summary>
/// <param name="str">The string to be cleaned.</param>
/// <param name="length">The maximum lenghth the string should be.</param>
/// <returns>A squeaky clean string.</returns>
public static string CleanString(string str, int length)
{
string ret = HttpUtility.HtmlEncode(str.Trim());
if (ret.Length > length)
ret = ret.Substring(0, length);
int ampNdx = ret.LastIndexOf('&');
if (ampNdx == -1)
return ret;
else
if (ret.IndexOf(';', ampNdx) == -1)
ret = ret.Substring(0, ampNdx);
return ret;
}
/// <summary>
/// The middle of the last nightly downtime.
/// </summary>
public static DateTime LastDowntimeMidpoint
{
get
{
DateTime now = DateTime.UtcNow;
DateTime midDowntime = new DateTime(now.Year, now.Month, now.Day, 11, 5, 0);
if (now < midDowntime)
{
midDowntime = midDowntime.Subtract(new TimeSpan(24, 0, 0));
}
return midDowntime;
}
}
private static object sync = new object();
private static IEveBrowser instance;
/// <summary>
/// Returns an instance of <see cref="IEveBrowser"/> that may or may not be a mock object.
/// See the web.config file for details
/// </summary>
public static IEveBrowser EveBrowser
{
get
{
if (instance == null)
{
lock (sync)
{
if (instance == null)
{
if (bool.Parse(WebConfigurationManager.AppSettings["OfflineMode"]))
instance = new OfflineEveBrowser();
else
instance = new EveBrowser();
}
}
}
return instance;
}
}
}