Skip to content

Instantly share code, notes, and snippets.

View jupre003's full-sized avatar

Justin jupre003

  • Germany
View GitHub Profile
@jupre003
jupre003 / InputSelectEnum.cs
Last active September 3, 2025 17:23
InputSelectEnum for Blazor
// file: Shared/InputSelectEnum.cs
using System;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Reflection;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Components.Rendering;
@jupre003
jupre003 / Peoject.cspoj
Last active November 13, 2023 14:05
Blazor VersionDisplay Component
<PropertyGroup>
<AssemblyVersion>2.4.2.0</AssemblyVersion>
<FileVersion>2.4.2.0</FileVersion>
<Version>2.4.2</Version>
</PropertyGroup>
@jupre003
jupre003 / EmbeddedResourceReader.cs
Created October 15, 2023 12:03
EmbeddedResourceReader
using System.Reflection;
internal static class EmbeddedResourceReader
{
public static string ReadResource(string resourceName)
{
Assembly assembly = Assembly.GetExecutingAssembly();
string content = string.Empty;
using (Stream resourceStream = assembly.GetManifestResourceStream(resourceName))
@jupre003
jupre003 / DotIcon
Created November 11, 2022 14:46
BS Icon with dot Indicator
<!--PERSON-->
<div class="d-flex h-100 bg-light">
<div class="d-flex">
<div>
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" fill="currentColor" class="bi bi-person"
viewBox="0 0 16 16">
<path
d="M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm2-3a2 2 0 1 1-4 0 2 2 0 0 1 4 0zm4 8c0 1-1 1-1 1H3s-1 0-1-1 1-4 6-4 6 3 6 4zm-1-.004c-.001-.246-.154-.986-.832-1.664C11.516 10.68 10.289 10 8 10c-2.29 0-3.516.68-4.168 1.332-.678.678-.83 1.418-.832 1.664h10z" />
</svg>
@jupre003
jupre003 / NumberStringFormatExtensions.cs
Last active October 4, 2025 20:56
Extension Methods for formating numbers as String in C# with german culture
namespace YourAppNamespace.Blazor.Components
{
public static class NumberStringFormatExtensions
{
public static string ToEuroCurrency(this double currencyValue, int decimalPlaces=-1)
{
if(decimalPlaces<0)
{
decimalPlaces = currencyValue.CalculateMinDecimalPlaces();
}
<Application
x:Class="AppName.ClientHost.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestPanda.Service.ClientHost">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<!-- Other merged dictionaries here -->
@jupre003
jupre003 / TimeSpanLabel.razor
Created December 27, 2021 21:49
Blazor TimeSpanLabel
@code {
[Parameter] public System.TimeSpan Value { get; set; }
}
<span>
@if (Value.Days > 0)
{
@Value.Days <span> @(Value.Days>1?"Tage ":"Tag ") </span>
}
@if (Value.Hours > 0)
@jupre003
jupre003 / EuroCurrencyLabel.razor
Last active December 27, 2021 21:51
Blazor EuroCurrencyLabel
@code {
[Parameter] public double Price { get; set; }
[Parameter] public string ToolTip { get; set; }
[Parameter] public int DecimalPlaces { get; set; } = 2;
}
<span title="@ToolTip" style="color: @(Price < 0 ? "#dc3545" : "#28a745");">
@if (Price > 0)
{
<span>+</span>
@jupre003
jupre003 / BuildConfig.cs
Last active January 31, 2021 16:39
Build IConfiguration with ConfigurationBuilder
private IConfiguration BuildConfig()
{
return new ConfigurationBuilder().AddJsonFile("appsettings.Test.json").Build();
}
@jupre003
jupre003 / ExampleJsInterop.cs
Last active January 31, 2021 16:39
ExampleJsInterop in Blazor
using Microsoft.JSInterop;
using System;
using System.Threading.Tasks;
namespace MbSoftlab.Blazor.Components
{
// This class provides an example of how JavaScript functionality can be wrapped
// in a .NET class for easy consumption. The associated JavaScript module is
// loaded on demand when first needed.
//