What error do you get when trying to use static let? It seems like it should be the correct solution.

By on 12/3/2012 6:18 AM ()

The following is how I think it should be and it results in a TypeInitializationException. It doesn't even seem to be able to find the RegisterProperty method during run time:

1
2
3
4
5
6
7
8
type CslaTestObj() =
    inherit BusinessBase<CslaTestObj>()

    static let IdProperty = CslaTestObj.RegisterProperty<int>(new PropertyInfo<int>("Id"));

    member m.Id 
        with get() : int = m.ReadProperty(IdProperty) |> unbox
        and set(v) = m.SetProperty(IdProperty, v)
By on 12/3/2012 9:38 AM ()

I don't see anything wrong with this code. Can you run this through the debugger and retrieve the InnerException? I suspect a CSLA-specific problem, which I don't know the first thing about unfortunately.

By on 12/4/2012 9:26 AM ()

Loic,
Thanks much for your assistance. I loaded up CSLA source (C#) and took a look. Here's the RegisterProperty method.

1
2
3
4
protected static PropertyInfo<P> RegisterProperty<P>(PropertyInfo<P> info)
{
    return Core.FieldManager.PropertyInfoManager.RegisterProperty<P>(typeof(T), info);
}

I changed protected to public and the static let in my call worked correctly. How can F# call C# protected functions and not have them be treated as private? I'm sure I'm hardly the first person to run into this. I really would rather not rewrite Rocky Lhotka's C# code. He's alot smarter than me :)

Ed

By on 12/4/2012 10:27 PM ()

Try to create a private static member in the inheriting class, which simply imitates the protected member and then use the new member from your static let (members can access protected, let's cannot).

By on 12/5/2012 2:06 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