Skip to content

Instantly share code, notes, and snippets.

namespace System.Collections.ObjectModel
{
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
@weitzhandler
weitzhandler / OAuthHttpClient
Created November 2, 2015 02:58
A HttpClient that handles bearer tokens
using Microsoft.Owin.Security.OAuth;
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
namespace System.Net.Http
{
@weitzhandler
weitzhandler / MultiValueDictionary.cs
Last active September 17, 2021 14:23
MultiValueDictionary<TKey, TValue>
namespace System.Collections.ObjectModel
{
using System.Collections.Generic;
using System.Linq;
public class MultiValueDictionary<TKey, TElement>
: Collection<TElement>, ILookup<TKey, TElement>
{
public MultiValueDictionary(Func<TElement, TKey> keyExtractor)
: base(new Collection(keyExtractor))
namespace Xamarin.Forms
{
public class AutoSizeBehavior : Behavior<ListView>
{
ListView _ListView;
protected override void OnAttachedTo(ListView bindable)
{
_ListView = bindable;
bindable.HeightRequest = 0;
@weitzhandler
weitzhandler / ResolutionChanger.cpp
Last active May 14, 2020 14:18
Toggle ultrawide resolution
#include <windows.h>
typedef DWORD PELS_WIDTH;
const PELS_WIDTH Wide = 3440;
const PELS_WIDTH Narrow = 2560;
int __cdecl main()
{
DEVMODEA dm;
namespace System.Windows.Controls
{
using System;
using System.Collections;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
@weitzhandler
weitzhandler / ColumnReference.cs
Last active November 27, 2019 15:52
ColumnReference - easy way to convert between Excel column index and column letter
internal struct ColumnReference
{
readonly uint _ColumnIndex;
const int AsciiTrim = 'A' - 1;
const int LastChar = 'Z' - AsciiTrim;
ColumnReference(uint columnIndex)
{
_ColumnIndex = columnIndex;
}
// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using ReactiveUI;
@weitzhandler
weitzhandler / AutoCompleteView.cs
Last active October 27, 2018 13:43
Xamarin.Forms AutoCompleteView
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Reflection;
using System.Windows.Input;
namespace Xamarin.Forms
@weitzhandler
weitzhandler / DeviceTimer.cs
Last active July 23, 2017 19:41
Device.Timer wrapper for Xamarin with Prism DI support
using System;
using System.Linq;
using System.Collections.Generic;
using Prism.Services;
namespace Xamarin.Forms
{
public class DeviceTimer
{
readonly Action _Task;