Class NamespaceGenerator<T>
Represents a transformation rule that generates namespaces
Inheritance
Inherited Members
Namespace: NMF.CodeGen
Assembly: NMF.CodeGen.dll
Syntax
public abstract class NamespaceGenerator<T> : TransformationRule<T, CodeNamespace> where T : class
Type Parameters
Name | Description |
---|---|
T | The model element type from which namespaces are being generated |
Constructors
| Edit this page View SourceNamespaceGenerator()
Creates a new instance
Declaration
protected NamespaceGenerator()
Properties
| Edit this page View SourceAssembliesToCheck
Gets the assemblies in which to check for system name conflicts
Declaration
protected virtual IEnumerable<Assembly> AssembliesToCheck { get; }
Property Value
Type | Description |
---|---|
IEnumerable<Assembly> |
DefaultImports
Gets the default namespace imports in a derived class
Declaration
public abstract IEnumerable<string> DefaultImports { get; }
Property Value
Type | Description |
---|---|
IEnumerable<string> |
Methods
| Edit this page View SourceCreateOutput(T, ITransformationContext)
Creates the uninitialized transformation rule output
Declaration
public override CodeNamespace CreateOutput(T input, ITransformationContext context)
Parameters
Type | Name | Description |
---|---|---|
T | input | The input model element |
ITransformationContext | context | The transformation context |
Returns
Type | Description |
---|---|
CodeNamespace | A blank code namespace with the correct name |
Overrides
GetName(T)
Gets the name for the code namespace generated from the given model element
Declaration
protected abstract string GetName(T input)
Parameters
Type | Name | Description |
---|---|---|
T | input | The input model element |
Returns
Type | Description |
---|---|
string | The name of the code namespace |
GetNamespaceConflictsIdentifier()
Gets the identifier for namespace conflicts
Declaration
protected virtual object GetNamespaceConflictsIdentifier()
Returns
Type | Description |
---|---|
object | An object that is used to obtain namespace conflicts |
IsNamespaceConflict(string, CodeNamespace)
Decides whether the given name causes a namespace conflict
Declaration
protected virtual bool IsNamespaceConflict(string name, CodeNamespace ns)
Parameters
Type | Name | Description |
---|---|---|
string | name | The proposed name |
CodeNamespace | ns | The namespace |
Returns
Type | Description |
---|---|
bool | True, if there is a namespace conflict so that the given name must be fully qualified, otherwise False |
IsSystemNameConflict(string)
Determines whether the given type name is a conflict with a system type
Declaration
protected virtual bool IsSystemNameConflict(string typeName)
Parameters
Type | Name | Description |
---|---|---|
string | typeName |
Returns
Type | Description |
---|---|
bool |
IsValidName(string, CodeNamespace)
Decides whether the given name is a valid class name for a type
Declaration
protected virtual bool IsValidName(string name, CodeNamespace ns)
Parameters
Type | Name | Description |
---|---|---|
string | name | The proposed name |
CodeNamespace | ns | The proposed namespace |
Returns
Type | Description |
---|---|
bool | True if the name is valid, otherwise False |
RequireType<TType>(TransformationRuleBase<TType, CodeTypeDeclaration>, Func<T, TType>)
Creates a dependency that the given subsequent model element is transformed to a type
Declaration
public ITransformationRuleDependency RequireType<TType>(TransformationRuleBase<TType, CodeTypeDeclaration> rule, Func<T, TType> selector) where TType : class
Parameters
Type | Name | Description |
---|---|---|
TransformationRuleBase<TType, CodeTypeDeclaration> | rule | The transformation rule used to generate the type |
Func<T, TType> | selector | A function selecting the correct subsequent model element |
Returns
Type | Description |
---|---|
ITransformationRuleDependency | The created transformation rule dependency |
Type Parameters
Name | Description |
---|---|
TType | The model element of the input type |
RequireTypes<TType>(TransformationRuleBase<TType, CodeTypeDeclaration>, Func<T, IEnumerable<TType>>)
Creates a dependency that the given subsequent model elements are transformed to types
Declaration
public ITransformationRuleDependency RequireTypes<TType>(TransformationRuleBase<TType, CodeTypeDeclaration> rule, Func<T, IEnumerable<TType>> selector) where TType : class
Parameters
Type | Name | Description |
---|---|---|
TransformationRuleBase<TType, CodeTypeDeclaration> | rule | The transformation rule used to generate the types |
Func<T, IEnumerable<TType>> | selector | A function that selects the subsequent model elements |
Returns
Type | Description |
---|---|
ITransformationRuleDependency | The created transformation rule dependency |
Type Parameters
Name | Description |
---|---|
TType | The model elements input type |
Transform(T, CodeNamespace, ITransformationContext)
Initializes the generated code namespace
Declaration
public override void Transform(T input, CodeNamespace output, ITransformationContext context)
Parameters
Type | Name | Description |
---|---|---|
T | input | The input model element |
CodeNamespace | output | The generated code namespace |
ITransformationContext | context | The transformation context |