Root BO Constructor

Root BO Constructor

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


JoeFallon1 posted on Wednesday, November 18, 2009

My Root BOs have always had constructors like this:

    Protected Sub New()
      'require use of factory methods      
    End Sub

I am setting up a transition to managed properties and may want to use Silverlight in the future.

Should my constructor be changed from Protected to Public?

Joe

DancesWithBamboo replied on Wednesday, November 18, 2009

I only make the Silverlight constuctor public so that it can only be mis-used in one type of UI.  Format is usually something like this with the constructors and factory methods grouped:

#if SILVERLIGHT
            public OfficeManagerClass()
            {
            }
            public static void       BeginGetOfficeManager(EventHandler<DataPortalResult<OfficeManagerClass>> handler)
            {
                var dp = new DataPortal<OfficeManagerClass>();
                dp.FetchCompleted += handler;
                dp.BeginFetch();
            }
        #else
        private OfficeManagerClass()
            {
            }

            public static OfficeManagerClass GetOfficeManager()
            {
                return DataPortal.Fetch<OfficeManagerClass>();
            }
        #endif

JoeFallon1 replied on Wednesday, November 18, 2009

Thanks!

That helps a lot.

Where is this defined:    #if SILVERLIGHT

Joe

 

DancesWithBamboo replied on Wednesday, November 18, 2009

Its a conditional compiler symbol like "DEBUG".  It gets defines on a Silverlight project automatically.  To use Silverlight you need to compile your Business Objects in 2 different projects; one for the server and one for the client.  Here is Rocky's blog describing the steps: http://www.lhotka.net/weblog/SettingUpABasicNtierCSLANETForSilverlightProject.aspx

Copyright (c) Marimer LLC