Skip to content

Commit

Permalink
More C# defaulting interop
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Jan 5, 2019
1 parent 760d856 commit 584846d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Equinox.Codec/UnionCodec.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace Equinox.UnionCodec

type OAttribute = System.Runtime.InteropServices.OptionalAttribute
type DAttribute = System.Runtime.InteropServices.DefaultParameterValueAttribute

open Newtonsoft.Json
open System.IO
open TypeShape
Expand Down Expand Up @@ -53,7 +56,7 @@ type JsonUtf8 =
/// <param name="settings">Configuration to be used by the underlying <c>Newtonsoft.Json</c> Serializer when encoding/decoding.</param>
/// <param name="requireRecordFields">Fail encoder generation if union cases contain fields that are not F# records. Defaults to <c>false</c>.</param>
/// <param name="allowNullaryCases">Fail encoder generation if union contains nullary cases. Defaults to <c>true</c>.</param>
static member Create<'Union when 'Union :> UnionContract.IUnionContract>(settings, ?requireRecordFields, ?allowNullaryCases)
static member Create<'Union when 'Union :> UnionContract.IUnionContract>(settings, [<O;D(null)>]?requireRecordFields, [<O;D(null)>]?allowNullaryCases)
: IUnionEncoder<'Union,byte[]> =
let inner =
UnionContract.UnionContractEncoder.Create<'Union,byte[]>(
Expand Down
8 changes: 7 additions & 1 deletion src/Equinox/Handler.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace Equinox

type OAttribute = System.Runtime.InteropServices.OptionalAttribute
type DAttribute = System.Runtime.InteropServices.DefaultParameterValueAttribute

/// Maintains a rolling folded State while Accumulating Events decided upon as part of a decision flow
type Context<'event, 'state>(fold : 'state -> 'event seq -> 'state, originState : 'state) =
let accumulated = ResizeArray<'event>()
Expand Down Expand Up @@ -35,7 +38,10 @@ type MaxResyncsExhaustedException(count) =
inherit exn(sprintf "Retry failed after %i attempts." count)

/// Central Application-facing API. Wraps the handling of decision or query flows in a manner that is store agnostic
type Handler<'event, 'state>(fold, log, stream : Store.IStream<'event, 'state>, maxAttempts : int, ?mkAttemptsExhaustedException, ?resyncPolicy) =
type Handler<'event, 'state>
( fold, log, stream : Store.IStream<'event, 'state>, maxAttempts : int,
[<O;D(null)>]?mkAttemptsExhaustedException,
[<O;D(null)>]?resyncPolicy) =
let contextArgs =
let mkContext state : Context<'event,'state> = Context<'event,'state>(fold, state)
let getEvents (ctx: Context<'event,'state>) = ctx.Accumulated
Expand Down

0 comments on commit 584846d

Please sign in to comment.