BadScript 2
Loading...
Searching...
No Matches
FSharpOptionHelper.cs
Go to the documentation of this file.
1
// Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information.
2
3
using
System;
4
using
CommandLine.Core
;
5
using
Microsoft.FSharp.Core;
6
7
namespace
CommandLine.Infrastructure
8
{
9
static
class
FSharpOptionHelper
10
{
11
public
static
Type
GetUnderlyingType
(Type type)
12
{
13
return
type
14
.GetGenericArguments()[0];
15
}
16
17
public
static
object
Some
(Type type,
object
value)
18
{
19
return
typeof(FSharpOption<>)
20
.MakeGenericType(type)
21
.StaticMethod(
22
"Some"
, value);
23
}
24
25
public
static
object
None
(Type type)
26
{
27
return
typeof(FSharpOption<>)
28
.MakeGenericType(type)
29
.StaticProperty(
30
"None"
);
31
}
32
33
public
static
object
ValueOf
(
object
value)
34
{
35
return
typeof(FSharpOption<>)
36
.MakeGenericType(
GetUnderlyingType
(value.GetType()))
37
.InstanceProperty(
38
"Value"
, value);
39
}
40
41
public
static
bool
IsSome
(
object
value)
42
{
43
return
(
bool
)typeof(FSharpOption<>)
44
.MakeGenericType(
GetUnderlyingType
(value.GetType()))
45
.StaticMethod(
46
"get_IsSome"
, value);
47
}
48
}
49
}
CommandLine.Infrastructure.FSharpOptionHelper
Definition
FSharpOptionHelper.cs:10
CommandLine.Infrastructure.FSharpOptionHelper.None
static object None(Type type)
Definition
FSharpOptionHelper.cs:25
CommandLine.Infrastructure.FSharpOptionHelper.GetUnderlyingType
static Type GetUnderlyingType(Type type)
Definition
FSharpOptionHelper.cs:11
CommandLine.Infrastructure.FSharpOptionHelper.IsSome
static bool IsSome(object value)
Definition
FSharpOptionHelper.cs:41
CommandLine.Infrastructure.FSharpOptionHelper.Some
static object Some(Type type, object value)
Definition
FSharpOptionHelper.cs:17
CommandLine.Infrastructure.FSharpOptionHelper.ValueOf
static object ValueOf(object value)
Definition
FSharpOptionHelper.cs:33
CommandLine.Core
Definition
ArgumentsExtensions.cs:10
CommandLine.Infrastructure
Definition
EnumerableExtensions.cs:8
deps
commandlineparser
src
CommandLine
Infrastructure
FSharpOptionHelper.cs
Generated by
1.9.8