From 589b64be0c27b6477ad41cff3fe93d8e8b7eff0c Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Fri, 15 May 2020 16:12:20 -0400 Subject: add nuget packaging metadata --- IRCStates/IRCStates.csproj | 4 +++ IRCStates/ServerDisconnectedException.cs | 11 ++++++ IRCStates/ServerException.cs | 8 ----- IRCTokens/EnumerableExtensions.cs | 62 ++++++++++++++++++++++++++++++++ IRCTokens/Extensions.cs | 62 -------------------------------- IRCTokens/IRCTokens.csproj | 4 +++ 6 files changed, 81 insertions(+), 70 deletions(-) delete mode 100644 IRCStates/ServerException.cs create mode 100644 IRCTokens/EnumerableExtensions.cs delete mode 100644 IRCTokens/Extensions.cs diff --git a/IRCStates/IRCStates.csproj b/IRCStates/IRCStates.csproj index cf9f190..2b0cac2 100644 --- a/IRCStates/IRCStates.csproj +++ b/IRCStates/IRCStates.csproj @@ -2,6 +2,10 @@ netcoreapp3.1 + IRCStates + 1.0.0 + Ben Harris + tildeverse.org diff --git a/IRCStates/ServerDisconnectedException.cs b/IRCStates/ServerDisconnectedException.cs index 4d0bab6..0912987 100644 --- a/IRCStates/ServerDisconnectedException.cs +++ b/IRCStates/ServerDisconnectedException.cs @@ -4,5 +4,16 @@ namespace IRCStates { public class ServerDisconnectedException : Exception { + public ServerDisconnectedException(string message) : base(message) + { + } + + public ServerDisconnectedException(string message, Exception innerException) : base(message, innerException) + { + } + + public ServerDisconnectedException() + { + } } } diff --git a/IRCStates/ServerException.cs b/IRCStates/ServerException.cs deleted file mode 100644 index 0f44a88..0000000 --- a/IRCStates/ServerException.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace IRCStates -{ - public class ServerException : Exception - { - } -} diff --git a/IRCTokens/EnumerableExtensions.cs b/IRCTokens/EnumerableExtensions.cs new file mode 100644 index 0000000..f98a86d --- /dev/null +++ b/IRCTokens/EnumerableExtensions.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace IRCTokens +{ + public static class EnumerableExtensions + { + public static IEnumerable Split(this byte[] bytes, byte separator) + { + if (bytes == null || bytes.Length == 0) return new List(); + + var newLineIndices = bytes.Select((b, i) => b == separator ? i : -1).Where(i => i != -1).ToArray(); + var lines = new byte[newLineIndices.Length + 1][]; + var currentIndex = 0; + var arrIndex = 0; + + for (var i = 0; i < newLineIndices.Length && currentIndex < bytes.Length; ++i) + { + var n = new byte[newLineIndices[i] - currentIndex]; + Array.Copy(bytes, currentIndex, n, 0, newLineIndices[i] - currentIndex); + currentIndex = newLineIndices[i] + 1; + lines[arrIndex++] = n; + } + + // Handle the last string at the end of the array if there is one. + if (currentIndex < bytes.Length) + lines[arrIndex] = bytes.Skip(currentIndex).ToArray(); + else if (arrIndex == newLineIndices.Length) + // We had a separator character at the end of a string. Rather than just allowing + // a null character, we'll replace the last element in the array with an empty string. + lines[arrIndex] = Array.Empty(); + + return lines.ToArray(); + } + + public static byte[] Trim(this IEnumerable bytes, byte separator) + { + if (bytes == null) return Array.Empty(); + + var byteList = new List(bytes); + var i = 0; + + if (!byteList.Any()) return byteList.ToArray(); + + while (byteList[i] == separator) + { + byteList.RemoveAt(i); + i++; + } + + i = byteList.Count - 1; + while (byteList[i] == separator) + { + byteList.RemoveAt(i); + i--; + } + + return byteList.ToArray(); + } + } +} diff --git a/IRCTokens/Extensions.cs b/IRCTokens/Extensions.cs deleted file mode 100644 index e346a43..0000000 --- a/IRCTokens/Extensions.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace IRCTokens -{ - public static class Extensions - { - public static IEnumerable Split(this byte[] bytes, byte separator) - { - if (bytes == null || bytes.Length == 0) return new List(); - - var newLineIndices = bytes.Select((b, i) => b == separator ? i : -1).Where(i => i != -1).ToArray(); - var lines = new byte[newLineIndices.Length + 1][]; - var currentIndex = 0; - var arrIndex = 0; - - for (var i = 0; i < newLineIndices.Length && currentIndex < bytes.Length; ++i) - { - var n = new byte[newLineIndices[i] - currentIndex]; - Array.Copy(bytes, currentIndex, n, 0, newLineIndices[i] - currentIndex); - currentIndex = newLineIndices[i] + 1; - lines[arrIndex++] = n; - } - - // Handle the last string at the end of the array if there is one. - if (currentIndex < bytes.Length) - lines[arrIndex] = bytes.Skip(currentIndex).ToArray(); - else if (arrIndex == newLineIndices.Length) - // We had a separator character at the end of a string. Rather than just allowing - // a null character, we'll replace the last element in the array with an empty string. - lines[arrIndex] = Array.Empty(); - - return lines.ToArray(); - } - - public static byte[] Trim(this IEnumerable bytes, byte separator) - { - if (bytes == null) return Array.Empty(); - - var byteList = new List(bytes); - var i = 0; - - if (!byteList.Any()) return byteList.ToArray(); - - while (byteList[i] == separator) - { - byteList.RemoveAt(i); - i++; - } - - i = byteList.Count - 1; - while (byteList[i] == separator) - { - byteList.RemoveAt(i); - i--; - } - - return byteList.ToArray(); - } - } -} diff --git a/IRCTokens/IRCTokens.csproj b/IRCTokens/IRCTokens.csproj index 2fe9300..e69a61d 100644 --- a/IRCTokens/IRCTokens.csproj +++ b/IRCTokens/IRCTokens.csproj @@ -2,6 +2,10 @@ netcoreapp3.1 + IRCTokens + 1.0.0 + Ben Harris + tildeverse.org -- cgit 1.4.1