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
private void ServiceAddressResolved(object sender, EventArgs e) | |
{ | |
var service = (NSNetService)sender; | |
var addresses = service.Addresses.Select(x => x.ToArray()).ToArray(); | |
var ipAddress = GetIPAddress(addresses.First()); // Consider that resolve might provide multiple IP addresses | |
// ... | |
} | |
private static IPAddress? GetIPAddress(byte[] data) | |
{ |
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
internal class WindowsFirewallService | |
{ | |
public static void AddRule(string ruleName, string udpPort) | |
{ | |
var policy = CreatePolicy(); | |
var rule = CreateRule(); | |
rule.Name = ruleName; | |
rule.Enabled = true; | |
rule.Action = NET_FW_ACTION_.NET_FW_ACTION_ALLOW; | |
rule.Profiles = (int)NET_FW_PROFILE_TYPE2_.NET_FW_PROFILE2_ALL; |
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
using System; | |
using System.Diagnostics; | |
using System.Net; | |
using System.Net.NetworkInformation; | |
using System.Net.Sockets; | |
namespace WakeOnLan | |
{ | |
internal class Program | |
{ |
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
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel.Composition; | |
using System.Linq; | |
using System.Reflection; | |
using System.Reflection.Context; | |
namespace WafApplication | |
{ | |
// .NET 4.x Reference: |
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
using System; | |
using System.Collections.Immutable; | |
using System.Diagnostics; | |
using System.IO; | |
using System.Linq; | |
using System.Reflection; | |
using System.Reflection.Metadata; | |
using System.Reflection.PortableExecutable; | |
using System.Security.Cryptography; |
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
internal static class EquatableHelper | |
{ | |
private static readonly ConcurrentDictionary<Type, Func<object, object, bool>> getEqualsFunctions | |
= new ConcurrentDictionary<Type, Func<object, object, bool>>(); | |
private static readonly ConcurrentDictionary<Type, Func<object, int>> getHashCodeFunctions | |
= new ConcurrentDictionary<Type, Func<object, int>>(); | |
public static bool PropertiesEquals(object x, object y) | |
{ | |
if (ReferenceEquals(x, y)) { return true; } |
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
// === Convert SQL Compact Edition database file to SQLite database file === | |
// Dump SQL Compact Edition data to SQLite compatible SQL file | |
// - Command line tools: https://github.com/ErikEJ/SqlCeToolbox/wiki/Command-line-tools | |
// - ExportSQLCE40.exe "Data Source=D:\Northwind.sdf;" Northwind.sql sqlite | |
// The SQL file created by the SqlCeToolbox contains GUID data as text. | |
// - Connection string with GUID as text: https://www.connectionstrings.com/sqlite/ | |
// Data Source=c:\mydb.db;Version=3;BinaryGUID=False; | |
// - Recommended is to store GUID data as binary instead of text (requires less space) |