Skip to content

Instantly share code, notes, and snippets.

View georg-jung's full-sized avatar

Georg Jung georg-jung

View GitHub Profile
@georg-jung
georg-jung / DropFilesBehavior.cs
Last active January 4, 2023 14:45
Drop files behavior for WinUI 3.
using Microsoft.UI.Xaml;
using Windows.ApplicationModel.DataTransfer;
namespace App1.Helpers;
// based on https://stackoverflow.com/a/65266427/1200847
public interface IFilesDropped
{
void OnFilesDropped(string[] files);
}
@georg-jung
georg-jung / ImageEmbedderRenderTask.cs
Created April 12, 2022 18:05
An IRenderTask implementation for NewsletterStudio 3 that embeds any images used in the mails sent as inline attachments. Inline attachments are not shown as attachments by typical mail clients.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Mail;
using System.Runtime.Caching;
using System.Threading.Tasks;
using HtmlAgilityPack;
using NewsletterStudio.Core.Rendering;
using NewsletterStudio.Core.Rendering.Tasks;
@georg-jung
georg-jung / InvalidXmlCharacterReplacingStreamReader.cs
Last active January 27, 2019 16:20
A StreamReader that replaces invalid XML characters. This enables you to use XmlReader for files which contain i.e. control chars.
// slightly updated version of https://stackoverflow.com/a/30351313/1200847
// uses .Net 4.0 function XmlConvert.IsXmlChar
// supports Async
public class InvalidXmlCharacterReplacingStreamReader : StreamReader
{
private readonly char _replacementCharacter;
public InvalidXmlCharacterReplacingStreamReader(string fileName, char replacementCharacter) : base(fileName)
{
@georg-jung
georg-jung / ProcessAsyncHelper.cs
Last active December 30, 2023 02:14 — forked from AlexMAS/ProcessAsyncHelper.cs
Use https://github.com/Tyrrrz/CliWrap instead, the following code has some shortcomings
using System;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
// based on https://gist.github.com/AlexMAS/276eed492bc989e13dcce7c78b9e179d
public static class ProcessAsyncHelper
{
public static async Task<ProcessResult> RunProcessAsync(string command, string arguments, int timeout)
{