Well, it is impossible to create generic properties -- this is a .NET restriction.

However, after a quick look at the Kendo documentation, it seems the best way to bind this would be to make the DataSourceConfiguration itself generic on the data type. Something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
let DataSourceConfiguration =
    Generic / fun t ->
        Pattern.Config "kendo.data.DataSourceConfiguration" {
            Required = []
            Optional =
                [
                    "data", Type.ArrayOf t
                ]
        }

// And then:
let DataSource =
    Class "kendo.data.DataSource"
    |+> [
        Generic - fun t -> Constructor (DataSourceConfiguration t)
    ]

Maybe even making DataSource generic w.r.t. the data type would make sense, I'm not sure.

For the namespacing question: if these types are accepted or returned by useful classes / methods / properties, they're not really dummy types, are they? :) You can probably shove them into a sub-namespace if you're afraid of cluttering, but if they're used, then they have to be accessible somewhere. Or maybe nest each configuration into its corresponding class:

1
2
3
let DataSource =
    Class "kendo.data.DataSource"
    |=> Nested [DataSourceConfiguration]
By on 4/29/2013 8:50 AM ()

Understood, I was leaning towards that and had failed to notice that the DataSourceConfiguration was indeed generic in your existing wrapper.

Merci Loic.

David

By on 4/29/2013 9:06 AM ()

Not so sure how to hoist the nested type now that it's got the generic argument though.

-- Correction

It doesn't seem to be the nested type that is at problem rather the Constructor for DataSource.

Ended up bringing the generic parameter up to the DataSource as well.

By on 4/29/2013 10:08 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper