Disconnected Agent Guidance Package

Topics: Mobile Client Software Factory
Jul 18, 2006 at 12:02 AM
originally posted by: larsandreas

We've tried the Guidance Package for the Disconnected Service Agent Block and wonder in what way it deals with updating web services. Assume, for instance, that the web service provider adds some methods; updating the web service in visual studio gives you access to the new functionality, but what about the generated code for the agent? Surely, it can't just be re-generated because you may have added your own method bodies.

Thanks.
Jul 18, 2006 at 12:21 AM
originally posted by: dcazzulino

The generated DSA uses the generation gap pattern to preserve your changes. (see http://www.google.com/search?q=generation+gap+design+pattern).
The idea is basically that the generated class is actually the base class from which your modified class inherits. The base class provides virtual/abstract methods that you are supposed to override. This way, re-generating the base class, does not cause the derived class to lose anything.

However, a newly generated base class may cause the derived class to no longer compile, such as is the case if a method is removed from the web service.
Jul 18, 2006 at 3:47 AM
originally posted by: larsandreas

I understand. Thanks :)

Is the guidance package generated code re-generated whenever the web service is updated, or do I have to step through the wizard again? (The guidance package doesn't work at my machine, so I can't just try it out)
Jul 18, 2006 at 8:48 PM
originally posted by: larsandreas

Hi again.

I have now been able to try out the guidance package and I still don't understand how to regenerate the files after updating a web reference. I've looked around for something like "update disconnected service agent", and i've tried using the guidance package again. The former does not exist, the latter does not produce any code at all (the second time).

Another thing that would be useful, is having information available as protected properties in the MyWebServiceAgent.cs file, instead of hard-coded in the CreateRequest method. This way we can use the class as a base class to add functionality to the agent.

Any comments?

Thanks :)
Jul 19, 2006 at 11:22 AM
originally posted by: dcazzulino

Thanks for your comments Lars.
The scenario was for simply re-running the Create DSA recipe and get the code updated/rewritten (only the base class).
However, there's a bug in the guidance package, in the GuidancePackage\MobileClientFactory\Actions\AddItemFromStringAction.cs file.
From your installation location, open that file, scroll to the OverwriteFile method, and modify it as follows:

private void OverwriteFile(DTE vs, string fullPath, string content)
{
VsHelper.EnsureWriteable(vs, fullPath);
File.WriteAllText(fullPath, content);
}

I missed the File.WriteAllText line :S....