Skip to content

Instantly share code, notes, and snippets.

View conficient's full-sized avatar
🤓
Loving BLAZOR!

Howard Richards conficient

🤓
Loving BLAZOR!
View GitHub Profile
@conficient
conficient / ICalendarSimple.razor
Created October 27, 2021 18:48
A simple ICalendar with no requirement for external libraries
@if(IsValid)
{
<a href=@dataUrl download=@Filename >@ChildContent</a>
}
@code
{
[Parameter] public DateTime? Start { get; set; }
[Parameter] public DateTime? End { get; set; }
@conficient
conficient / bUnit.razor
Last active March 1, 2022 18:00
bUnit Quick Reference
@* need to change project SDK *@
<Project Sdk="Microsoft.NET.Sdk.Razor">
@* add bUnit package *@
<PackageReference Include="bunit" Verion="x.x.x" />
@* Use a `@code` block in a `.razor` test file, e.g. *@
@* if the test component inherits from `TestContext ` you don't need the `new TestContext();` bit
@code {
@conficient
conficient / NugetManager.cs
Created November 20, 2020 10:22 — forked from cpyfferoen/NugetManager.cs
NuGet API wrapper to search/install packages WITH AUTHENTICATION the same way Nuget.Exe/Client does it - looks up CredentialProviders and plugins (also for Credentials). Specific use case was Azure DevOps feed access.
using NuGet.Common;
using NuGet.Configuration;
using NuGet.Credentials;
using NuGet.PackageManagement;
using NuGet.Packaging;
using NuGet.Packaging.Core;
using NuGet.Packaging.Signing;
using NuGet.ProjectManagement;
using NuGet.Protocol;
using NuGet.Protocol.Core.Types;
@conficient
conficient / Gravatar.razor
Last active June 10, 2022 11:47
A Razor component that displays a Gravatar image for a user's email address
@* Creates a Gravatar image using Bootstrap styling from email address *@
<img class="rounded-circle" src="@url" />
@code
{
[Parameter] public string Email { get; set; }
[Parameter] public int Size { get; set; } = 24;
protected override void OnParametersSet()
{
// create hash
@conficient
conficient / DevOnly.razor
Created July 30, 2020 16:42
Blazor DevOnly component - only show the content of the component in Development mode
@using Microsoft.Extensions.Hosting
@inject Microsoft.AspNetCore.Hosting.IWebHostEnvironment env
@if (isDevelopment)
{
@ChildContent
}
@code {
[Parameter] public RenderFragment ChildContent { get; set; }
@conficient
conficient / appsettings.md
Last active October 6, 2023 09:55
AppSettings - in different environments

appsettings

In a JSON file, appsettings can be a nested heirachy, e.g.

{
    "Top": {
        "Second": {
            "Key": "value"
        }
 }
@conficient
conficient / BlazorModalExample.razor
Last active February 14, 2024 12:30
Blazor Modal Dialog with no JS interop
<button class="btn btn-primary" @onclick="@ModalShow">Show Dialog!</button>
@if (showModal)
{
<div class="modal fade show" id="myModal" style="display:block" aria-modal="true" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">