Skip to content

Instantly share code, notes, and snippets.

View conceptdev's full-sized avatar
💭
🐵monkeying around

Craig Dunn conceptdev

💭
🐵monkeying around
View GitHub Profile
public class MsgHub
{
public static MsgHub Instance = new MsgHub();
public static void Send<TArgs> (TArgs args)
{
var msg = args.GetType ().Name;
MessagingCenter.Send<MsgHub, TArgs> (Instance, msg, args);
}
using System.Drawing;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace HexagonApp {
[Register ("AppDelegate")]
class AppDelegate : UIApplicationDelegate {
UIWindow window;
public override bool FinishedLaunching (UIApplication app, NSDictionary options) {
@Clancey
Clancey / gist:7610128
Last active December 29, 2015 03:49
Background Downloader. Has the same API as WebClient but uses the underlying NSUrlRequest to download in the background.
public class BackgroundDownload
{
public BackgroundDownload ()
{
}
NSUrlSessionDownloadTask downloadTask;
static NSUrlSession session;
public async Task DownloadFileAsync(Uri url, string destination)
{
if (downloadTask != null)
@chkn
chkn / LocalCache.cs
Last active December 21, 2015 02:39
Xamarin async gems
public static class LocalCache {
static HashSet<string> tempKeys = new HashSet<string> ();
public static Task<Stream> GetCachedOrDownload (string key, Uri uri, bool temporary = true)
{
return GetCachedOrDownload (key, uri, CreateNativeHttpClient, temporary);
}
public static Task<Stream> GetCachedOrDownload (string key, Uri uri, Func<HttpClient> createHttpClient, bool temporary = true)
@felixcollins
felixcollins / AssetLibraryReadStream.cs
Created October 28, 2012 20:06
Monotouch - Stream Wrapper for AssetRepresentation
using System;
using System.IO;
using MonoTouch;
using MonoTouch.Foundation;
using MonoTouch.AssetsLibrary;
namespace StreamHelper
{
/// <summary>
@dsplaisted
dsplaisted / AsyncPortableTask.cs
Created July 8, 2012 05:36
Portable task wrappers
// An implementation of IPortableTask which wraps an actual Task.
// This has to go in a project targeting a platform or platforms which support Task and async/await
using System;
using System.Threading.Tasks;
namespace PortableTasks
{
public class AsyncPortableTask : IPortableTask
{