wasSharpNET – Diff between revs 9 and 11

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 9 Rev 11
1 /////////////////////////////////////////////////////////////////////////// 1 ///////////////////////////////////////////////////////////////////////////
2 // Copyright (C) Wizardry and Steamworks 2013 - License: GNU GPLv3 // 2 // Copyright (C) Wizardry and Steamworks 2013 - License: GNU GPLv3 //
3 // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // 3 // Please see: http://www.gnu.org/licenses/gpl.html for legal details, //
4 // rights of fair usage, the disclaimer and warranty conditions. // 4 // rights of fair usage, the disclaimer and warranty conditions. //
5 /////////////////////////////////////////////////////////////////////////// 5 ///////////////////////////////////////////////////////////////////////////
6   6  
7 using System.Diagnostics; 7 using System.Diagnostics;
8 using System.Text; 8 using System.Text;
9 using System.Text.RegularExpressions; 9 using System.Text.RegularExpressions;
10   10  
11 namespace wasSharpNET.Platform.Windows.Commands.NetSH 11 namespace wasSharpNET.Platform.Windows.Commands.NetSH
12 { 12 {
13 public class URLACL 13 public class URLACL
14 { 14 {
15 public string domain; 15 public string domain;
16 public string URL; 16 public string URL;
17   17  
18 private readonly Regex URLReservationRegex; 18 private readonly Regex URLReservationRegex;
19 public string username; 19 public string username;
20   20  
21 public URLACL(string URL, string username, string domain) 21 public URLACL(string URL, string username, string domain)
22 { 22 {
23 this.URL = URL; 23 this.URL = URL;
24 this.username = username; 24 this.username = username;
25 this.domain = domain; 25 this.domain = domain;
26   26  
27 URLReservationRegex = 27 URLReservationRegex =
28 new Regex( 28 new Regex(
29 string.Format(@"{0}.*{1}", Regex.Escape(URL), 29 string.Format(@"{0}.*{1}", Regex.Escape(URL),
30 Regex.Escape(string.Format(@"{0}\{1}", domain, username))), 30 Regex.Escape(string.Format(@"{0}\{1}", domain, username))),
31 RegexOptions.Singleline | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | 31 RegexOptions.Singleline | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase |
32 RegexOptions.Compiled); 32 RegexOptions.Compiled);
33 } 33 }
34   34  
35 public bool isReserved 35 public bool isReserved
36 { 36 {
37 get 37 get
38 { 38 {
39 var netSHOutput = new StringBuilder(); 39 var netSHOutput = new StringBuilder();
40 var checkProcess = new System.Diagnostics.Process(); 40 var checkProcess = new System.Diagnostics.Process();
41 checkProcess.StartInfo = new ProcessStartInfo("netsh", @"http show urlacl") 41 checkProcess.StartInfo = new ProcessStartInfo("netsh", @"http show urlacl")
42 { 42 {
43 RedirectStandardOutput = true, 43 RedirectStandardOutput = true,
44 CreateNoWindow = true, 44 CreateNoWindow = true,
45 WindowStyle = ProcessWindowStyle.Hidden, 45 WindowStyle = ProcessWindowStyle.Hidden,
46 UseShellExecute = false 46 UseShellExecute = false
47 }; 47 };
48   48  
49 checkProcess.OutputDataReceived += (sender, output) => 49 checkProcess.OutputDataReceived += (sender, output) =>
50 { 50 {
51 if (output?.Data != null) 51 if (output?.Data != null)
52 { 52 {
53 netSHOutput.Append(output.Data); 53 netSHOutput.Append(output.Data);
54 } 54 }
55 }; 55 };
56   56  
57 checkProcess.Start(); 57 checkProcess.Start();
58 checkProcess.BeginOutputReadLine(); 58 checkProcess.BeginOutputReadLine();
59 checkProcess.WaitForExit(); 59 checkProcess.WaitForExit();
60   -  
61   60  
62 return URLReservationRegex.IsMatch(netSHOutput.ToString()); 61 return URLReservationRegex.IsMatch(netSHOutput.ToString());
63 } 62 }
64 } 63 }
65   64  
66 public void Reserve() 65 public void Reserve()
67 { 66 {
68 System.Diagnostics.Process.Start(new ProcessStartInfo("netsh", 67 System.Diagnostics.Process.Start(new ProcessStartInfo("netsh",
69 string.Format(@"http add urlacl url={0} user={1}\{2}", URL, domain, username)) 68 string.Format(@"http add urlacl url={0} user={1}\{2}", URL, domain, username))
70 { 69 {
71 Verb = @"runas", 70 Verb = @"runas",
72 CreateNoWindow = true, 71 CreateNoWindow = true,
73 WindowStyle = ProcessWindowStyle.Hidden, 72 WindowStyle = ProcessWindowStyle.Hidden,
74 UseShellExecute = true 73 UseShellExecute = true
75 }).WaitForExit(); 74 }).WaitForExit();
76 } 75 }
77   76  
78 public void Release() 77 public void Release()
79 { 78 {
80 System.Diagnostics.Process.Start(new ProcessStartInfo("netsh", 79 System.Diagnostics.Process.Start(new ProcessStartInfo("netsh",
81 string.Format(@"http del urlacl url={0}", URL)) 80 string.Format(@"http del urlacl url={0}", URL))
82 { 81 {
83 Verb = @"runas", 82 Verb = @"runas",
84 CreateNoWindow = true, 83 CreateNoWindow = true,
85 WindowStyle = ProcessWindowStyle.Hidden, 84 WindowStyle = ProcessWindowStyle.Hidden,
86 UseShellExecute = true 85 UseShellExecute = true
87 }).WaitForExit(); 86 }).WaitForExit();
88 } 87 }
89 } 88 }
90 } -  
91   89 }
-   90  
92
Generated by GNU Enscript 1.6.5.90.
-  
93   -  
94   -  
95   -