This file contains 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
public static class SelectListExtensionMethods | |
{ | |
/// <summary> | |
/// The SelectListItem to use by default as the placeholder for select lists generated by these extension methods when the user needs to pick a value. | |
/// </summary> | |
public static readonly SelectListItem DefaultEmptySelectListItem = new SelectListItem() { Text = "-- Pick One --", Value = string.Empty }; | |
/// <summary> | |
/// The SelectListItem to use by default as the placeholder for select lists generated by these extension methods when not picking a value is the same as using as of the possible choices (meant for filtering typically) | |
/// </summary> | |
public static readonly SelectListItem AnySelectListItem = new SelectListItem() { Text = "-- Any --", Value = string.Empty }; |
This file contains 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 System.ServiceModel.Channels; | |
using System.ServiceModel.Description; | |
using System.ServiceModel.Dispatcher; | |
internal class ReportingServicesEndpointBehavior : IEndpointBehavior | |
{ | |
public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters) { } | |
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime) | |
{ |
This file contains 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 System.ComponentModel.DataAnnotations; | |
using Microsoft.AspNetCore.Mvc.DataAnnotations; | |
using Microsoft.Extensions.Localization; | |
public class CustomValidationAttributeAdapterProvider : IValidationAttributeAdapterProvider | |
{ | |
readonly IValidationAttributeAdapterProvider baseProvider = new ValidationAttributeAdapterProvider(); | |
public IAttributeAdapter GetAttributeAdapter(ValidationAttribute attribute, IStringLocalizer stringLocalizer) | |
{ |
This file contains 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
/* | |
References (F4 - Additional References - Add...) | |
~~~~~~~~~~~~~~~~~~~ | |
<Your AspNetCore site assembly> | |
* Check Reference ASP.NET Core | |
Using (F4 - Additional Namespace Imports) | |
~~~~~~~~~~~~~~~~~~~ | |
Microsoft.AspNetCore.Hosting | |
Microsoft.Extensions.Configuration |
This file contains 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
Sample of some files I whipped up to try and demonstrate how to provide a | |
custom RazorPage to list errors recorded in StackExchange's Exceptional |
This file contains 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
public static class CollectionEditingHtmlExtensions | |
{ | |
/// <summary> | |
/// Begins a collection item by inserting a hidden field for the index value | |
/// </summary> | |
/// <param name="collectionName">The name of the collection property that owns this item</param> | |
/// <param name="indexValue">The value of the index for the current item</param> | |
public static IDisposable BeginCollectionItem<TModel>(this IHtmlHelper<TModel> html, string collectionName, Guid indexValue) | |
{ | |
return BeginCollectionItem(html, collectionName, indexValue == Guid.Empty ? null : indexValue.ToString(), html.ViewContext.Writer); |
This file contains 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
[HtmlTargetElement("CollectionItem")] | |
public class CollectionItemTagHelper : TagHelper | |
{ | |
private readonly IHtmlHelper htmlHelper; | |
[ViewContext] | |
[HtmlAttributeNotBound] | |
public ViewContext ViewContext { get; set; } | |
public CollectionItemTagHelper(IHtmlHelper htmlHelper) |
This file contains 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
# I use the days since Jan 1, 2000 as part of my build number to mimic a behavior found with .NET Full Framework | |
# that would autoincrement the 4th piece of the version information based on this math. I started using it as a | |
# way to reverse enginer the build date at runtime. After switching to .NET Core,I lost this, and start using this | |
# logic to get that behavior back | |
# Example build numbers resulting from this... | |
# 7.0.featurebranch.1+7550 | |
# 7.0.1+7550 | |
# Inspiration for the versioning differently between branches | |
# https://medium.com/@ychetankumarsarma/build-versioning-in-azure-devops-pipelines-94b5a79f80a0 |
This file contains 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
public class PrioritizedGroupsSelectListItemComparer : Comparer<SelectListItem> | |
{ | |
private readonly List<string> prioritizedGroupNames; | |
public PrioritizedGroupsSelectListItemComparer(params string[] prioritizedGroupNames) | |
{ | |
this.prioritizedGroupNames = prioritizedGroupNames.ToList(); | |
} | |
public PrioritizedGroupsSelectListItemComparer(IEnumerable<string> prioritizedGroupNames) | |
{ |
This file contains 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
public enum EllipseStyle { End, Middle }; | |
public static string EllipsizeString(this string text, int? maxLength, EllipseStyle ellipseStyle) | |
{ | |
if(string.IsNullOrEmpty(text)) | |
return null; | |
const string ellipsis = "..."; | |
var preferredCharacters = new[] { ' ', ',', '.', ';', ':', '?', '!' }; | |
string truncatedString = null; |
OlderNewer