Search code examples
c#umlenterprise-architectclass-diagram

Enterprise Architect UML Diagram, Class Model


I have class.

[DataContract]
public class Person{ 
 [DataMember]
 public string Name{get; set;};

 [DataMember]
 public string Lastname{get; set;};    
 }

I need to create UML class diagram in Enterprise Architect. I create class and add Name and Lastname property but i don't know how to put [DataContract] and [DataMember]. Can anyone know how to do it or is it posible to do it?


Solution

  • The annotations are used to express what shall be serialized by the data contract serializer. This language specific (or at least platform specific) and no known or supported concept in UML. The UML way to solve this are stereotypes. Therefore define a stereotype << DataContract >>, which can be applied to classes, and a stereotype << DataMember >>, which can be applied to attributes. Then model your class with the attributes having the according stereotypes. Based on that stereotypes the generation of code can be controlled or the transformation of the model.