Skip to content

Instantly share code, notes, and snippets.

View GeorgDangl's full-sized avatar
😎
Coding

Georg Dangl GeorgDangl

😎
Coding
View GitHub Profile
@GeorgDangl
GeorgDangl / AvaCloudUserClientFactory.cs
Created July 5, 2023 11:26
Accessing AVACloud with user- instead of service accounts
public class AvaCloudUserClientFactory
{
public AvaCloudUserClientFactory(string userIdentifier,
string userPassword,
string avacloudBaseUrl = "https://avacloud-api.dangl-it.com",
Func<ITokenStorage> tokenStorageFactory = null)
{
_serviceProvider = BuildAvaCloudServiceProvider(userIdentifier,
userPassword,
avacloudBaseUrl,
@GeorgDangl
GeorgDangl / SwaggerExtensions.cs
Created April 16, 2023 20:39
NSwag Parameter Sorting
services.AddSwaggerDocument(c =>
{
c.PostProcess = (openApiDocument) =>
{
var operation = openApiDocument.Paths.Single(p => p.Key.StartsWith("/conversion/gaeb/ava"));
var operationParameters = operation.Value.Values.Single().Parameters;
var sortedParameters = SortParameters(operationParameters).ToList();
operationParameters.Clear();
foreach (var parameter in sortedParameters)
{
@GeorgDangl
GeorgDangl / ApiKeyRequirement.cs
Created July 10, 2018 14:48
Using Policy Based API Key Authorization in ASP.NET Core
public class ApiKeyRequirement : IAuthorizationRequirement
{
public IReadOnlyList<string> ApiKeys { get; set; }
public ApiKeyRequirement(IEnumerable<string> apiKeys)
{
ApiKeys = apiKeys?.ToList() ?? new List<string>();
}
}
@GeorgDangl
GeorgDangl / HackyReportPage.xaml
Created October 31, 2017 20:14
Displaying graphs and charts in a Xamarin WebView with Chart.js
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"
x:Class="App.Mobile.Views.HackyReportPage"
Title="Hacky Chart.js Report">
<WebView VerticalOptions="FillAndExpand">
<WebView.Source>
<HtmlWebViewSource Html="{Binding ReportHtml}" />
#begin[GAEB]
#begin[_Dangl]
[_Info]Created with Dangl GAEB Tool, Copyright 2013 - 2018 Georg Dangl, www.dangl-it.com, Version 1.4.15.0 (Built: 11.01.2018 16:13)[end]
#end[_Dangl]
#begin[GAEBInfo]
[Version]1.2[end]
[VersMon]11[end]
[VersJahr]2001[end]
[Datum]17.02.2018[end]
[Uhrzeit]11:07[end]
@GeorgDangl
GeorgDangl / Startup.cs
Created July 10, 2018 12:05
Excluding Assemblies from ASP.NET Core MVC Controller Discovery
services.AddMvc()
// This allows to exclude some assembly from controller discovery
.ConfigureApplicationPartManager(a =>
{
var appPart = a.ApplicationParts.FirstOrDefault(ap => ap.Name == "Assembly.Name");
if (appPart != null)
{
a.ApplicationParts.Remove(appPart);
}
})
namespace Project.SpaExtensions
{
public interface IUserLanguageService
{
string GetUserLocale();
}
}
@GeorgDangl
GeorgDangl / AssemblyInfo.cs
Last active September 18, 2022 03:27
Running SQL Server Integration Tests in .NET Core Projects via Docker, see https://blog.dangl.me/archive/running-sql-server-integration-tests-in-net-core-projects-via-docker/
using Xunit;
// This is required to have the IAssemblyFixture from the Xunit.Extensions.Ordering Package available
[assembly: TestFramework("Xunit.Extensions.Ordering.TestFramework", "Xunit.Extensions.Ordering")]
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
if (Database.ProviderName == "Microsoft.EntityFrameworkCore.Sqlite")
{
// SQLite does not have proper support for DateTimeOffset via Entity Framework Core, see the limitations
// here: https://docs.microsoft.com/en-us/ef/core/providers/sqlite/limitations#query-limitations
// To work around this, when the Sqlite database provider is used, all model properties of type DateTimeOffset
// use the DateTimeOffsetToBinaryConverter
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<RootNamespace></RootNamespace>
<IsPackable>False</IsPackable>
<NoWarn>CS0649;CS0169</NoWarn>