├── .gitignore
└── Src
├── After
├── FunctionalCSharp.sln
└── FunctionalCSharp
│ ├── App.config
│ ├── Disposable.cs
│ ├── FunctionalCSharp.csproj
│ ├── FunctionalExtensions.cs
│ ├── HtmlBuilder.cs
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── Result.cs
│ ├── StreamFactory.cs
│ ├── StringBuilderExtensions.cs
│ └── Validator.cs
└── Before
├── FunctionalCSharp.sln
└── FunctionalCSharp
├── App.config
├── FunctionalCSharp.csproj
├── Program.cs
├── Properties
└── AssemblyInfo.cs
└── StreamFactory.cs
/.gitignore:
--------------------------------------------------------------------------------
1 | #################
2 | ## Visual Studio
3 | #################
4 |
5 | ## Ignore Visual Studio temporary files, build results, and
6 | ## files generated by popular Visual Studio add-ons.
7 |
8 | # User-specific files
9 | *.suo
10 | *.user
11 | *.sln.docstates
12 |
13 | # Build results
14 |
15 | [Dd]ebug/
16 | [Rr]elease/
17 | x64/
18 | build/
19 | [Bb]in/
20 | [Oo]bj/
21 |
22 | # MSTest test Results
23 | [Tt]est[Rr]esult*/
24 | [Bb]uild[Ll]og.*
25 |
26 | *_i.c
27 | *_p.c
28 | *.ilk
29 | *.meta
30 | *.obj
31 | *.pch
32 | *.pdb
33 | *.pgc
34 | *.pgd
35 | *.rsp
36 | *.sbr
37 | *.tlb
38 | *.tli
39 | *.tlh
40 | *.tmp
41 | *.tmp_proj
42 | *.log
43 | *.vspscc
44 | *.vssscc
45 | .builds
46 | *.pidb
47 | *.log
48 | *.scc
49 |
50 | # Visual C++ cache files
51 | ipch/
52 | *.aps
53 | *.ncb
54 | *.opensdf
55 | *.sdf
56 | *.cachefile
57 |
58 | # Visual Studio profiler
59 | *.psess
60 | *.vsp
61 | *.vspx
62 |
63 | # Guidance Automation Toolkit
64 | *.gpState
65 |
66 | # ReSharper is a .NET coding add-in
67 | _ReSharper*/
68 | *.[Rr]e[Ss]harper
69 |
70 | # TeamCity is a build add-in
71 | _TeamCity*
72 |
73 | # DotCover is a Code Coverage Tool
74 | *.dotCover
75 |
76 | # NCrunch
77 | *.ncrunch*
78 | .*crunch*.local.xml
79 |
80 | # Installshield output folder
81 | [Ee]xpress/
82 |
83 | # DocProject is a documentation generator add-in
84 | DocProject/buildhelp/
85 | DocProject/Help/*.HxT
86 | DocProject/Help/*.HxC
87 | DocProject/Help/*.hhc
88 | DocProject/Help/*.hhk
89 | DocProject/Help/*.hhp
90 | DocProject/Help/Html2
91 | DocProject/Help/html
92 |
93 | # Click-Once directory
94 | publish/
95 |
96 | # Publish Web Output
97 | *.Publish.xml
98 | *.pubxml
99 |
100 | # NuGet Packages Directory
101 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
102 | #packages/
103 |
104 | # Windows Azure Build Output
105 | csx
106 | *.build.csdef
107 |
108 | # Windows Store app package directory
109 | AppPackages/
110 |
111 | # Others
112 | sql/
113 | *.Cache
114 | ClientBin/
115 | [Ss]tyle[Cc]op.*
116 | ~$*
117 | *~
118 | *.dbmdl
119 | *.[Pp]ublish.xml
120 | *.pfx
121 | *.publishsettings
122 |
123 | # RIA/Silverlight projects
124 | Generated_Code/
125 |
126 | # Backup & report files from converting an old project file to a newer
127 | # Visual Studio version. Backup files are not needed, because we have git ;-)
128 | _UpgradeReport_Files/
129 | Backup*/
130 | UpgradeLog*.XML
131 | UpgradeLog*.htm
132 |
133 | # SQL Server files
134 | App_Data/*.mdf
135 | App_Data/*.ldf
--------------------------------------------------------------------------------
/Src/After/FunctionalCSharp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.31101.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FunctionalCSharp", "FunctionalCSharp\FunctionalCSharp.csproj", "{DC0FE2A9-3967-4247-B8C3-D597C497F928}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {DC0FE2A9-3967-4247-B8C3-D597C497F928}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {DC0FE2A9-3967-4247-B8C3-D597C497F928}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {DC0FE2A9-3967-4247-B8C3-D597C497F928}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {DC0FE2A9-3967-4247-B8C3-D597C497F928}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/Src/After/FunctionalCSharp/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Src/After/FunctionalCSharp/Disposable.cs:
--------------------------------------------------------------------------------
1 | namespace System
2 | {
3 | public static class Disposable
4 | {
5 | public static TResult Using
6 | (
7 | Func factory,
8 | Func fn)
9 | where TDisposable : IDisposable
10 | {
11 | using (var disposable = factory())
12 | {
13 | return fn(disposable);
14 | }
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Src/After/FunctionalCSharp/FunctionalCSharp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {DC0FE2A9-3967-4247-B8C3-D597C497F928}
8 | Exe
9 | Properties
10 | FunctionalCSharp
11 | FunctionalCSharp
12 | v4.6
13 | 512
14 |
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
66 |
--------------------------------------------------------------------------------
/Src/After/FunctionalCSharp/FunctionalExtensions.cs:
--------------------------------------------------------------------------------
1 | namespace System
2 | {
3 | public static class FunctionalExtensions
4 | {
5 | public static T Tee(this T @this, Action action)
6 | {
7 | action(@this);
8 | return @this;
9 | }
10 |
11 | public static TResult Map(
12 | this TSource @this,
13 | Func fn) =>
14 | fn(@this);
15 |
16 | public static T When(
17 | this T @this,
18 | Func predicate,
19 | Func fn) =>
20 | predicate()
21 | ? fn(@this)
22 | : @this;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Src/After/FunctionalCSharp/HtmlBuilder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace FunctionalCSharp
6 | {
7 | public static class HtmlBuilder
8 | {
9 | public static Func, string> BuildSelectBox(string id, bool includeUnknown) =>
10 | options =>
11 | new StringBuilder()
12 | .AppendFormattedLine("