forked from dahall/Vanara
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
David Hall
committed
Apr 5, 2018
1 parent
d9337cb
commit cd8afc3
Showing
12 changed files
with
162 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
using Vanara.Security.AccessControl; | ||
using static Vanara.PInvoke.AdvApi32; | ||
using static Vanara.PInvoke.AdvApi32; | ||
|
||
namespace Vanara.Security.AccessControl | ||
{ | ||
/// <summary>Class to hold associated <see cref="SystemPrivilege"/> and <see cref="PrivilegeAttributes"/> pairs.</summary> | ||
public class PrivilegeAndAttributes | ||
{ | ||
/// <summary>Initializes a new instance of the <see cref="PrivilegeAndAttributes"/> class.</summary> | ||
/// <param name="p">The privilege.</param> | ||
/// <param name="a">The attribute.</param> | ||
public PrivilegeAndAttributes(SystemPrivilege p, PrivilegeAttributes a) | ||
{ | ||
Privilege = p; | ||
Attributes = a; | ||
} | ||
|
||
/// <summary>Gets the privilege.</summary> | ||
/// <value>The privilege.</value> | ||
public SystemPrivilege Privilege { get; } | ||
/// <summary>Gets the attributes.</summary> | ||
/// <value>The attributes.</value> | ||
public PrivilegeAttributes Attributes { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,52 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using static Vanara.PInvoke.NetListMgr; | ||
|
||
namespace Vanara.Network | ||
{ | ||
public class NetworkConnection | ||
/// <summary>Represents a single network connection. Wraps <see cref="INetworkConnection"/>.</summary> | ||
public class NetworkConnection : IDisposable | ||
{ | ||
private readonly INetworkConnection conn; | ||
private INetworkConnection conn; | ||
|
||
internal NetworkConnection(INetworkConnection networkConnection) | ||
{ | ||
if (conn == null) throw new ArgumentNullException(nameof(networkConnection)); | ||
conn = networkConnection; | ||
} | ||
|
||
/// <summary>Returns the ID of the network adapter used by this connection. There may multiple connections using the same adapter ID.</summary> | ||
/// <returns>A GUID that specifies the adapter ID of the TCP/IP interface used by this network connection.</returns> | ||
public Guid AdapterId => conn.GetAdapterId(); | ||
|
||
/// <summary>Returns the Connection ID associated with this network connection.</summary> | ||
/// <returns>A GUID that specifies the Connection ID associated with this network connection.</returns> | ||
public Guid ConnectionId => conn.GetConnectionId(); | ||
|
||
/// <summary>Returns the connectivity state of the network.</summary> | ||
/// <returns>A NLM_CONNECTIVITY enumeration value that contains a bitmask that specifies the connectivity of this network connection.</returns> | ||
public NLM_CONNECTIVITY Connectivity => conn.GetConnectivity(); | ||
|
||
/// <summary>Returns the type of network connection.</summary> | ||
/// <returns>An NLM_DOMAIN_TYPE enumeration value that specifies the domain type of the network.</returns> | ||
public NLM_DOMAIN_TYPE DomainType => conn.GetDomainType(); | ||
|
||
/// <summary>Specifies if the associated network connection has any network connectivity.</summary> | ||
/// <value>If TRUE, this network connection has connectivity; if FALSE, it does not.</value> | ||
public bool IsConnected => conn.IsConnected; | ||
|
||
/// <summary>Specifies if the associated network connection has internet connectivity.</summary> | ||
/// <value>If TRUE, this network connection has connectivity to the internet; if FALSE, it does not.</value> | ||
public bool IsConnectedToInternet => conn.IsConnectedToInternet; | ||
|
||
internal INetwork Network => conn.GetNetwork(); | ||
|
||
/// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary> | ||
void IDisposable.Dispose() | ||
{ | ||
if (conn == null) return; | ||
Marshal.FinalReleaseComObject(conn); | ||
conn = null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.