Created
May 17, 2024 09:25
-
-
Save anilkay/8d45bc0dc4de3fb19262c16773932576 to your computer and use it in GitHub Desktop.
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
| using NanoidDotNet; | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| namespace nanoiddeneme | |
| { | |
| internal class Utils | |
| { | |
| private string CustomAlphabet="abcdefgh12356789"; | |
| private int Size = 8; | |
| public Utils(string customAlphabet, int size) | |
| { | |
| CustomAlphabet = customAlphabet; | |
| Size = size; | |
| } | |
| public Utils() | |
| { | |
| } | |
| /// <summary> | |
| /// generated Random Url. | |
| /// </summary> | |
| /// <param name="baseUrl"></param> | |
| /// <param name="path"></param> | |
| /// <returns></returns> | |
| /// <exception cref="ArgumentNullException"></exception> | |
| internal (string generatedUrl, string generatedId) GenerateUrlForUniqueOperation(string baseUrl, string path) | |
| { | |
| if (string.IsNullOrEmpty(baseUrl)) | |
| { | |
| throw new ArgumentNullException("baseUrl Cannot be null or empty"); | |
| } | |
| if (string.IsNullOrEmpty(path)) | |
| { | |
| throw new ArgumentNullException("path Cannot be null or empty"); | |
| } | |
| string generatedId = Nanoid.Generate(alphabet: CustomAlphabet, size: Size); | |
| string generatedUrl = baseUrl + path + "/" + generatedId; | |
| return (generatedUrl, generatedId); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment