Advertisement
Guest User

Untitled

a guest
Dec 19th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.92 KB | None | 0 0
  1. type StringFloatOptionConverter() =
  2.     interface IValueConverter with
  3.         member this.Convert(value:obj, _targetType: Type, _parameter: obj, _culture: System.Globalization.CultureInfo) =
  4.             let s = match value with
  5.                         | :? Core.Option<float> as opt ->
  6.                             match opt with
  7.                                 | Some f -> sprintf "%.1f" f
  8.                                 | None -> ""
  9.                         | _ -> ""
  10.             s :> obj
  11.         member this.ConvertBack(value:obj, _targetType: Type, _parameter: obj, _culture: System.Globalization.CultureInfo) =
  12.             let o = match value with
  13.                         | :? string as str ->
  14.                             match Double.TryParse(str) with
  15.                                 | (true, parsed) -> Some parsed
  16.                                 | _ -> None
  17.                         | _ -> None
  18.             o :> obj
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement