Ticket #803 (closed enhancement: fixed)

Opened 4 years ago

Last modified 4 years ago

Maestro API: Default settings for resource classes

Reported by: jng Owned by: ksgeograf
Priority: low Milestone:
Component: Maestro Version:
Severity: trivial Keywords:
Cc: External ID:

Description

It would be nice if resource types are initialized with default settings.

Since these classes are generated off the xsd schemas (correct?), there is a lot of boilerplate code required to explicitly set all the required elements for a given resource.

For example:

Layer Definition:

  • Create a default line/point/polygon style

Web Layout:

  • Create a default command list.
  • Create a default toolbar/context menu/task pane bar configuration.

Change History

Changed 4 years ago by ksgeograf

  • status changed from new to assigned
  • version 2.0.1 deleted

The easiest way to accomplish this is to use the "DeserializeObject?" method, and give it a file stream as input. There are some templates in the "Templates" folder.

A simple solution would be to embed these in the MaestroAPI.dll, and create methods to generate objects from them. Does that seem like a resonable solution?

Changed 4 years ago by jng

Yes. The idea is that I should be able to do something like:

WebLayout? wb = new WebLayout?();

and I would have a usable web layout resource straight away.

anything that can let me do that is a reasonable solution.

Changed 4 years ago by jng

Or some kind of ResourceFactory? class that has

CreateLineLayer?() CreateAreaLayer?() CreatePointLayer?() ... CreateXXX()

would also work

Changed 4 years ago by ksgeograf

In r3535, I have added a method called CreateResourceObject? to the connection interface. You can now do:

MaestroAPI.HttpServerConnection con = new OSGeo.MapGuide.MaestroAPI.HttpServerConnection(new Uri("http://localhost/mapguide"), "Administrator", "admin", "da", true);
MaestroAPI.LayerDefinition ldef = con.CreateResourceObject<MaestroAPI.LayerDefinition>();

And get a layer with many default properties set. Is this close enough to meet your requirements, or do you have a special use case in mind?

Changed 4 years ago by jng

Yes. This is what I am after! Thanks.

Changed 4 years ago by ksgeograf

  • status changed from assigned to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.