Home
Insert
Update snippet 'Quotation property name + comp + value extract'
Title
Description
for zec_ on irc
Source code
open Microsoft.FSharp.Quotations module P = Quotations.Patterns type Comparison = Equals of string * obj | NotEquals of string * obj let getNameValuePair (expr:Expr<('a -> bool)>) = match expr with | P.Lambda(_, P.Call(None, mi, [Patterns.PropertyGet(_, pi, _); P.Value(value, _) ])) -> match mi.Name with | "op_Equality" ->Some(Equals(pi.Name, value)) | "op_Inequality" -> Some(NotEquals(pi.Name, value)) | _ -> None | _ -> None let test = <@ fun (s:string) -> s.Length <> 2 @> let r = getNameValuePair test
Tags
qoutations
qoutations
Author
Link
Reference NuGet packages
If your snippet has external dependencies, enter the names of NuGet packages to reference, separated by a comma (
#r
directives are not required).
Update