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 UsefulExtensionMethods | |
{ | |
public static TModel FirstOrNew<TModel>(this IEnumerable<TModel> queryable) where TModel : new() | |
=> queryable.FirstOrDefault() ?? new TModel(); | |
public static async Task<TModel> FirstOrNewAsync<TModel>(this IQueryable<TModel> queryable) where TModel : new() | |
=> (await queryable.FirstOrDefaultAsync()) ?? new TModel(); | |
public static bool IsActuallTheSameAs(this string s1, string s2, StringComparison stringComparison = StringComparison.InvariantCultureIgnoreCase) | |
=> string.Equals(s1, s2, stringComparison); |
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
## Ignore Visual Studio temporary files, build results, and | |
## files generated by popular Visual Studio add-ons. | |
## | |
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore | |
# User-specific files | |
*.suo | |
*.user | |
*.userosscache | |
*.sln.docstates |
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
# ASP.NET Core (.NET Framework) | |
# Build and test ASP.NET Core projects targeting the full .NET Framework. | |
# Add steps that publish symbols, save build artifacts, and more: | |
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core | |
trigger: | |
- master | |
- dev | |
pool: |
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 RatioToFraction | |
{ | |
/// <summary> | |
/// Converts a ratio to a fraction with the specified accuracy. | |
/// Accuracy = .0001 will make 1/1000 return correctly, but Accuracy = .001 return as 1/9991 | |
/// </summary> | |
/// <param name="ratio">The ratio.</param> | |
/// <param name="accuracy">Accuracy is the maximum relative error; convert to absolute maxError</param> | |
/// <returns>Tuple in the form of (numerator, denominator)</returns> | |
public static (decimal, decimal) NormalizeFraction(decimal ratio, decimal accuracy) |
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 KeyValuePairDataContainer : IEnumerable<KeyValuePair<string, string>[]> | |
{ | |
public IEnumerator<KeyValuePair<string, string>[]> GetEnumerator() | |
{ | |
yield return new KeyValuePair<string, string>[] | |
{ | |
new KeyValuePair<string, string>("key1", "value1") | |
}; | |
yield return new KeyValuePair<string, string>[] | |
{ |
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
$('.card-header').append('<span class="fas fa-minus float-right position-absolute" style="top: 1em; right: 1em;"></span>'); | |
$('.card-header').on('click', function (e) { | |
var card = $(this).closest('.card'); | |
$(card.find('.card-body')[0]).toggle('slide'); | |
swapCssClasses($(card.find('.position-absolute')), 'fa-plus', 'fa-minus'); | |
}); |
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 sealed class Status : TypeSafeEnum | |
{ | |
private static readonly Dictionary<int, Status> Instance = new Dictionary<int, Status>(); | |
public static readonly Status Active = new Status(0, "Active", 'A'); | |
public static readonly Status Inactive = new Status(1, "InActive", 'I'); | |
private Status(int value, string name, char code) : base(value, name, code) | |
{ | |
Instance[value] = this; | |
} |
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
@model EntityBase | |
@using System.ComponentModel | |
@using System.ComponentModel.DataAnnotations | |
@using System.Reflection | |
@using Microsoft.AspNetCore.Mvc.Localization | |
@using Microsoft.Extensions.Localization | |
@inject IHtmlLocalizer<DataAnnotationResources> DataAnnotationLocalizer | |
@inject IStringLocalizer<SharedResources> SharedLocalizer |
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; | |
using System.Net.Http; | |
using System.Net.Http.Headers; | |
using System.Text; | |
namespace IntegrationTest | |
{ | |
internal class BasicRequestWithHttpClient | |
{ | |
private const string Username = ""; |
NewerOlder