1 people like it.
Like the snippet!
Option Type Support on ServiceStack
A simple module for registering option types with ServiceStack serializer.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
|
namespace RockSpot.Runtime
open System
open ServiceStack.Text
module ServiceStack =
let inline deserializeOption x =
match x with
| null -> None
| _ -> Some (JsonSerializer.DeserializeFromString<_> x)
let inline serializeOption x =
match x with
| Some v -> JsonSerializer.SerializeToString<_> v
| None -> null
let registerOptionFor<'a> () =
JsConfig<'a option>.DeSerializeFn <- Func<_,_>(deserializeOption)
JsConfig<'a option>.SerializeFn <- Func<_,_>(serializeOption)
let registerPrimitiveOptions =
registerOptionFor<string>
>> registerOptionFor<bool>
>> registerOptionFor<char>
>> registerOptionFor<byte>
>> registerOptionFor<sbyte>
>> registerOptionFor<int16>
>> registerOptionFor<uint16>
>> registerOptionFor<int>
>> registerOptionFor<uint32>
>> registerOptionFor<int64>
>> registerOptionFor<uint64>
>> registerOptionFor<nativeint>
>> registerOptionFor<unativeint>
>> registerOptionFor<single>
>> registerOptionFor<double>
>> registerOptionFor<decimal>
>> registerOptionFor<DayOfWeek>
>> registerOptionFor<Guid>
>> registerOptionFor<TimeSpan>
>> registerOptionFor<DateTime>
>> registerOptionFor<DateTimeOffset>
|
namespace System.Runtime
namespace System
namespace ServiceStack
namespace ServiceStack.Text
Multiple items
module ServiceStack
from RockSpot.Runtime
--------------------
namespace ServiceStack
val deserializeOption : x:string -> 'a option
Full name: RockSpot.Runtime.ServiceStack.deserializeOption
val x : string
union case Option.None: Option<'T>
union case Option.Some: Value: 'T -> Option<'T>
Multiple items
type JsonSerializer =
static val UTF8Encoding : UTF8Encoding
static member DeserializeFromReader<'T> : reader:TextReader -> 'T + 1 overload
static member DeserializeFromStream<'T> : stream:Stream -> 'T + 1 overload
static member DeserializeFromString<'T> : value:string -> 'T + 1 overload
static member DeserializeRequest<'T> : webRequest:WebRequest -> 'T + 1 overload
static member DeserializeResponse<'T> : webRequest:WebRequest -> 'T + 3 overloads
static member SerializeToStream<'T> : value:'T * stream:Stream -> unit + 1 overload
static member SerializeToString<'T> : value:'T -> string + 1 overload
static member SerializeToWriter<'T> : value:'T * writer:TextWriter -> unit + 1 overload
Full name: ServiceStack.Text.JsonSerializer
--------------------
type JsonSerializer<'T> =
new : unit -> JsonSerializer<'T>
member CanCreateFromString : type:Type -> bool
member DeserializeFromReader : reader:TextReader -> 'T
member DeserializeFromString : value:string -> 'T
member SerializeToString : value:'T -> string
member SerializeToWriter : value:'T * writer:TextWriter -> unit
Full name: ServiceStack.Text.JsonSerializer<_>
--------------------
JsonSerializer() : unit
JsonSerializer.DeserializeFromString<'T>(value: string) : 'T
JsonSerializer.DeserializeFromString(value: string, type: Type) : obj
val serializeOption : x:'a option -> string
Full name: RockSpot.Runtime.ServiceStack.serializeOption
val x : 'a option
val v : 'a
JsonSerializer.SerializeToString<'T>(value: 'T) : string
JsonSerializer.SerializeToString(value: obj, type: Type) : string
val registerOptionFor<'a> : unit -> unit
Full name: RockSpot.Runtime.ServiceStack.registerOptionFor
Multiple items
type JsConfig =
static val TreatValueAsRefTypes : HashSet<Type>
static member AlwaysUseUtc : bool with get, set
static member AppendUtcOffset : Nullable<bool> with get, set
static member AssumeUtc : bool with get, set
static member BeginScope : unit -> JsConfigScope
static member ConvertObjectTypesIntoStringDictionary : bool with get, set
static member DateHandler : DateHandler with get, set
static member EmitCamelCaseNames : bool with get, set
static member EmitLowercaseUnderscoreNames : bool with get, set
static member EscapeUnicode : bool with get, set
...
Full name: ServiceStack.Text.JsConfig
--------------------
type JsConfig<'T> =
new : unit -> JsConfig<'T>
static val IncludeTypeInfo : Nullable<bool>
static val ExcludeTypeInfo : Nullable<bool>
static val EmitCamelCaseNames : Nullable<bool>
static val EmitLowercaseUnderscoreNames : Nullable<bool>
static val ExcludePropertyNames : string[]
static member DeSerializeFn : Func<string, 'T> with get, set
static member HasDeserialingFn : bool
static member HasDeserializeFn : bool
static member HasSerializeFn : bool
...
Full name: ServiceStack.Text.JsConfig<_>
--------------------
JsConfig() : unit
type 'T option = Option<'T>
Full name: Microsoft.FSharp.Core.option<_>
Multiple items
type Func<'TResult> =
delegate of unit -> 'TResult
Full name: System.Func<_>
--------------------
type Func<'T,'TResult> =
delegate of 'T -> 'TResult
Full name: System.Func<_,_>
--------------------
type Func<'T1,'T2,'TResult> =
delegate of 'T1 * 'T2 -> 'TResult
Full name: System.Func<_,_,_>
--------------------
type Func<'T1,'T2,'T3,'TResult> =
delegate of 'T1 * 'T2 * 'T3 -> 'TResult
Full name: System.Func<_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 -> 'TResult
Full name: System.Func<_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 -> 'TResult
Full name: System.Func<_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'T14,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 * 'T14 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'T14,'T15,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 * 'T14 * 'T15 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'T14,'T15,'T16,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 * 'T14 * 'T15 * 'T16 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_>
val registerPrimitiveOptions : (unit -> unit)
Full name: RockSpot.Runtime.ServiceStack.registerPrimitiveOptions
Multiple items
val string : value:'T -> string
Full name: Microsoft.FSharp.Core.Operators.string
--------------------
type string = String
Full name: Microsoft.FSharp.Core.string
type bool = Boolean
Full name: Microsoft.FSharp.Core.bool
Multiple items
val char : value:'T -> char (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.char
--------------------
type char = Char
Full name: Microsoft.FSharp.Core.char
Multiple items
val byte : value:'T -> byte (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.byte
--------------------
type byte = Byte
Full name: Microsoft.FSharp.Core.byte
Multiple items
val sbyte : value:'T -> sbyte (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.sbyte
--------------------
type sbyte = SByte
Full name: Microsoft.FSharp.Core.sbyte
--------------------
type sbyte<'Measure> = sbyte
Full name: Microsoft.FSharp.Core.sbyte<_>
Multiple items
val int16 : value:'T -> int16 (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.int16
--------------------
type int16 = Int16
Full name: Microsoft.FSharp.Core.int16
--------------------
type int16<'Measure> = int16
Full name: Microsoft.FSharp.Core.int16<_>
Multiple items
val uint16 : value:'T -> uint16 (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.uint16
--------------------
type uint16 = UInt16
Full name: Microsoft.FSharp.Core.uint16
Multiple items
val int : value:'T -> int (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.int
--------------------
type int = int32
Full name: Microsoft.FSharp.Core.int
--------------------
type int<'Measure> = int
Full name: Microsoft.FSharp.Core.int<_>
Multiple items
val uint32 : value:'T -> uint32 (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.uint32
--------------------
type uint32 = UInt32
Full name: Microsoft.FSharp.Core.uint32
Multiple items
val int64 : value:'T -> int64 (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.int64
--------------------
type int64 = Int64
Full name: Microsoft.FSharp.Core.int64
--------------------
type int64<'Measure> = int64
Full name: Microsoft.FSharp.Core.int64<_>
Multiple items
val uint64 : value:'T -> uint64 (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.uint64
--------------------
type uint64 = UInt64
Full name: Microsoft.FSharp.Core.uint64
Multiple items
val nativeint : value:'T -> nativeint (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.nativeint
--------------------
type nativeint = IntPtr
Full name: Microsoft.FSharp.Core.nativeint
Multiple items
val unativeint : value:'T -> unativeint (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.unativeint
--------------------
type unativeint = UIntPtr
Full name: Microsoft.FSharp.Core.unativeint
Multiple items
val single : value:'T -> single (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.single
--------------------
type single = Single
Full name: Microsoft.FSharp.Core.single
Multiple items
val double : value:'T -> float (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.double
--------------------
type double = Double
Full name: Microsoft.FSharp.Core.double
Multiple items
val decimal : value:'T -> decimal (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.decimal
--------------------
type decimal = Decimal
Full name: Microsoft.FSharp.Core.decimal
--------------------
type decimal<'Measure> = decimal
Full name: Microsoft.FSharp.Core.decimal<_>
type DayOfWeek =
| Sunday = 0
| Monday = 1
| Tuesday = 2
| Wednesday = 3
| Thursday = 4
| Friday = 5
| Saturday = 6
Full name: System.DayOfWeek
Multiple items
type Guid =
struct
new : b:byte[] -> Guid + 4 overloads
member CompareTo : value:obj -> int + 1 overload
member Equals : o:obj -> bool + 1 overload
member GetHashCode : unit -> int
member ToByteArray : unit -> byte[]
member ToString : unit -> string + 2 overloads
static val Empty : Guid
static member NewGuid : unit -> Guid
static member Parse : input:string -> Guid
static member ParseExact : input:string * format:string -> Guid
...
end
Full name: System.Guid
--------------------
Guid()
Guid(b: byte []) : unit
Guid(g: string) : unit
Guid(a: int, b: int16, c: int16, d: byte []) : unit
Guid(a: uint32, b: uint16, c: uint16, d: byte, e: byte, f: byte, g: byte, h: byte, i: byte, j: byte, k: byte) : unit
Guid(a: int, b: int16, c: int16, d: byte, e: byte, f: byte, g: byte, h: byte, i: byte, j: byte, k: byte) : unit
Multiple items
type TimeSpan =
struct
new : ticks:int64 -> TimeSpan + 3 overloads
member Add : ts:TimeSpan -> TimeSpan
member CompareTo : value:obj -> int + 1 overload
member Days : int
member Duration : unit -> TimeSpan
member Equals : value:obj -> bool + 1 overload
member GetHashCode : unit -> int
member Hours : int
member Milliseconds : int
member Minutes : int
...
end
Full name: System.TimeSpan
--------------------
TimeSpan()
TimeSpan(ticks: int64) : unit
TimeSpan(hours: int, minutes: int, seconds: int) : unit
TimeSpan(days: int, hours: int, minutes: int, seconds: int) : unit
TimeSpan(days: int, hours: int, minutes: int, seconds: int, milliseconds: int) : unit
Multiple items
type DateTime =
struct
new : ticks:int64 -> DateTime + 10 overloads
member Add : value:TimeSpan -> DateTime
member AddDays : value:float -> DateTime
member AddHours : value:float -> DateTime
member AddMilliseconds : value:float -> DateTime
member AddMinutes : value:float -> DateTime
member AddMonths : months:int -> DateTime
member AddSeconds : value:float -> DateTime
member AddTicks : value:int64 -> DateTime
member AddYears : value:int -> DateTime
...
end
Full name: System.DateTime
--------------------
DateTime()
(+0 other overloads)
DateTime(ticks: int64) : unit
(+0 other overloads)
DateTime(ticks: int64, kind: DateTimeKind) : unit
(+0 other overloads)
DateTime(year: int, month: int, day: int) : unit
(+0 other overloads)
DateTime(year: int, month: int, day: int, calendar: Globalization.Calendar) : unit
(+0 other overloads)
DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int) : unit
(+0 other overloads)
DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, kind: DateTimeKind) : unit
(+0 other overloads)
DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, calendar: Globalization.Calendar) : unit
(+0 other overloads)
DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, millisecond: int) : unit
(+0 other overloads)
DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, millisecond: int, kind: DateTimeKind) : unit
(+0 other overloads)
Multiple items
type DateTimeOffset =
struct
new : dateTime:DateTime -> DateTimeOffset + 5 overloads
member Add : timeSpan:TimeSpan -> DateTimeOffset
member AddDays : days:float -> DateTimeOffset
member AddHours : hours:float -> DateTimeOffset
member AddMilliseconds : milliseconds:float -> DateTimeOffset
member AddMinutes : minutes:float -> DateTimeOffset
member AddMonths : months:int -> DateTimeOffset
member AddSeconds : seconds:float -> DateTimeOffset
member AddTicks : ticks:int64 -> DateTimeOffset
member AddYears : years:int -> DateTimeOffset
...
end
Full name: System.DateTimeOffset
--------------------
DateTimeOffset()
DateTimeOffset(dateTime: DateTime) : unit
DateTimeOffset(ticks: int64, offset: TimeSpan) : unit
DateTimeOffset(dateTime: DateTime, offset: TimeSpan) : unit
DateTimeOffset(year: int, month: int, day: int, hour: int, minute: int, second: int, offset: TimeSpan) : unit
DateTimeOffset(year: int, month: int, day: int, hour: int, minute: int, second: int, millisecond: int, offset: TimeSpan) : unit
DateTimeOffset(year: int, month: int, day: int, hour: int, minute: int, second: int, millisecond: int, calendar: Globalization.Calendar, offset: TimeSpan) : unit
More information