-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeb2PdfConfig.cs
More file actions
56 lines (50 loc) · 1.42 KB
/
Web2PdfConfig.cs
File metadata and controls
56 lines (50 loc) · 1.42 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
using System;
namespace Web2Pdf
{
public class Web2PdfConfig
{
public string UrlString { get; set; }
public string OutputFilePath { get; set; }
public bool UseTimestampPrefix { get; set; } = false;
public static Web2PdfConfig FromArgs(string[] args)
{
var config = new Web2PdfConfig();
if (args.Length > 0)
{
config.UrlString = args[0];
if (args.Length > 1)
{
if (args[1].ToLower().Equals("/ts"))
{
config.UseTimestampPrefix = true;
if (args.Length == 3)
{
config.OutputFilePath = args[2];
}
}
else if (args.Length == 2)
{
config.OutputFilePath = args[1];
}
}
}
return config;
}
public bool IsValid()
{
try
{
new Uri(UrlString);
if (!string.IsNullOrEmpty(OutputFilePath) && OutputFilePath.ToLower().EndsWith(".pdf"))
{
return true;
}
}
catch
{
return false;
}
return false;
}
}
}