Vote count:
0
I'm struggling somewhat to translate a piece of C# code that defines a static, generic extension, recursive extension method to F#. The particular piece of code is Daniel Smith's Stackoverflow Community Wiki piece at Write an Rx "RetryAfter" extension method. It's defined like so
public static IObservable<TSource> RetryAfterDelay<TSource, TException>(
this IObservable<TSource> source,
TimeSpan retryDelay,
int retryCount,
IScheduler scheduler) where TException : Exception
{
return source.Catch<TSource, TException>(ex =>
{
if (retryCount <= 0)
{
return Observable.Throw<TSource>(ex);
}
return
source.DelaySubscription(retryDelay, scheduler)
.RetryAfterDelay<TSource, TException>(
retryDelay, --retryCount, scheduler);
});
}
I'm unable to come up with a way to define the function so that I could call it inside the function. A current, simplified version I have is like so, wherein the compiler tells The field, constructor or member 'retryafterDelay' is not defined
[<Extension>]
type ObservableExtensions() =
[<Extension>]
static member inline retryAfterDelay((source: IObservable<_>), (retryDelay: TimeSpan), retryCount, (scheduler: IScheduler)): IObservable<_> =
source.Catch(fun ex -> source.DelaySubscription(retryDelay, scheduler).retryafterDelay(retryDelay, retryCount - 1, scheduler))
Should this be possible? I've tried to come up with an example of this particular case, but thus far in vain.
asked 53 secs ago
Aucun commentaire:
Enregistrer un commentaire