Opened 15 years ago

Closed 15 years ago

#803 closed enhancement (fixed)

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 (6)

comment:1 by ksgeograf, 15 years ago

Status: newassigned
Version: 2.0.1

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?

comment:2 by jng, 15 years ago

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.

comment:3 by jng, 15 years ago

Or some kind of ResourceFactory class that has

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

would also work

comment:4 by ksgeograf, 15 years ago

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?

comment:5 by jng, 15 years ago

Yes. This is what I am after! Thanks.

comment:6 by ksgeograf, 15 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.