This file contains hidden or 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
| var ips = new[] { "95e6:a11d:a55b:43f3:8bd0:a45e:cb82:fa4b", "::1", "2041:0000:140F::875B:131B", "2041:0:140F::875B:131B" }; | |
| foreach (var ipString in ips) | |
| { | |
| var ip = IPAddress.Parse(ipString); | |
| //NOTE: MapToIPv6() is only needed when we parsed IPv4 as a source. 127.0.0.1 will become ::ffff:127.0.0.1 | |
| var bytes = ip.MapToIPv6().GetAddressBytes(); | |
| var guid = new Guid(bytes); | |
| var ipBack = new IPAddress(guid.ToByteArray()); | |
| //NOTE 2: Due to Microsoft using different byte order vs rest of the world, GUID will look different as string vs IPv6 as string. See https://stackoverflow.com/questions/9195551/why-does-guid-tobytearray-order-the-bytes-the-way-it-does |
This file contains hidden or 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
| /// <summary> | |
| /// SQL metadata helper. Needed mostly because SQL SqlMetaData class is rather badly designed. | |
| /// </summary> | |
| public static class SqlMetaDataHelper | |
| { | |
| /// <summary> | |
| /// Return SqlMetaData for specific DB type. | |
| /// For variable-length fields such as VarChar length -1 is the default (maximum supported), so specify the proper length. | |
| /// </summary> | |
| public static SqlMetaData Create(string name, SqlDbType sqlDbType, int length = -1) |
This file contains hidden or 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 SqlTypeHelper | |
| { | |
| private static readonly Dictionary<Type, SqlDbType> SqlDbTypes; | |
| static SqlTypeHelper() | |
| { | |
| //https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql-server-data-type-mappings | |
| SqlDbTypes = new Dictionary<Type, SqlDbType> | |
| { |
This file contains hidden or 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
| public static string FasterFormat(TimeSpan time) | |
| { | |
| var charP = new char[9]; | |
| int hours = time.Hours; | |
| int minutes = time.Minutes; | |
| int seconds = time.Seconds; | |
| int ms = time.Milliseconds; | |
| if (hours > 10) charP[0] = (char)('0' + hours / 10); | |
| if (hours > 0) | |
| { |
This file contains hidden or 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
| /// <summary> | |
| /// Found from the internets, heavily modified for optimization and flexibility | |
| /// </summary> | |
| /// <param name="size">Size in bytes</param> | |
| /// <param name="numberFormat">Format of the returned number. Defaults to 0.##</param> | |
| internal static string ReadableSize(long size, string numberFormat = "0.##") | |
| { | |
| size = Math.Abs(size); | |
| string suffix; | |
| float readable; |
This file contains hidden or 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
| # EditorConfig - http://EditorConfig.org. This file comes from Roslyn - https://github.com/dotnet/roslyn/blob/master/.editorconfig, edited | |
| # top-most EditorConfig file | |
| root = true | |
| # Use tabs for indentation. | |
| [*] | |
| indent_style = tab | |
| trim_trailing_whitespace = true | |
| end_of_line = crlf |