How to partial class References.cs

How to partial class References.cs

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


DeHaynes posted on Tuesday, September 19, 2006

I have subclassed the CSLA framework.  I am in the process of adding the functionality I need by create partial classes that add to the framework functionality.  I am finished with it upto the point where I have to work with public partial class WebServicePortal.

I found this class in a file called references.cs under "Csla\Web References\WebServiceHost".  I need to add four things to this web service.  Specifically

DeactivateCompletedEventArgs
DactivateCompletedEventHander

ReactivateCompletedEventArgs
RactivateCompletedEventHander

The problem is I do not see this file represented anywhere in Visual Studio.  I am not familiar with Web Services and I am trying to learn so I know how to add this functionality, but if anyone can clue me in, I would appreciate it.

 

DansDreams replied on Friday, September 22, 2006

Are you using web services for your inter-tier communication within CSLA?  Rocky's position is that's there really just to demonstrate that any communication channel was possible and he didn't expect it to be widely useful.

Besides that question, I'm not expertly familiar with this either, but what you're trying to do looks a little bizarre.  Are you trying to somehow implement event functionality to a web service DataPortal channel above what's already in in the web service itself?

BTW, by subclassing CSLA rather than modifying it I never meant using partial classes but rather inheritance.  The goal was to leave CSLA exactly as is as much as possible.  It's probably not a tremendously difficult thing, but you have to go back through and set up all the CSLA classes as partial when you want to use a new CSLA version, right?

DeHaynes replied on Friday, September 22, 2006

   Well, I am implementing is exactly like the Fetch, Delete, Update etc routines that already exist.  I am only trying to add two more methods.  They are called

Deactivate
Reactivate

 (The naming was because made done because an object will assume to be active whenever it is created, so it must first be deactivated.)

   Anyway I needed to add these two methods and when I did, I just followed the compiling error messages throughout the framework and created the code I needed to accomplish this. I was able to hack the framework to do this in my original foray into the framework. 

   Taking your advice, I am tried to subclass the functionality, but it is impossible because it requires additional code throughout the framework in order to support the additional two methods.  .  So my next solution was to create partial classes where the additional code was needed.  That way when a new version of the framework came out, I would just need to go into the original code and change the classes to partial and then copy my custom partial classes.  This all works fine, until Web Services.

   By the way, I originally thought about just using the Update functionality to implement the Reactivate, Deactivate capability but it occured to me that a Reactivate or Deactivate stored procedure would be different than an Update stored procedure.  The Update SP just updates a single object.  A Reactivate/Deactivate SP would behave more like a Delete SP, where they go through the related tables and Reactivate/Deactivate the associated records.  Now that I think of it, I guess I could make a special field in each SP that would call a seperate stored procedure depending on the value contained in it.

   Maybe I will give that a try instead.

DeHaynes replied on Friday, September 22, 2006

Oh hey.  Thanks a ton.  I was really at a dead end with this.

DansDreams replied on Friday, September 22, 2006

I'm still confused, and probably will remain so unless I retrace all your steps and see what you're seeing.

The references.cs file is something built automatically by Visual Studio when you reference a web service.  But apparently not trying to change the functionality of the web service itself, right?  (If you are then I think you've taken a wrong turn somewhere.)

So I'm still really puzzed at how you ended up in references.cs.

DeHaynes replied on Friday, September 22, 2006

DansDreams:

I'm still confused, and probably will remain so unless I retrace all your steps and see what you're seeing.

The references.cs file is something built automatically by Visual Studio when you reference a web service.  But apparently not trying to change the functionality of the web service itself, right?  (If you are then I think you've taken a wrong turn somewhere.)

So I'm still really puzzed at how you ended up in references.cs.

Let me use the original base code as an example. 

   When you call the Save() function in your object, it starts code that goes THROUGH the framework which allows the object to be moved to the application server and ultimately calls your DataPortal_Update() at the application server.  There are also capabilities for code to be run when the update completes.  In order to accomplish this, there are DataPortal_Update type references throughout the framework.  For instance, the web services has UpdateCompletedEventArgs and UpdateCompletedEventHandler;  the RemotingPortal class has the public DataPortalResult Update(object obj, DataPortalContext context).   So there are references to the following functions that are prevasive throughout the framework:

DataPortal_Fetch
DataPortal_Insert
DataPortal_Update
DataPortal_Delete

What I am trying to do is add

DataPortal_Deactivate
DataPortal_Reactivate

to the capability list such that I can assign seperate stored procedures to these.  And call them seperate from any of the above four processes.  I cannot do this via subclassing because the framework needs to be aware that those two additional functions exist, so when I tell it to execute them it knows how to find them.

.  I created partial classes everywhere I had to add additional code and it was around 15 - 20 additional files.  Still, I was ok with that because my code was seperate from the frame work.  But then I ran into the Web Reference part of the Web Services.  I don't know much about Web Services and I manually found "references.cs"  but I couldn't find it in Visual studio. 

   As it is, I think that I have thought of a way to work around the issue.  If I make special parameters in my Update Stored Procedure, I can tell it that I am Reactivating or Deactivating an object and thus run a different stored procedure than the normal Update Stored Procedure.

   BTW, I ended up in "references.cs" because when I started adding functionality to the framework, I would get errors because a supporting object would not support my Reactivate/Deactivate functionality.  So I would then move to that object, see what it did and write the code to enable the functionality at that level.  I would try a rebuild and it would complain because a supporting object didn't support the functionality.  Rinse-and-repeat.  I followed this process until I got to Web Services.  Then I was not able to resolve the error.  I couldn't find the WebServicePortal in Visual Studio so I dropped out of Visual Studio and started looking for it.  I found it in "references.cs".

DansDreams replied on Monday, September 25, 2006

I think the statement or observation of those four methods being pervasive throughout the framework might be a little misleading.

The DataPortal is simply a design whereby client code calls a DataPortal method on the "server" (which may of course actually be on the same machine) which in turn calls a perdertermined method back on the passed client BO via reflection.  At that point it really has nothing particularly to do with web services unless you're specifically trying to use the web services channel.

Which is to say that you would not have to modify every single class in which you find some code dealing with the DataPortal_XYZ methods.  Only the ones you need to.

So again I ask, are you trying to use the web services channel for this kind of intranet inter-tier communication?  If so, was this mandated or a decision of yours?

BTW, you probably don't have the "show all files" option on in Visual Studio.  It's a button in Solution Explorer and will show you all the files behind the scenes when switched on.

DeHaynes replied on Monday, September 25, 2006

   So far all my decisions have been mine.  Until this morning I haven't had input from anyone else in my company.  This morning, in a meeting, we decided to use LocalProxy.  So I don't need any of the other channels.  
   On the otherhand, I do not want to have to recompile and redistribute the DLLs when/if a change comes allong that makes me centralize the application server.  Also, even if you use Local Proxy but you add the Reactivate/Deactivate functionality, how can you get the framework to compile. 

   In order to get the functionality, you would have to modify the IDataPortalServer interface.  To add the functions

Reactivate(Type objectType, object criteria, DataPortalContext context
Deactivate(Type objectType, object criteria, DataPortalContext context)

   Once you did that, you would invalidate the pre-existing, unmodified channels because they don't implement those functions.  So then you would have to "Exclude from Project" on them from the context menu in order to get it to compile.  Then you loose the capability to use the different channels without re-compiling later.

 

  I am happy to continue to discuss this because I would love to learn a bit more about this stuff, but I don't want to annoy you in any way.  I appreciate your help and insight.  Asi it is, I have thought up a work-around solution, thanks to your prodding from earlier in this post.  I am going to impliment the work around this week.

 

P.S.  In my VS2005, the "Show All Files" icon at the top of the Solution Explorer is inaccessible.  It looks greyed-out, but it is hard to tell.  At anyrate, I cannot select like the other two icons.

   

   

Copyright (c) Marimer LLC