Skip to content

Instantly share code, notes, and snippets.

View programmation's full-sized avatar

David Dancy programmation

View GitHub Profile
var response = await GetAsync (requestUri, token);
var responseType = response.Content?.Headers?.ContentType?.MediaType;
this.Debug (String.Format ("Response {0} ({1}) -> {2}", (int)response.StatusCode, response.StatusCode.ToString (), responseType));
var responseText = await response.Content.ReadAsStringAsync ();
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;
namespace MyNamespace
{
public class LoggingHttpClientHandler : HttpClientHandler
{
public static class EnumExtensions
{
public static string Description(this Enum e)
{
var type = e.GetType();
var name = Enum.GetName(type, e);
var memberInfo = type.GetTypeInfo()
.DeclaredMembers
.Where(p => p.Name == name)
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
namespace MyNamespace
// from https://forums.xamarin.com/discussion/comment/279890/#Comment_279890
public partial class GradientView : ContentView
{
public Color StartColor { get; set; } = Color.Transparent;
public Color EndColor { get; set; } = Color.Transparent;
public bool Horizontal { get; set; } = false;
public GradientView()
{
@programmation
programmation / XamarinStartup.cs
Created August 6, 2017 23:39
Configure Xamarin app to use device culture
// from https://forums.xamarin.com/discussion/100540/set-default-culture-to-culture-of-device
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(CultureInfo.CurrentUICulture.ToString());
// from https://forums.xamarin.com/discussion/comment/168974/#Comment_168974
public class BindableToolbarItem : ToolbarItem
{
public static readonly BindableProperty IsVisibleProperty =
BindableProperty.Create("IsVisible", typeof (bool), typeof (BindableToolbarItem),
true, BindingMode.TwoWay, propertyChanged: OnIsVisibleChanged);
public BindableToolbarItem()
{
@programmation
programmation / FrameworkInterface.cs
Last active August 3, 2018 03:32
Framework defaults by Interface extensions
using System;
using System.Drawing;
// adapted from https://stackoverflow.com/a/37980328
namespace FrameworkInterface
{
public class Program
{
public static void Main(string[] args)
using System;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
using Nito.AsyncEx;
namespace Core.Utility
{
public abstract class BaseOperation<TInput, TOutput>
{
public TaskCompletionSource<TOutput> TaskCompletionSource { get; }
using System;
using System.Linq;
using System.Threading.Tasks;
namespace EventActionFunc
{
public class Program
{
static async Task Main(string[] args)
{