index > Visual Studio Team System - Domain-Specific Language Tools > How to generate Hashtable like collection?

How to generate Hashtable like collection?


Hi,

Is there any way to generate a collection with an access by some key? For example, I have Embedding reference with "allow dublicates" property equal to "False", the target role player has element name attribute. I want to get elements not only by index but by element name, for instance.

Evgeny

Evgeny Popov

Hi Evgeny,

There's no direct/obvious way to gen the code automatically. You can either

1. Change the template file: This is so that it can generates the code you want. or

2. Add helper method in the parent/embedding model element to returned the embedded element via name.

Regards,

Patrick




Patrick Tseng
Patrick Tseng

Hi Patrick,

I took a look at the template, it's not easy to modify template, because there are a lot of dependencies on

Microsoft.VisualStudio.Modeling.LinkedElementCollection<T>

Helper method it is not what I really want, but... If add a generation of those methods to CodeTemplate it may be nice. I was looking on MonikerResolver.

Any way, thank you for response!

Evgeny

Evgeny Popov

Hi Evgeny,

Really, at present it's not possibly to do this effectively.

You can simulate the API of a hastable to some extent by using a custom collection type of a role and deriving your own collection from LinkedElementCollection. This collection could add indexed accessors. However, making those accessors anything other than brute force searches is pretty painful as you can't change the fundamental storage of the links at present.

One way to do it if you really needed read-time perf is to use Store events to watch the collection and keep an extrinsic index in sync with the actual links.

I'd be interested to know how many folks would find being able to index collections by properties a compelling future feature.




Gareth Jones - Developer - DSL Tools & Software Factories Platform [MSFT]
GarethJ - MSFT
reply 4

You can use google to search for other answers

 

More Articles

RelationShip ZeroOne-ZeroMany as property
How to intercept shape double-click event
Error : Value cannot be null ,Parameter name:Key
ZOrder
How to set compartment's default expanded property to false?
Installation Problems? "operation is not valid due to the cu...
[outdated] September 2005 CTP available
Embedding Relationships and Inheritence
How to move shapes within diagram programmatically???
Popup dialog in DSL
Welcome to Bokebb   New Update   Joins the collection  
 

New Articles

Custom Command improvements
designer definition toolbox item - compa…
academic distribution of a DSL
How to Use Path Syntax and Element Merge…
DSL and GAT demo
DSL Support For Reverse Engineering, Obj…
Many models, one template.
How to make the connector text parallel …
How to clip shape text?
Experimental UI - show and hide shapes a…
How to intercept shape double-click event
Comments and CommentShapes
Designer and File Associations
ZOrder
Dynamically Create Links OnAttributeChan…

Hot Articles

T4 Text Template Editor for VS2005
Enable/Disable property OnValueChanging/…
UIPChart problem
On Stores, Editors & Models.
Multiple viewpoints/ zoom in, zoom out
Multiple DSL's using the same file exten…
UML Sequence diagram in DSL?
Crash of visual studio when model is inc…
DSL : Properties Grouping in the Proper…
Transitions shapes not draggable/Package…
November DSL toolkit: how to add command…
Open a new Document
February CTP of DSL Tools is live in the…
Where can i get more documents of DLS To…
Migrating compartments

Recommend Articles

Validation / Rejecting a change from a C…
How to fill custom properties dynamicall…
GAC support in Templating Engine (Featur…
How to remove non application menu-items…
November DSL toolkit: how to add command…
Using existing Enumerations
Define a menu command
Error Message: Cannot find custom tool …
Elements doesn't appear to the target de…
DSL Tools V1 Released
How to Use Path Syntax and Element Merge…
How to access the Session in subdomain?
How to change the Name property when a S…
Codegen templates selected at build time
newbie question,thank you for your atten…