This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See Observable.Empty() | |
public static Task Empty { | |
get { | |
// we have to return a new one every time, other wise the task will be disposed | |
return MakeEmpty(); | |
} | |
} | |
// See Observable.Catch() | |
public static Task Catch(this Task task) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$identity = $OctopusParameters["Octopus.Action.WindowsService.CustomAccountName"] | |
$nugetExists = Test-Path "$env:TEMP\nuget.exe" | |
if ($nugetExists -ne $true) { | |
Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile "$env:TEMP\nuget.exe" | |
} | |
& $env:TEMP\nuget.exe install Carbon -ExcludeVersion -OutputDirectory $env:TEMP | |
Import-Module $env:TEMP\Carbon\Carbon | |
Grant-Privilege -Identity $identity -Privilege SeServiceLogonRight |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reactive.Disposables; | |
using System.Text; | |
using System.Threading; | |
using Microsoft.ApplicationInsights; | |
using Microsoft.ApplicationInsights.DataContracts; | |
using RabbitMQ.Client; | |
using RabbitMQ.Client.Events; | |
namespace RabbitAppInsightsHelloWorld |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void WithNamedParameters<TImplementer> (this IRegistrationBuilder<TImplementer, ReflectionActivatorData, SingleRegistrationStyle> registrationBuilder) { | |
var activatorData = registrationBuilder.ActivatorData; | |
var implementationType = activatorData.ImplementationType; | |
var constructors = activatorData.ConstructorFinder.FindConstructors (implementationType); | |
registrationBuilder.OnPreparing (preparingEventArgs => OnPreparing (constructors, | |
activatorData.ConstructorSelector, | |
preparingEventArgs)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IDisposable Subscribe<TSource> (this IObservable<TSource> sequence, Func<TSource, IDisposable> onNext) { | |
var disposePreviousValues = sequence.Aggregate (Disposable.Empty, | |
(disposable, value) => { | |
using (disposable) | |
return onNext (value); | |
}); | |
var disposeLastValue = disposePreviousValues.TakeLast (1).Subscribe (last => last.Dispose ()); | |
return disposeLastValue; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class SynchronizationContextExtensions { | |
public static Task<T> ExecuteAsync<T> (this SynchronizationContext synchronizationContext, Func<T> factory, CancellationToken cancellationToken = default (CancellationToken)) { | |
var state = new State<T> (factory, | |
cancellationToken); | |
synchronizationContext.Post (ExecuteAsync<T>, | |
state); | |
return state.Task; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class CancellationTokenExtensions { | |
/// <summary> | |
/// Creates an observable sequence from a cancellationToken | |
/// </summary> | |
/// <param name="cancellationToken">token to observe</param> | |
/// <param name="throwOperationCanceledException">true to terminate the sequence with an exception instead of emitting a value</param> | |
/// <returns>an observable sequence that emits a value when the token is fired</returns> | |
public static IObservable<Unit> ToObservable (this CancellationToken cancellationToken, bool throwOperationCanceledException = false) { | |
if (!cancellationToken.CanBeCanceled) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Returns the elements from the source observable sequence only after the predicate returns true (non-inclusive) | |
/// </summary> | |
/// <typeparam name="TSource">The type of the elements in the source sequence</typeparam> | |
/// <param name="source">Source sequence to propagate elements for</param> | |
/// <param name="predicate">A function to test each source element for a condition</param> | |
/// <returns>An observable sequence containing the elements of the source sequence starting from the point the predicate is true</returns> | |
[NotNull] | |
public static IObservable<TSource> SkipUntil<TSource>([NotNull] this IObservable<TSource> source, [NotNull] Func<TSource, bool> predicate) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class Form1 : Form | |
{ | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
private void Form1_Load(object sender, EventArgs e) | |
{ | |
webBrowser1.Navigate("https://login.live.com"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary>Filters the elements of an observable sequence based on a nullability.</summary> | |
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam> | |
/// <param name="source">An observable sequence whose elements to filter.</param> | |
/// <returns>An observable sequence that contains elements from the input sequence that are not <c>null</c>.</returns> | |
/// <exception cref="T:System.ArgumentNullException"><paramref name="source" /> is null.</exception> | |
[NotNull] | |
[ContractAnnotation("source:null => halt")] | |
public static IObservable<TSource> WhereNotNull<TSource>([NotNull] this IObservable<TSource> source) where TSource : class | |
{ | |
if (source == null) |
OlderNewer