Silverlight - DataPortal.CreateChild<>() fails

Silverlight - DataPortal.CreateChild<>() fails

Old forum URL: forums.lhotka.net/forums/t/6474.aspx


Peran posted on Friday, February 20, 2009

Hi

I have an EditableRootCollection with EditableChild objects; the following factory method (pg 181) works in csla but fails in cslalight.

internal static EditableChild NewEditableChild()
{
    return DataPortal.CreateChild<EditableChild>();
}

Should cslalight.Core.BusinessBase.Child_Create be made public so that silverlight reflection can find it?

I know there are workarounds; a public override of Child_Create, or instantiate a new object rather than have the ChildPortal do this for me, but it would be good to take advantage of the automatic calls to MarkAsChild() and ValidationRules.CheckRules().


Peran

RockfordLhotka replied on Saturday, February 21, 2009

In SL the methods need to be public, because SL reflection (and dynamic method calls) won't work against non-public members.

You can use the System.ComponentModel.EditorBrowsable attribute to hide the member from intellisense, but it needs to be public.

Peran replied on Saturday, February 21, 2009

Hi Rocky

I can add this to my EditableChild

#if SILVERLIGHT
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new void Child_Create()
        {
            base.Child_Create();
        }
#endif

Would you consider making the base method Public in the CSLALight framework, making the override unnecessary, or is it preferable to leave as is?

Thanks

Peran

Copyright (c) Marimer LLC