Opened 16 years ago

Closed 16 years ago

#672 closed enhancement (fixed)

Resource definitions - adding ResourceName property

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

Description

Instead of going through:

string mapDef = conn.GetResourceIdentifier("PLAN", MapDefinition, false);
string name  = conn.GetResourceName(mapDef, false); 
string runtimeMap = conn.GetResourceIdentifier(name, RuntimeMap, true);

it would be nice if definition classes had additional ResourceName property (String), thus saving us some repetitive coding. For example:

MapDefinition.ResourceId => "Library://SomeFolder/SomeSubFolder/PLAN.MapDefinition"
MapDefinition.ResourceName => "PLAN"

Change History (4)

comment:1 by ksgeograf, 16 years ago

Status: newassigned
Version: 2.0.1

I find it a bit confusing that there are all these functions that manipulate the resourceId.

The problem with adding a property like you propose is that it quickly leads to other properties, such as "ResourceExtension", "ResourcePath", "ResourceNameAndPath" and "ResourceNameInSession".

.Net uses the System.IO.Path class to store static functions for manipulation on paths.

I was thinking of creating a class for the ResourceId (much like the MgResourceId class), and let that class have all the properties and functions. If possible it could be automatically convertible to and from a string.

I will try to see if I can make such a class, and implement it everywhere. Otherwise I will move all those manipulation into a static class called "ResourceIdentifier".

comment:2 by MaksimS, 16 years ago

Yap, either that or having MapDefinition and all other xxxDefinition types inherit some base Definition class exposing these helper path-mangling functions. Presumably it shouldn't clash with present serializer if given NonSerialized flags. It's much slicker (well, from end-user's standpoint) than having separate static class with helper functions.

comment:3 by MaksimS, 16 years ago

OTOH, having base Definition type (MustInherit in VisualBasic) enables some more unified constructs on functions receiving definition objects as parameters.

comment:4 by ksgeograf, 16 years ago

Resolution: fixed
Status: assignedclosed

I have added a new class called ResourceIdentifier that has all the properties and methods avalible. It is assignable to and from a string, so it is easy to use. It was not possible to make the actual "ResourceId" properties have the new type, due to the Xml serialization process. I did not add the "ResourceName" property, because it would clutter the class definition. Instead, you can now do: string name = new ResourceIdentifier(...).Name;

Note: See TracTickets for help on using tickets.