Skip to content

Instantly share code, notes, and snippets.

/// <summary>
/// Retry the source using a separate Observable to determine whether to retry again or not.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="source"></param>
/// <param name="retryObservable">The observable factory used to determine whether to retry again or not. Number of retries & exception provided as parameters</param>
/// <param name="executeScheduler">The scheduler to be used to observe the source on. If non specified MainThreadScheduler used</param>
/// <param name="retryScheduler">The scheduler to use for the retry to be observed on. If non specified MainThreadScheduler used.</param>
/// <returns></returns>
public static IObservable<T> Retry<T>(this IObservable<T> source,Func<int,Exception, IObservable<bool>> retryObservable,IScheduler executeScheduler=null,IScheduler retryScheduler=null)
@jcmm33
jcmm33 / Extract.cs
Created August 11, 2016 09:43
Autofac Mutable Dependancy Resolver
public class AutofacDependencyResolver : IMutableDependencyResolver
{
private readonly IContainer _container;
public AutofacDependencyResolver(IContainer container)
{
_container = container;
}
public void Dispose()
@jcmm33
jcmm33 / GeoLocator.cs
Created July 4, 2016 16:02
Location Observable Sample
public IObservable<GeoLocation> CurrentLocationObservable(LocationOptions options)
{
IObservable<GeoLocation> observable = null;
if (!_observables.TryGetValue(options,out observable))
{
var coordinates = new Subject<GeoLocation> ();
var geoInstance = new GeoInstance (coordinates, options);
@jcmm33
jcmm33 / ReactiveAppCompatFragment.cs
Created June 29, 2016 17:23
Appcompat Fragments
using System;
using System.Collections.Generic;
using Android.Runtime;
using System.ComponentModel;
using System.Reactive.Subjects;
using System.Reactive;
using ReactiveUI;
namespace ReactiveUI.Framework.Android
{
@jcmm33
jcmm33 / log.txt
Last active March 8, 2016 15:49
Automapper installation log
Attempting to gather dependencies information for package 'AutoMapper.4.2.1' with respect to project 'AutomapperAndroidInstallIssue', targeting 'MonoAndroid,Version=v6.0'
Attempting to resolve dependencies for package 'AutoMapper.4.2.1' with DependencyBehavior 'Lowest'
Resolving actions to install package 'AutoMapper.4.2.1'
Resolved actions to install package 'AutoMapper.4.2.1'
Adding package 'Microsoft.CSharp.4.0.0' to folder 'E:\Temp\AutomapperAndroidInstallIssue\packages'
Added package 'Microsoft.CSharp.4.0.0' to folder 'E:\Temp\AutomapperAndroidInstallIssue\packages'
Added package 'Microsoft.CSharp.4.0.0' to 'packages.config'
Successfully installed 'Microsoft.CSharp 4.0.0' to AutomapperAndroidInstallIssue
Adding package 'System.Collections.4.0.10' to folder 'E:\Temp\AutomapperAndroidInstallIssue\packages'
Added package 'System.Collections.4.0.10' to folder 'E:\Temp\AutomapperAndroidInstallIssue\packages'
@jcmm33
jcmm33 / Active Activity code
Created February 23, 2016 09:12
Enter Transition
var commandContext = new CommandContext
{
ActivityOptions =
ActivityOptions.MakeSceneTransitionAnimation(context, new Pair(imageView, FoodVenue.ViewNameImageView))
};
currentActivity.StartActivity(intent,commandContext.ActivityOptions.ToBundle());
@jcmm33
jcmm33 / RetryWithConditionMixins.cs
Last active January 26, 2016 16:02
Reactive Extension Retry with Condition. Usage of Materialize could possibly reduce some of the leg work here but it seems to work for my scenario anyway. Similarly there may be issues related to observables which just complete and don't emit values, but that isn't a scenario we don't have.
public static class RetryWithConditionMixins
{
/// <summary>
/// Retry with condition observable.
/// </summary>
/// <typeparam name="TIn"></typeparam>
/// <typeparam name="TOut"></typeparam>
/// <param name="source"></param>
/// <param name="selector">The selector function which potentially can be retried</param>
@jcmm33
jcmm33 / MAIN.CS
Last active November 5, 2015 10:11
ScrollViewer in flipview
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
this.Loaded += MainPage_Loaded;
}
private void MainPage_Loaded(object sender, RoutedEventArgs e)
@jcmm33
jcmm33 / TaskExtensions.cs
Created May 15, 2015 08:45
Task Cancellation Extension
/// <summary>
/// Task Extensions
/// </summary>
public static class TaskExtensions
{
/// <summary>
/// Enable cancellation for a task for which cancellation tokens can't be specified.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="task"></param>
@jcmm33
jcmm33 / BuildDownload.ps1
Last active August 29, 2015 14:20
Build 2015 Video Downloader
# Insert code here to change to directory where you wish to download videos if you so desire
[Environment]::CurrentDirectory=(Get-Location -PSProvider FileSystem).ProviderPath
$a = ([xml](new-object net.webclient).downloadstring("http://s.ch9.ms/Events/dotnetConf/2015/RSS/mp4high"))
$a.rss.channel.item | foreach{
$url = New-Object System.Uri($_.enclosure.url)
$file = "- " + $_.creator + " - " + $_.title.Replace(":", "-").Replace("?", "").Replace("/", "-").Replace("<", "").Replace("|", "").Replace('"',"").Replace("*","")
$file = $file.substring(0, [System.Math]::Min(120, $file.Length))
$file = $file.trim()