forked from TOTBWF/FSharp.Data.GraphQL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtensions.fs
More file actions
31 lines (27 loc) · 1.3 KB
/
Copy pathExtensions.fs
File metadata and controls
31 lines (27 loc) · 1.3 KB
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
/// The MIT License (MIT)
/// Copyright (c) 2016 Bazinga Technologies Inc
module internal FSharp.Data.GraphQL.Extensions
open System.Reflection
type TypeInfo with
/// If no property is found with the specified name, it will try changing the case of the first letter
member x.GetDeclaredProperty(propertyName: string, ignoreCase: bool) =
match x.GetDeclaredProperty(propertyName), ignoreCase with
| null, true ->
let first =
let first = propertyName.Substring(0,1)
match first.ToUpper() with
| upper when upper <> first -> upper
| _ -> first.ToLower()
x.GetDeclaredProperty(first + propertyName.Substring(1))
| prop, _ -> prop
/// If no method is found with the specified name, it will try changing the case of the first letter
member x.GetDeclaredMethod(propertyName: string, ignoreCase: bool) =
match x.GetDeclaredMethod(propertyName), ignoreCase with
| null, true ->
let first =
let first = propertyName.Substring(0,1)
match first.ToUpper() with
| upper when upper <> first -> upper
| _ -> first.ToLower()
x.GetDeclaredMethod(first + propertyName.Substring(1))
| prop, _ -> prop