### Get Repository Root Path in C# Source: https://github.com/intellitect/multitool/blob/main/README.md This C# example illustrates how to obtain the default root path of a Git repository using `IntelliTect.Multitool.RepositoryPaths.GetDefaultRepoRoot()`. It then demonstrates combining this root path with a filename to construct a full, environment-independent file path. ```csharp // In this case, the GetDefaultRepoRoot() method can be used to get the root of a repository. string fullPathToTheFile = Path.Combine(IntelliTect.Multitool.RepositoryPaths.GetDefaultRepoRoot(), "TheFile.txt"); ``` -------------------------------- ### Display ReleaseDateAttribute on CSHTML Page Source: https://github.com/intellitect/multitool/blob/main/README.md This CSHTML example shows how to directly display the UTC compile-time date obtained from `IntelliTect.Multitool.ReleaseDateAttribute.GetReleaseDate()` within a Razor page. The result is a UTC `DateTime` string rendered directly in the HTML output. ```cshtml // This example is in cshtml. @IntelliTect.Multitool.ReleaseDateAttribute.GetReleaseDate() // Returns a datetime in UTC ``` -------------------------------- ### IntelliTect.Multitool Extension Methods API Source: https://github.com/intellitect/multitool/blob/main/README.md This section provides API documentation for the extension methods available in the IntelliTect.Multitool library, detailing methods within `StringExtensions` and `SystemLinqExtensions` along with their purpose and the types they extend. ```APIDOC StringExtensions: ValidateUrlString(this string urlString): Description: Extension method to validate a URL string by checking to make sure the string is formatted correctly. CreateUrlSlug(this string inputString): Description: Extension method to modify a string so that it is URL compatible. SystemLinqExtensions: WhereNotNull(this System.Linq.Generic.IEnumerable source): Description: Extension method to allow return of non-null value from a null object. Returns: System.Linq.Generic.IEnumerable ``` -------------------------------- ### Rebase a Git topic branch against main Source: https://github.com/intellitect/multitool/blob/main/CONTRIBUTING.md Instructions on how to rebase your local topic branch against the latest changes in the main repository, including fetching updates, checking out branches, performing the rebase, resolving merge conflicts, and pushing the updated branch. It also notes when force pushing is acceptable. ```git git fetch upstream git checkout main git rebase upstream/main git checkout your-branch git rebase main # Fix any merge conflicts git push origin your-branch # You may need to git push origin your-branch --force to get the commits pushed. ``` -------------------------------- ### Format and Localize ReleaseDateAttribute on CSHTML Source: https://github.com/intellitect/multitool/blob/main/README.md This CSHTML snippet demonstrates how to convert the UTC `DateTime` from `GetReleaseDate()` to a local timezone (Pacific Standard Time) and format it into a specific string format ('d MMM, yyyy h:mm:ss tt'). It utilizes `TimeZoneInfo.ConvertTimeFromUtc` and `CultureInfo.InvariantCulture` for precise formatting and localization. ```cshtml // convert this UTC DateTime object into one for my local timezone that is formatted in a “d MMM, yyyy h:mm:ss tt” (ex: 8 Feb, 2023 11:36:31 AM). // The following code will format the date and convert it to my local time zone of Pacific Standard Time. Build: @if (IntelliTect.Multitool.ReleaseDateAttribute.GetReleaseDate() is DateTime date) { @TimeZoneInfo.ConvertTimeFromUtc(date, TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time")).ToString("d MMM, yyyy h:mm:ss tt", CultureInfo.InvariantCulture) } // Result is "Build: 8 Feb, 2023 11:36:31 AM" ``` -------------------------------- ### Assign ReleaseDateAttribute to C# Variable Source: https://github.com/intellitect/multitool/blob/main/README.md This C# code snippet demonstrates how to retrieve the compile-time UTC DateTime using `IntelliTect.Multitool.ReleaseDateAttribute.GetReleaseDate()` and assign it to a local `DateTime?` variable. The method returns a nullable `DateTime` representing the build date. ```csharp DateTime? date = IntelliTect.Multitool.ReleaseDateAttribute.GetReleaseDate(); // Returns a datetime in UTC to date ``` -------------------------------- ### Filter Null Values with WhereNotNull Extension in C# Source: https://github.com/intellitect/multitool/blob/main/README.md This C# snippet demonstrates the `WhereNotNull()` extension method from `SystemLinqExtensions`. It efficiently filters out null values from a `List` (a list of nullable strings), returning a new `List` containing only the non-null elements. This method is useful for safely processing collections that may contain nulls. ```csharp List listWithSomeNullValues = ["this", null, "is", null, "my", null, "favorite", null]; List listWithoutNullValues = listWithSomeNullValues.WhereNotNull().ToList(); // returns ["this", "is", "my", "favorite"] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.