From f712a0635789317e84c14e5b20cd7f999c3eb81b Mon Sep 17 00:00:00 2001 From: Jon Sagara Date: Wed, 15 Nov 2023 21:41:30 -0800 Subject: [PATCH] Added StringSplits. --- Directory.Build.props | 2 +- src/Sagara.Core/StringSplits.cs | 16 ++++++++++ ...on.SystemTextJson.SystemTextJsonHelper.md} | 32 +++++++++---------- .../docs/Sagara.Core.StringSplits.md | 12 +++++++ src/Sagara.Core/docs/index.md | 7 ++-- 5 files changed, 49 insertions(+), 20 deletions(-) create mode 100644 src/Sagara.Core/StringSplits.cs rename src/Sagara.Core/docs/{Sagara.Core.Json.SystemTextJson.STJsonHelper.md => Sagara.Core.Json.SystemTextJson.SystemTextJsonHelper.md} (52%) create mode 100644 src/Sagara.Core/docs/Sagara.Core.StringSplits.md diff --git a/Directory.Build.props b/Directory.Build.props index b86d1af..6f9e958 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,7 +5,7 @@ 12.0 - 2.0.4 + 2.0.5 2.0.0 2.0.0 Jon Sagara diff --git a/src/Sagara.Core/StringSplits.cs b/src/Sagara.Core/StringSplits.cs new file mode 100644 index 0000000..123abc9 --- /dev/null +++ b/src/Sagara.Core/StringSplits.cs @@ -0,0 +1,16 @@ +namespace Sagara.Core; + +/// +/// Static array references to that we don't have to allocate an array every time we call string.Split. +/// +public static class StringSplits +{ + public static readonly char[] + Colon = { ':' }, + Comma = { ',' }, + Email = { '@', '.' }, + ForwardSlash = { '/' }, + Newline = { '\n' }, + NewlineCarriageReturn = { '\n', '\r' }, + Semicolon = { ';' }; +} diff --git a/src/Sagara.Core/docs/Sagara.Core.Json.SystemTextJson.STJsonHelper.md b/src/Sagara.Core/docs/Sagara.Core.Json.SystemTextJson.SystemTextJsonHelper.md similarity index 52% rename from src/Sagara.Core/docs/Sagara.Core.Json.SystemTextJson.STJsonHelper.md rename to src/Sagara.Core/docs/Sagara.Core.Json.SystemTextJson.SystemTextJsonHelper.md index b613c55..0ddd7b8 100644 --- a/src/Sagara.Core/docs/Sagara.Core.Json.SystemTextJson.STJsonHelper.md +++ b/src/Sagara.Core/docs/Sagara.Core.Json.SystemTextJson.SystemTextJsonHelper.md @@ -1,20 +1,20 @@ #### [Sagara.Core](index.md 'index') ### [Sagara.Core.Json.SystemTextJson](index.md#Sagara.Core.Json.SystemTextJson 'Sagara.Core.Json.SystemTextJson') -## STJsonHelper Class +## SystemTextJsonHelper Class Helper methods for serializing JSON with System.Text.Json. ```csharp -public static class STJsonHelper +public static class SystemTextJsonHelper ``` -Inheritance [System.Object](https://docs.microsoft.com/en-us/dotnet/api/System.Object 'System.Object') 🡒 STJsonHelper +Inheritance [System.Object](https://docs.microsoft.com/en-us/dotnet/api/System.Object 'System.Object') 🡒 SystemTextJsonHelper ### Methods - + -## STJsonHelper.Deserialize(string, bool) Method +## SystemTextJsonHelper.Deserialize(string, bool) Method Parse the JSON string into into an instance of the type specified by a generic type parameter. Default is to use case-insensitive property names. @@ -24,18 +24,18 @@ public static T? Deserialize(string json, bool caseInsensitivePropertyNames=t ``` #### Type parameters - + `T` #### Parameters - + `json` [System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String') The JSON string to parse. - + `caseInsensitivePropertyNames` [System.Boolean](https://docs.microsoft.com/en-us/dotnet/api/System.Boolean 'System.Boolean') @@ -43,12 +43,12 @@ True to use case-insensitive property names; false to use case-sensitive property names. Default is true. #### Returns -[T](Sagara.Core.Json.SystemTextJson.STJsonHelper.md#Sagara.Core.Json.SystemTextJson.STJsonHelper.Deserialize_T_(string,bool).T 'Sagara.Core.Json.SystemTextJson.STJsonHelper.Deserialize(string, bool).T') +[T](Sagara.Core.Json.SystemTextJson.SystemTextJsonHelper.md#Sagara.Core.Json.SystemTextJson.SystemTextJsonHelper.Deserialize_T_(string,bool).T 'Sagara.Core.Json.SystemTextJson.SystemTextJsonHelper.Deserialize(string, bool).T') The deserialized object of type T. - + -## STJsonHelper.Serialize(TValue, bool, bool) Method +## SystemTextJsonHelper.Serialize(TValue, bool, bool) Method Convert the value into a JSON string. Default is camelCase property names and minified output. @@ -57,24 +57,24 @@ public static string Serialize(TValue value, bool camelCase=true, bool p ``` #### Type parameters - + `TValue` #### Parameters - + -`value` [TValue](Sagara.Core.Json.SystemTextJson.STJsonHelper.md#Sagara.Core.Json.SystemTextJson.STJsonHelper.Serialize_TValue_(TValue,bool,bool).TValue 'Sagara.Core.Json.SystemTextJson.STJsonHelper.Serialize(TValue, bool, bool).TValue') +`value` [TValue](Sagara.Core.Json.SystemTextJson.SystemTextJsonHelper.md#Sagara.Core.Json.SystemTextJson.SystemTextJsonHelper.Serialize_TValue_(TValue,bool,bool).TValue 'Sagara.Core.Json.SystemTextJson.SystemTextJsonHelper.Serialize(TValue, bool, bool).TValue') The value to convert to JSON. - + `camelCase` [System.Boolean](https://docs.microsoft.com/en-us/dotnet/api/System.Boolean 'System.Boolean') True to use camelCase property naming; false to use PascalCase. Default is true. - + `prettyPrint` [System.Boolean](https://docs.microsoft.com/en-us/dotnet/api/System.Boolean 'System.Boolean') diff --git a/src/Sagara.Core/docs/Sagara.Core.StringSplits.md b/src/Sagara.Core/docs/Sagara.Core.StringSplits.md new file mode 100644 index 0000000..d595e71 --- /dev/null +++ b/src/Sagara.Core/docs/Sagara.Core.StringSplits.md @@ -0,0 +1,12 @@ +#### [Sagara.Core](index.md 'index') +### [Sagara.Core](index.md#Sagara.Core 'Sagara.Core') + +## StringSplits Class + +Static array references to that we don't have to allocate an array every time we call string.Split. + +```csharp +public static class StringSplits +``` + +Inheritance [System.Object](https://docs.microsoft.com/en-us/dotnet/api/System.Object 'System.Object') 🡒 StringSplits \ No newline at end of file diff --git a/src/Sagara.Core/docs/index.md b/src/Sagara.Core/docs/index.md index 3cbaf08..864f254 100644 --- a/src/Sagara.Core/docs/index.md +++ b/src/Sagara.Core/docs/index.md @@ -35,6 +35,7 @@ and then copy this new value back to [CurrentGuid](Sagara.Core.SequentialGuid.md#Sagara.Core.SequentialGuid.CurrentGuid 'Sagara.Core.SequentialGuid.CurrentGuid'). - **[operator ++(SequentialGuid)](Sagara.Core.SequentialGuid.md#Sagara.Core.SequentialGuid.op_Increment(Sagara.Core.SequentialGuid) 'Sagara.Core.SequentialGuid.op_Increment(Sagara.Core.SequentialGuid)')** `Operator` Increment one or more bytes of [CurrentGuid](Sagara.Core.SequentialGuid.md#Sagara.Core.SequentialGuid.CurrentGuid 'Sagara.Core.SequentialGuid.CurrentGuid') to get the next sequential Guid, and then copy this new value back to [CurrentGuid](Sagara.Core.SequentialGuid.md#Sagara.Core.SequentialGuid.CurrentGuid 'Sagara.Core.SequentialGuid.CurrentGuid'). +- **[StringSplits](Sagara.Core.StringSplits.md 'Sagara.Core.StringSplits')** `Class` Static array references to that we don't have to allocate an array every time we call string.Split. @@ -78,10 +79,10 @@ ## Sagara.Core.Json.SystemTextJson Namespace -- **[STJsonHelper](Sagara.Core.Json.SystemTextJson.STJsonHelper.md 'Sagara.Core.Json.SystemTextJson.STJsonHelper')** `Class` Helper methods for serializing JSON with System.Text.Json. - - **[Deserialize<T>(string, bool)](Sagara.Core.Json.SystemTextJson.STJsonHelper.md#Sagara.Core.Json.SystemTextJson.STJsonHelper.Deserialize_T_(string,bool) 'Sagara.Core.Json.SystemTextJson.STJsonHelper.Deserialize(string, bool)')** `Method` Parse the JSON string into into an instance of the type specified by a generic type parameter. Default +- **[SystemTextJsonHelper](Sagara.Core.Json.SystemTextJson.SystemTextJsonHelper.md 'Sagara.Core.Json.SystemTextJson.SystemTextJsonHelper')** `Class` Helper methods for serializing JSON with System.Text.Json. + - **[Deserialize<T>(string, bool)](Sagara.Core.Json.SystemTextJson.SystemTextJsonHelper.md#Sagara.Core.Json.SystemTextJson.SystemTextJsonHelper.Deserialize_T_(string,bool) 'Sagara.Core.Json.SystemTextJson.SystemTextJsonHelper.Deserialize(string, bool)')** `Method` Parse the JSON string into into an instance of the type specified by a generic type parameter. Default is to use case-insensitive property names. - - **[Serialize<TValue>(TValue, bool, bool)](Sagara.Core.Json.SystemTextJson.STJsonHelper.md#Sagara.Core.Json.SystemTextJson.STJsonHelper.Serialize_TValue_(TValue,bool,bool) 'Sagara.Core.Json.SystemTextJson.STJsonHelper.Serialize(TValue, bool, bool)')** `Method` Convert the value into a JSON string. Default is camelCase property names and minified output. + - **[Serialize<TValue>(TValue, bool, bool)](Sagara.Core.Json.SystemTextJson.SystemTextJsonHelper.md#Sagara.Core.Json.SystemTextJson.SystemTextJsonHelper.Serialize_TValue_(TValue,bool,bool) 'Sagara.Core.Json.SystemTextJson.SystemTextJsonHelper.Serialize(TValue, bool, bool)')** `Method` Convert the value into a JSON string. Default is camelCase property names and minified output.