Interface mapping for C# (C# code)
For each Interface that is not nested, ACS generates a code file (.cs) unless the tagged value of the C# Parent File Scoped tag definition is set to True. Within the code file, ACS generates the Interface as an interface.
The interface declaration and body is derived from the items it owns, properties of the Interface, and the tagged values set for Tag Definitions applied by the «C# Classifier» stereotype.
ACS generates the child items, properties and tagged values of an Interface as follows.
Child items:
• If the Interface owns any
Attributes, ACS generates each Attribute as an event or property. For more information about Attribute mapping, click here
Attribute mapping • If the Interface owns any
Operations, ACS generates each Operation as an indexer or method. For more information about Operation mapping, click here
Operation mapping • If the Interface owns any
Roles, ACS generates the each Role as a property. For more information about Role mapping, click here
Association mapping Other child items are ignored.
Properties:
• If a
Description is specified, ACS generates the text of an Interface's Description property on the line before the code generated for the interface. For information about how comments are generated, click here
Generating code comments • ACS generates the Name property as the identifier of the interface.
| ACS may modify the interface identifier that is added to the code to make it valid for C#. You can specify the exact identifier to use through the CODE_GENERATION_NAME property of an Interface. Tell me more... |
• If the Template property is set to True (Template check box selected on Property Pages), ACS generates the Modeler Interface as a generic interface. ACS generates the Formal Template Parameters as the type parameters between angle brackets after the interface identifier.
• If the Visibility property is set to public or package: ACS generates the interface with a public or internal modifier accordingly – ACS generates private and protected modifiers only for nested interfaces.
Other properties are ignored.
The «C# Classifier» stereotype applies the following Tag Definitions to an Interface:
• If a value is set for the tagged value of the C# Attributes tag definition, ACS generates the value as the set of attributes for the interface.
• If a value is set for the tagged value of the C# Extern Alias Directives tag definition and the Interface is generated as a compilation unit, ACS generates the value as the external alias directives. Use this tag definition when defining directives for the Interface that cannot be modeled within the model.
• The tagged value of the read-only C# File tag definition is used for opening generated code files from Modeler. This value is set by ACS.
| Note that the tagged value of the derived C# File tag definition is stored in your computer's registry (not the model) – the path and file name you see does not apply to other users of the model. |
• If the tagged value of the C# Internal tag definition is set to Internal, ACS generates the interface with the internal modifier.
If the Interface is a child of a Class and the C# Internal tag definition is set to Protected Internal, ACS generates the interface with the protected internal modifiers.
• If the tagged value of the C# New tag definition is set to True, ACS generates the new keyword when appropriate.
• If the tagged value of the C# Parent File Scoped tag definition is set to True, ACS does not generate a code file for the Interface and the interface is defined in the code file that is generated for the owning Model, Package or Class.
• If the tagged value of the C# Partial tag definition is set to True - ACS generates the interface with the Partial modifier.
• The C# Sealed tag definition is not used when applied to an Interface.
• The C# Static tag definition is not used when applied to an Interface.
• If the Interface is a template class (generates a generic type - see Template property) and a value is set for the tagged value of the C# Type Parameters Constraints tag definition, ACS generates the value as the constraints that apply to the type parameters of a generic type. ACS generates the value after the interface declaration and before the body code.
• If the tagged value of the C# Unsafe tag definition is set to True, ACS generates the interface with the Unsafe modifier.
• If a value is set for the tagged value of the C# Using Directives tag definition, ACS generates the value as the using directives of the interface.
ACS generates the using directives that are required for the code it generates; however, should you require additional using directives that cannot be derived from the model, use the C# Using Directives to specify them.