zpx-utils
1.0.0
dotnet add package zpx-utils --version 1.0.0
NuGet\Install-Package zpx-utils -Version 1.0.0
<PackageReference Include="zpx-utils" Version="1.0.0" />
<PackageVersion Include="zpx-utils" Version="1.0.0" />
<PackageReference Include="zpx-utils" />
paket add zpx-utils --version 1.0.0
#r "nuget: zpx-utils, 1.0.0"
#:package zpx-utils@1.0.0
#addin nuget:?package=zpx-utils&version=1.0.0
#tool nuget:?package=zpx-utils&version=1.0.0
ZopoxoUtils Documentation Overview The ZopoxoUtils namespace provides utility extension methods for string manipulation and numeric operations. It includes two main extension classes: StringExtensions and IntegralExtensions, each containing a variety of helpful methods to streamline common tasks. Classes
StringExtensions The StringExtensions class provides a set of extension methods for string manipulation, including removing special characters, extracting numeric values, and mapping strings to predefined zones. Methods: � RemoveSpecialCharacters(string input) Removes special characters from the input string, leaving only alphanumeric characters, periods, and spaces. � ExtractNumericValueFromString(string input) Extracts numeric values from the input string, removing all non-numeric characters except for periods and spaces. � MapToZone(string input) Maps the input string to a predefined zone based on its value, after removing special characters and ignoring case. � RemoveSpaces(string input) Removes all spaces (including tabs, newlines, etc.) from the input string. � RemoveBackSlash(string input) Removes backslashes and special characters like \n, \t, \b, \r, \f, etc., from the input string. � EscapeCSVString(string input) Escapes CSV-specific characters in the input string, such as commas, double quotes, and newline characters, to make it CSV-compatible. � TrimPhoneNumber(string number) Removes all non-numeric characters from the input string and trims it to the last 10 digits if the length exceeds 10.
GenricListExtention
Methods:
The GenricListExtention class provides extension methods for working with generic lists and dictionaries. It contains methods to convert a list of objects into a list of dictionaries, as well as methods to convert these dictionaries into CSV formats, either as a byte array or a memory stream.
Features Convert any List<T> to a List of Dictionary<string, object>: This method takes a generic list of objects and converts each object into a dictionary of property names and values.
Convert Dictionary to CSV as Byte Array: Converts a list of dictionaries into CSV format and returns the result as a byte array.
Convert Dictionary to CSV as MemoryStream: Converts a list of dictionaries into CSV format and returns the result as a MemoryStream object.
Usage
- Convert a List to a List of Dictionaries Method: ConvertToDictionaryList<T>
This method takes a list of any type T and converts it to a List<Dictionary<string, object>>.
Example:
var listOfObjects = new List<YourClass> { new YourClass(), new YourClass() }; var dictionaryList = listOfObjects.ConvertToDictionaryList(); Parameters: models: A generic list of type T (where T is a class). Returns: A List<Dictionary<string, object>> containing property names and values for each object in the input list. 2. Convert Dictionary List to CSV Byte Array Method: ConvertDictionaryToCSV
This method converts a list of dictionaries into a CSV formatted byte array.
Example:
var byteArray = dictionaryList.ConvertDictionaryToCSV(); Parameters: data: A list of dictionaries where each dictionary represents a row in the CSV. Returns: A byte[] containing the CSV data. 3. Convert Dictionary List to CSV MemoryStream Method: ConvertDictionaryToStream
This method converts a list of dictionaries into a CSV formatted MemoryStream.
Example: csharp Copy code var memoryStream = dictionaryList.ConvertDictionaryToStream(); Parameters: data: A list of dictionaries where each dictionary represents a row in the CSV. Returns: A MemoryStream containing the CSV data. Notes The methods utilize reflection to read property names and values from the provided objects. Only properties with the IncludeInDictionaryAttribute attribute will be included in the converted dictionary. Make sure to define the EscapeCSVString() extension method to handle special characters in CSV data. Dependencies Namespace: Ensure that the necessary namespaces are included:
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; using System.Text; 3. IntegralExtensions The IntegralExtensions class provides a set of extension methods for numeric operations, including conversions between grams and kilograms and summing numbers. Methods: Methods: � ConvertGramsToKilograms<T>(T input) Converts the given input from grams to kilograms. Supports int, double, float, and decimal types. Returns the converted value or the original input if the type is unsupported. � ConvertKilogramsToGrams<T>(T input) Converts the given input from kilograms to grams. Supports int, double, float, and decimal types. Returns the converted value or the original input if the type is unsupported. � SumTwoNumbers(int number1, int number2) Sums two integer numbers and returns the result. � SumThreeNumbers(int number1, int number2, int number3) Sums three integer numbers and returns the result. � SumNumbers(params int[] numbers) Sums a variable number of integer numbers. Returns the sum of the numbers or 0 if the input is null or empty. � RoundOff<T>(T input) Rounds off the given input to two decimal places. Supports double and decimal types. Returns the rounded value or the original input if the type is unsupported.
- Type Casting Extensions Methods: � ConvertObjectToSpecificType<T>(object input) Converts an object to a specific type T. The type T can be any data type (e.g., int, string, etc.). If the type is a string, it will remove backslashes from the input string. Returns default(T) if the input is DBNull, otherwise, returns the converted value of type T.
License This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|