Created
September 18, 2011 09:44
-
-
Save hodzanassredin/1224920 to your computer and use it in GitHub Desktop.
TypeProvider demo from @dsyme presentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Learn more about F# at http://fsharp.net | |
namespace ExampleTypeProvider.DesignTime | |
open System | |
open System.Collections.Generic | |
open System.Linq.Expressions | |
open System.Globalization | |
open System.Reflection | |
open System.Diagnostics | |
open Microsoft.FSharp.Core.CompilerServices | |
[<TypeProvider>] | |
type FolderTypeProvider(config:TypeProviderConfig) as this = | |
inherit TypeProviderForNamespaces() | |
let oneType = ProvidedTypeDefenition("Samples.TypeSpace", "OneType") | |
let prop = ProvidedProperty("Name", typeof<string>, | |
IsStatic = true, | |
GetterCode = (fun args-> <@@ "hello" @@>)) | |
do oneType.AddMember prop | |
do this.AddNamespace("Samples.TypeSpace", [oneType]) | |
[<assembly: TypeProviderAssembly>] | |
do() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment