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.10.0 (in Microsoft.VisualStudio.Modeling.Sdk.DslDefinition.10.0.dll)
Syntax
'宣言
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 | |
---|---|---|
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. | |
AllowMultiple | Gets if the given role allows multiple instances, based on its Multiplicity. | |
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". | |
CreateXmlNamespaceQualifiers | Create xmlNamespaceQualifiers for the dslLibrary and its first-level imported libraries | |
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). | |
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. | |
GenerateFontStyle | Create the correct syntax for initializing a font's style. | |
GetAccessModifier | Gets the C# access modifier keyword for the given AccessModifier enum | |
GetAttributeProperties | Returns all DomainProperties defined on the given DomainClass that will be serialized as XML attribute. | |
GetBaseClass | Gets the string for declaring the base class of a domain class. If the base class is not defined, ModelElement is used. | |
GetBaseDomainClass | Get the base domain class for the supplied class | |
GetBaseDomainClassMonikerSchemaTypeName | Get the moniker schema type name for the base class of the given domain class. | |
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". | |
GetBaseDomainClassSchemaTypeName | Get the schema type name for the base class of the given domain class. | |
GetBaseDomainClassXmlTagName | Get the XmlTagName for the base class of the supplied domain class. | |
GetBasePropertyHandlerName | Gets the base class for the PropertyHandler for the given property. The base class is different if it's a calculated property. | |
GetBaseRelationship | Gets the string for declaring the base relationship of a domain relationship. If the base class is not defined, ElementLink is used. | |
GetBaseRole | Gets the base role of the given role if one exists. If not, it returns null. | |
GetCamelCase | Conver the input string to camel case by lower-casing the first character | |
GetDesigner | Get the Designer defined in the given DslLibrary. | |
GetDiagramElementForDecoratorMap | Gets the diagram element associated with the shape or connector map that defines a decorator map. | |
GetDomainClassMonikerSchemaTypeName | Get the moniker schema type name for the given domain class. | |
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". | |
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". | |
GetDomainClassSchemaTypeName | Get the schema type name for the given domain class. | |
GetDomainClassXmlTagName(DomainClass, String) | Get the XmlTagName for a domain class. | |
GetDomainClassXmlTagName(DomainClass, String, Dictionary<DslLibrary, String>) | Get the XmlTagName for a domain class. | |
GetDomainTypeFullName(DomainProperty) | Gets the full name of the type of the DomainProperty (including generic parameters) relative to the namespace of the property's class. | |
GetDomainTypeFullName(DomainType, String) | Gets the full name of the DomainType (including generic parameters) relative to the given current namespace. | |
GetElementProperties | Returns all DomainProperties defined on the given DomainClass that will be serialized as nested XML element. | |
GetGeneratedLinkAccessModifier | Returns the most limited type access modifier among the passed in DomainRelationship and its role players. | |
GetGeneratedPropertyGetterAccessModifier | Returns the getter property modifier to be used for the Get/Set properties in the DomainRelationship class | |
GetGeneratedPropertySetterAccessModifier | Returns the setter property modifier to be used for the Get/Set properties in the DomainRelationship class | |
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. | |
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 | |
GetGuid | Returns a string of the form "new System.Guid(xxx)" where xxx is the string form of the given guid. | |
GetInheritanceModifier | Gets the C# modifier keyword for the given InheritanceModifier enum | |
GetMethodModifier | Gets the method modifier (virtual, override, etc.) in generated code with the given parameters. | |
GetModelElementDomainClass | Returns the DomainClass that represents ModelElement | |
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. | |
GetPackageNamespace | Get Dsl package name for the given Dsl. | |
GetPropertyDefaultValue | Returns the string to declare the default value of a property (in the form "= defaultValue" | |
GetPropertyDefaultValueAttribute | Gets the string for the constructor of the System.ComponentModel.DefaultValueAttribute. | |
GetPropertyHandlerName | Gets the name of a property handler for a property | |
GetPropertyKind | Returns the string for the kind of the kind of the property for the DomainPropertyAttribute constructor. | |
GetPropertyRepresentation | Get the PropertyRepresentation (Attribute, Element, or Ignored) of the given DomainProperty. Default is Attribute if not specified. | |
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. | |
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()). | |
GetSameNameBaseRole | Returns the base role of the given role if it has the same name as the given role | |
GetSegmentInputType(PathSegment) | For the given pathSegment, this method returns its input fully qualified type name. | |
GetSegmentInputType(PathSegment, Boolean) | For the given pathSegment, this method returns its input fully qualified type name. | |
GetSegmentOutputType(PathSegment) | For the given pathSegment, this method returns its output fully qualified type name. | |
GetSegmentOutputType(PathSegment, Boolean) | For the given pathSegment, this method returns its output fully qualified type name. | |
GetSerializedDomainClasses | Get a list of all DomainClasses in the given DslLibrary that will have serializers generated. | |
GetTypeAccessModifier | Gets the C# access modifier keyword for the given TypeAccessModifier enum | |
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. | |
GetVersionString | Get the version of a DslLibrary in string form. | |
GetXmlSchemaNamespace | Get the XML namespace to use for the generated schema | |
HasCompartmentMaps | True if the given Diagram defines CompartmentMaps. | |
HasCustomBaseImplementation | Obsolete. Whether the given DomainClass (or any of its base DomainClasses) is marked as "IsCustom", which means the serialization is customized. | |
HasCustomTypeDescriptor | Returns true if the given class has a custom type descriptor defined, false otherwise. | |
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. | |
IsCoreDomainModel | Returns whether the supplied class is the Core domain model | |
IsElementLinkDomainClass | Returns whether the supplied domain class represents "ElementLink". | |
IsGuidType | returns true if typeName represents Guid ("System.Guid") | |
IsInCoreDomainModel | Returns whether the supplied class is part of the Core domain model | |
IsLaxElementSchemaRequired | Whether a lax element schema type definition is required for the class | |
IsModelElementDomainClass | Returns whether the supplied domain class represents "ModelElement". | |
IsMultiple | returns true if the upper bound of the given multiplicity is * | |
IsOuterDecorator(DiagramElementHasDecorators) | Returns true if the given link connects to an outer decorator. | |
IsOuterDecorator(ShapeDecoratorPosition) | Returns true if the given ShapeDecorationPosition is an outer decorator. | |
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. | |
IsStringProperty | returns true if the property is of type string. | |
IsStringType | returns true if typeName represents a string ("string" or "System.String") | |
MapToSchemaType | Map a DomainType to its schema type. | |
OmitElement | Gets if the given DomainRelationship is serialized as "OmitElement" (without the role element tag). | |
RequiresGeneratedPropertyDescriptor | Returns true if the given descriptor requires a PropertyDescriptor derived class to be generated, false otherwise. | |
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) ... ... | |
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. | |
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. | |
UseFullForm | Gets if the given DomainRelationship is serialized in full-form. | |
WrapAsCSharpString | Wrap the given string into a string literal in C# syntax. |
Top
Fields
Name | Description | |
---|---|---|
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.