Delen via


CodeGenerationUtilities Class

Utilities used by the code-generation templates

Inheritance Hierarchy

System.Object
  Microsoft.VisualStudio.Modeling.DslDefinition.CodeGenerationUtilities

Namespace:  Microsoft.VisualStudio.Modeling.DslDefinition
Assembly:  Microsoft.VisualStudio.Modeling.Sdk.DslDefinition.12.0 (in Microsoft.VisualStudio.Modeling.Sdk.DslDefinition.12.0.dll)

Syntax

'Declaration
Public NotInheritable Class CodeGenerationUtilities
public static class CodeGenerationUtilities
public ref class CodeGenerationUtilities abstract sealed
[<AbstractClass>]
[<Sealed>]
type CodeGenerationUtilities =  class end
public final class CodeGenerationUtilities

The CodeGenerationUtilities type exposes the following members.

Methods

  Name Description
Public methodStatic member AddSerializationResourceStrings Add resource strings used by generated serializers. The string added here are not localized, because they're used to generate resx file, which will be localized.
Public methodStatic member AllowMultiple Gets if the given role allows multiple instances, based on its Multiplicity.
Public methodStatic member CalculateInheritanceDepth Given a DomainClass, calculate the inheritance depth in generated code (taking into consideration of double-derived base classes). This is used to determine whether we need a SuppressMessage attribute for "excessive inheritance".
Public methodStatic member CreateXmlNamespaceQualifiers Create xmlNamespaceQualifiers for the dslLibrary and its first-level imported libraries
Public methodStatic member DefinesDiagramElements True if the given DslLibrary defines diagram elements, false otherwise. Diagram elements are elements that are included in DslLibrary.DiagramElements, plus diagram (if one is defined).
Public methodStatic member DefinesNewTargetRole In relationship derivation, a relationship can use the same target role-player as its parent relationship, or it can define a new one (which derives from the parent relationship's target role-player). This method tells whether the given DomainRelationship defines a new target role- player.
Public methodStatic member GenerateFontStyle Create the correct syntax for initializing a font's style.
Public methodStatic member GetAccessModifier Gets the C# access modifier keyword for the given AccessModifier enum
Public methodStatic member GetAttributeProperties Returns all DomainProperties defined on the given DomainClass that will be serialized as XML attribute.
Public methodStatic member GetBaseClass Gets the string for declaring the base class of a domain class. If the base class is not defined, ModelElement is used.
Public methodStatic member GetBaseDomainClass Get the base domain class for the supplied class
Public methodStatic member GetBaseDomainClassMonikerSchemaTypeName Get the moniker schema type name for the base class of the given domain class.
Public methodStatic member GetBaseDomainClassMonikerTagName Get the MonikerTagName for a the base class of the supplied domain class when it is serialized as a moniker. Note that the tag name cannot be the same for moniker, because that will require two definitions of the same element in the generated schema. The default name used (if not specified using "XmlClassData.MonikerElementName"), will be the non-moniker XmlTagName followed by "Moniker".
Public methodStatic member GetBaseDomainClassSchemaTypeName Get the schema type name for the base class of the given domain class.
Public methodStatic member GetBaseDomainClassXmlTagName Get the XmlTagName for the base class of the supplied domain class.
Public methodStatic member GetBasePropertyHandlerName Gets the base class for the PropertyHandler for the given property. The base class is different if it's a calculated property.
Public methodStatic member GetBaseRelationship Gets the string for declaring the base relationship of a domain relationship. If the base class is not defined, ElementLink is used.
Public methodStatic member GetBaseRole Gets the base role of the given role if one exists. If not, it returns null.
Public methodStatic member GetCamelCase Conver the input string to camel case by lower-casing the first character
Public methodStatic member GetDesigner Get the Designer defined in the given DslLibrary.
Public methodStatic member GetDiagramElementForDecoratorMap Gets the diagram element associated with the shape or connector map that defines a decorator map.
Public methodStatic member GetDomainClassMonikerSchemaTypeName Get the moniker schema type name for the given domain class.
Public methodStatic member GetDomainClassMonikerTagName(DomainClass, String) Get the MonikerTagName for a domain class, when it is serialized as a moniker. Note that the tag name cannot be the same for moniker, because that will require two definitions of the same element in the generated schema. The default name used (if not specified using "XmlClassData.MonikerElementName"), will be the non-moniker XmlTagName followed by "Moniker".
Public methodStatic member GetDomainClassMonikerTagName(DomainClass, String, Dictionary<DslLibrary, String>) Get the MonikerTagName for a domain class, when it is serialized as a moniker. Note that the tag name cannot be the same for moniker, because that will require two definitions of the same element in the generated schema. The default name used (if not specified using "XmlClassData.MonikerElementName"), will be the non-moniker XmlTagName followed by "Moniker".
Public methodStatic member GetDomainClassSchemaTypeName Get the schema type name for the given domain class.
Public methodStatic member GetDomainClassXmlTagName(DomainClass, String) Get the XmlTagName for a domain class.
Public methodStatic member GetDomainClassXmlTagName(DomainClass, String, Dictionary<DslLibrary, String>) Get the XmlTagName for a domain class.
Public methodStatic member GetDomainTypeFullName(DomainProperty) Gets the full name of the type of the DomainProperty (including generic parameters) relative to the namespace of the property's class.
Public methodStatic member GetDomainTypeFullName(DomainType, String) Gets the full name of the DomainType (including generic parameters) relative to the given current namespace.
Public methodStatic member GetElementProperties Returns all DomainProperties defined on the given DomainClass that will be serialized as nested XML element.
Public methodStatic member GetGeneratedLinkAccessModifier Returns the most limited type access modifier among the passed in DomainRelationship and its role players.
Public methodStatic member GetGeneratedPropertyGetterAccessModifier Returns the getter property modifier to be used for the Get/Set properties in the DomainRelationship class
Public methodStatic member GetGeneratedPropertySetterAccessModifier Returns the setter property modifier to be used for the Get/Set properties in the DomainRelationship class
Public methodStatic member GetGenerationClassName Returns the name of the class to be generated. In the case of a double-derived class, we add 'Base' to the name of the domain class. If not, the name of the domain class is used.
Public methodStatic member GetGenerationInheritanceModifier Gets the class modifier for a domain class. Returns "abstract" if the class is a double derived class because the generated class (base class) in a double-derived pair is always abstract
Public methodStatic member GetGuid Returns a string of the form "new System.Guid(xxx)" where xxx is the string form of the given guid.
Public methodStatic member GetInheritanceModifier Gets the C# modifier keyword for the given InheritanceModifier enum
Public methodStatic member GetMethodModifier Gets the method modifier (virtual, override, etc.) in generated code with the given parameters.
Public methodStatic member GetModelElementDomainClass Returns the DomainClass that represents ModelElement
Public methodStatic member GetNameProperty Return a property (in this or a base class) that can be used to idenfify an element to the user. Returns the property marked IsElementName. If there is none, returns the property marked IsMonikerKey. If there is none, returns null.
Public methodStatic member GetPackageNamespace Get Dsl package name for the given Dsl.
Public methodStatic member GetPropertyDefaultValue Returns the string to declare the default value of a property (in the form "= defaultValue"
Public methodStatic member GetPropertyDefaultValueAttribute Gets the string for the constructor of the System.ComponentModel.DefaultValueAttribute.
Public methodStatic member GetPropertyHandlerName Gets the name of a property handler for a property
Public methodStatic member GetPropertyKind Returns the string for the kind of the kind of the property for the DomainPropertyAttribute constructor.
Public methodStatic member GetPropertyRepresentation Get the PropertyRepresentation (Attribute, Element, or Ignored) of the given DomainProperty. Default is Attribute if not specified.
Public methodStatic member GetPropertyTagName Gets the XML tag name of the given DomainProperty. The tag name will be either the XML attribute name if the property is serialized as an XML attribute, or XML element name if the property is serialized as a nested XML element.
Public methodStatic member GetRelationshipTagName Get the XML role element name for the given role's relationship. Note: this is the RoleElementName (if defined), not the XML tag name for a full-form relationship (which is returned from GetDomainClassXmlTagName()).
Public methodStatic member GetSameNameBaseRole Returns the base role of the given role if it has the same name as the given role
Public methodStatic member GetSegmentInputType(PathSegment) For the given pathSegment, this method returns its input fully qualified type name.
Public methodStatic member GetSegmentInputType(PathSegment, Boolean) For the given pathSegment, this method returns its input fully qualified type name.
Public methodStatic member GetSegmentOutputType(PathSegment) For the given pathSegment, this method returns its output fully qualified type name.
Public methodStatic member GetSegmentOutputType(PathSegment, Boolean) For the given pathSegment, this method returns its output fully qualified type name.
Public methodStatic member GetSerializedDomainClasses Get a list of all DomainClasses in the given DslLibrary that will have serializers generated.
Public methodStatic member GetTypeAccessModifier Gets the C# access modifier keyword for the given TypeAccessModifier enum
Public methodStatic member GetTypeRole Gets the role that determines the type of the generated property for this role. This is the most-base role that has the same name as this role.
Public methodStatic member GetVersionString Get the version of a DslLibrary in string form.
Public methodStatic member GetXmlSchemaNamespace Get the XML namespace to use for the generated schema
Public methodStatic member HasCompartmentMaps True if the given Diagram defines CompartmentMaps.
Public methodStatic member HasCustomBaseImplementation Obsolete. Whether the given DomainClass (or any of its base DomainClasses) is marked as "IsCustom", which means the serialization is customized.
Public methodStatic member HasCustomTypeDescriptor Returns true if the given class has a custom type descriptor defined, false otherwise.
Public methodStatic member HasNonAbstractBaseClass Tells if the given DomainClass has a non-abstract base class. There is needed to determine if a "new" keyword needs to be generated.
Public methodStatic member IsCoreDomainModel Returns whether the supplied class is the Core domain model
Public methodStatic member IsElementLinkDomainClass Returns whether the supplied domain class represents "ElementLink".
Public methodStatic member IsGuidType returns true if typeName represents Guid ("System.Guid")
Public methodStatic member IsInCoreDomainModel Returns whether the supplied class is part of the Core domain model
Public methodStatic member IsLaxElementSchemaRequired Whether a lax element schema type definition is required for the class
Public methodStatic member IsModelElementDomainClass Returns whether the supplied domain class represents "ModelElement".
Public methodStatic member IsMultiple returns true if the upper bound of the given multiplicity is *
Public methodStatic member IsOuterDecorator(DiagramElementHasDecorators) Returns true if the given link connects to an outer decorator.
Public methodStatic member IsOuterDecorator(ShapeDecoratorPosition) Returns true if the given ShapeDecorationPosition is an outer decorator.
Public methodStatic member IsRootClass If a DomainClass is a root class, all its serialization-related methods/properties will be virtual (unless it's sealed); otherwise, these methods/properties will be "override" and will call base implementations. Currently, a DomainClass is a root class if it derives from Microsoft.VisualStudio.Modeling.ModelElement or Microsoft.VisualStudio.Modeling.ElementLink directly.
Public methodStatic member IsStringProperty returns true if the property is of type string.
Public methodStatic member IsStringType returns true if typeName represents a string ("string" or "System.String")
Public methodStatic member MapToSchemaType Map a DomainType to its schema type.
Public methodStatic member OmitElement Gets if the given DomainRelationship is serialized as "OmitElement" (without the role element tag).
Public methodStatic member RequiresGeneratedPropertyDescriptor Returns true if the given descriptor requires a PropertyDescriptor derived class to be generated, false otherwise.
Public methodStatic member SortDomainClassesByInheritance<T> Sort a collection of DomainClasses based on relative inheritance relationships. The most derived one will appear first in the sort result. This is used in following situation: Say there're 4 DomainClasses A, B, C and D. You need to generate some code like following: ... A a = obj as A; if (a != null) ... B b = obj as B; if (b != null) ... C c = obj as C; if (c != null) ... D d = obj as D; if (d != null) ... ... If C derives from A, the above code is wrong; the correct code should check for C first before checking for A. That's why this method should be called to sorted the DomainClasses in inheritance order, and the generated code will look like: ... C c = obj as C; if (c != null) ... A a = obj as A; if (a != null) ... B b = obj as B; if (b != null) ... D d = obj as D; if (d != null) ... ...
Public methodStatic member SortProperties Sort DomainProperties based on XmlElement.Order (if specified). By default, the order of each property is 0. Properties with smaller order will appear first. Properties of the same order will not be sorted (i.e. they'll keep their relative order after sorting). The sorting is in-place, so the passed-in collection will be changed directly.
Public methodStatic member SortRoles Sort DomainRoles based on XmlRelationshipElement.Order (if specified). By default, the order of each role is 0. Roles with smaller order will appear first. Roles of the same order will not be sorted (i.e. they'll keep their relative order after sorting). The sorting is in-place, so the passed-in collection will be changed directly.
Public methodStatic member UseFullForm Gets if the given DomainRelationship is serialized in full-form.
Public methodStatic member WrapAsCSharpString Wrap the given string into a string literal in C# syntax.

Top

Fields

  Name Description
Public fieldStatic member CoreDomainModelNamespacePrefix

Top

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.VisualStudio.Modeling.DslDefinition Namespace