Book a Demo

Author Topic: How to represent c# generics?  (Read 5807 times)

Sean Gifford

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
How to represent c# generics?
« on: July 11, 2014, 03:51:53 am »
For example, given a class "Detail", and another class "Master" where Master has an attribute that is an IEnumerable<Detail>, how do I actually represent that?

Right now, I'm overriding the attribute type with a value I'm typing in, but obviously I don't have the correct connections by doing this.

Thanks!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How to represent c# generics?
« Reply #1 on: July 11, 2014, 05:04:37 am »
I'm not sure which context you are talking about. But to define types there is usually an ellipsis button right to the input field. There you can choose the right classifier. Just typing it will not result in the right matching.

q.

Sean Gifford

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: How to represent c# generics?
« Reply #2 on: July 11, 2014, 05:08:40 am »
I might be missing something fundamental here.
But if I create a new type that is IEnumerable<Detail>, that doesn't really connect the Master class to Detail. IEnumerable<Detail> being just a list of Detail.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How to represent c# generics?
« Reply #3 on: July 11, 2014, 05:12:19 am »
Are you by any chance talking about the API? Maybe you should note the steps you take.

q.

Sean Gifford

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: How to represent c# generics?
« Reply #4 on: July 11, 2014, 05:26:58 am »
No, I'm talking about simple C# class definitions in a class diagram.  Being able to define attributes or operation parameters on the class to equivalents to C# generic types, like IEnumerable<T>, IDictionary<K,T>, etc. all while maintaining the expected connections.

Sean Gifford

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: How to represent c# generics?
« Reply #5 on: July 11, 2014, 06:03:51 am »
I think I'm closer to a solution, and perhaps this will make what I'm asking clearer.

I have my two sample classes setup, and I've now tried making the Details attribute on Master a Detail type, but whose details are that it's a collection of 0..* multiplicity using a container of type IEnumerable<T>.  It looks like this (http://1drv.ms/1rZaf7i)


This at least succeeds in linking the two elements together, and one understands looking at the result what the intention is.  But it still isn't correct, because when I attempt to generate code I get this:

Code: [Select]
///////////////////////////////////////////////////////////
//  Master.cs
//  Implementation of the Class Master
//  Generated by Enterprise Architect
//  Created on:      10-Jul-2014 2:00:12 PM
//  Original author:
///////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;



public class Master {

      private Detail IEnumerable<T> Details;
      private int Id;

      public Master(){

      }

      ~Master(){

      }

      public virtual void Dispose(){

      }

}//end Master

where

Quote
private Detail IEnumerable<T> Details;
should be
Quote
private IEnumerable<Detail> Details;

I also tried using the IEnumerable<#TYPE#> syntax with no improvement.
EA11, btw

Hope that this makes it clearer.  I'm sure this is just my lacking in some EA fundamentals....