it:ad:t4:syntax:ttinclude

IT:AD:Transformations:T4:Syntax:ttinclude

<#@ include file="EF.Utility.CS.ttinclude"#>
Tip: It's in `C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes` if you want to go over the source to know what methods are available....

The file contains several class (yeah…I know…should be one class per file…but I guess they did it that way as it's just more practical to only have to include one file).

Classes are:

CodeGenerationTools

Responsible for helping to create source code that is correctly formatted and functional.

public class CodeGenerationTools {
  public CodeGenerationTools(object textTransformation) {...}
  public bool FullyQualifySystemTypes { get; set; } //default:false
  public bool CamelCaseFields { get; set; } //default:true
  /// Returns the NamespaceName suggested by VS if running inside VS.  Or null.
  public string VsNamespaceSuggestion(){...}
  /// Returns a string that is safe for use as an identifier in C#. Keywords are escaped.
  public string Escape(string name) {...}
  /// Returns the name of the TypeUsage's EdmType that is safe for use as an identifier.
  public string Escape(TypeUsage typeUsage) {...}
  /// Returns the name of the EdmMember that is safe for use as an identifier.
  public string Escape(EdmMember member) {...}
  /// Returns the name of the EdmType that is safe for use as an identifier.
  public string Escape(EdmType type) {...}
  /// Returns the name of the EdmFunction that is safe for use as an identifier.
  public string Escape(EdmFunction function) {...}
  /// Returns the name of the EntityContainer that is safe for use as an identifier.
  public string Escape(EntityContainer container) {...}
  /// Returns the name of the EntitySet that is safe for use as an identifier.
  public string Escape(EntitySet set) {...}
  /// Returns the name of the StructuralType that is safe for use as an identifier.
  public string Escape(StructuralType type) {...}
  /// Returns the NamespaceName with each segment safe to use as an identifier.
  public string EscapeNamespace(string namespaceName) {...}
  /// Returns the name of the EdmMember formatted for use as a field identifier.
  /// This method changes behavior based on the CamelCaseFields setiting.
  public string FieldName(EdmMember member) {...}
  /// Returns the name of the EntitySet formatted for use as a field identifier.
  /// This method changes behavior based on the CamelCaseFields setting.
  public string FieldName(EntitySet set) {...}
  /// Returns the name of the Type object formatted for use in source code.
  /// This method changes behavior based on the FullyQualifySystemTypes setting.
  public string Escape(Type clrType) {...}
  /// Returns the abstract option if the entity is Abstract, otherwise returns String.Empty
  public string AbstractOption(EntityType entity) {...}
  /// Returns the passed in identifier with the first letter changed to lowercase {...}
  public string CamelCase(string identifier)
  /// Returns value with single space at end. Or empty string.
  public string SpaceAfter(string value) {...}
  /// Returns value with single space at begining. Or empty string.
  public string SpaceBefore(string value) {...}
  /// Returns value with value at end. Or empty string.
  public string StringAfter(string value, string append) {...}
  /// Returns value with value at begining. Or empty string.
  public string StringBefore(string prepend, string value) {...}
  /// Retuns as full of a name as possible, if a namespace is provided
  /// the namespace and name are combined with a period, otherwise just
  /// the name is returned.
  public string CreateFullName(string namespaceName, string name) {...}
  public string CreateLiteral(object value) {...}
}

 

MetadataLoader

Contains helper methods that access the Entity Framework metadata needed for code generation.

/// Makes the Entity Framework Metadata more accessible for code generation.
class MetadataTools {
  //Constructor
  MetadataTools(object textTransformation) {...}
  /// If the passed in TypeUsage has an EdmType that is a PrimitiveType, this method returns
 /// the coresponding Type object, otherwise it returns the Type object for Object.
 Type ClrType(TypeUsage typeUsage)
 /// True if the EdmProperty is a key of its DeclaringType, False otherwise.
 bool IsKey(EdmProperty property){...}
 /// True if the EdmProperty TypeUsage is Nullable, False otherwise.
 bool IsNullable(EdmProperty property){...}
 /// True if the TypeUsage is Nullable, False otherwise.
 bool IsNullable(TypeUsage typeUsage){...}
/// If the passed in TypeUsage represents a collection this method returns final element
 /// type of the collection, otherwise it returns the value passed in.
 TypeUsage GetElementType(TypeUsage typeUsage){...}
 /// Returns the NavigationProperty that is the other end of the same association set if it is
 /// available, otherwise it returns null.
 NavigationProperty Inverse(NavigationProperty navProperty){...}
 /// Given a property on the dependent end of a referential constraint, returns the corresponding property on the principal end.
 /// Requires: The association has a referential constraint, and the specified dependentProperty is one of the properties on the dependent end.
 EdmProperty GetCorrespondingPrincipalProperty(NavigationProperty navProperty, EdmProperty dependentProperty){...}
 /// Given a property on the principal end of a referential constraint, returns the corresponding property on the dependent end.
 /// Requires: The association has a referential constraint, and the specified principalProperty is one of the properties on the principal end.
 EdmProperty GetCorrespondingDependentProperty(NavigationProperty navProperty, EdmProperty principalProperty){...}
 /// Gets the collection of properties that are on the principal end of a referential constraint for the specified navigation property.
 /// Requires: The association has a referential constraint.
 ReadOnlyMetadataCollection<EdmProperty> GetPrincipalProperties(NavigationProperty navProperty){...}
 /// Gets the collection of properties that are on the dependent end of a referential constraint for the specified navigation property.
 /// Requires: The association has a referential constraint.
 ReadOnlyMetadataCollection<EdmProperty> GetDependentProperties(NavigationProperty navProperty){...}
 /// True if the source end of the specified navigation property is the principal in an identifying relationship.
 /// or if the source end has cascade delete defined.
 bool IsCascadeDeletePrincipal(NavigationProperty navProperty){...}
 /// True if the specified association end is the principal in an identifying relationship.
 /// or if the association end has cascade delete defined.
 bool IsCascadeDeletePrincipal(AssociationEndMember associationEnd){...}
 /// True if the specified association end is the principal end in an identifying relationship.
 /// In order to be an identifying relationship, the association must have a referential constraint 
    where all of the dependent properties are part of the dependent type's primary key.
 bool IsPrincipalEndOfIdentifyingRelationship(AssociationEndMember associationEnd){...}
 /// True if the specified association type is an identifying relationship.
 /// In order to be an identifying relationship, the association must have a referential constraint 
    where all of the dependent properties are part of the dependent type's primary key.
 bool IsIdentifyingRelationship(AssociationType association){...}
 /// requires: firstType is not null
 /// effects: if secondType is among the base types of the firstType, return true,
 /// otherwise returns false.
 /// when firstType is same as the secondType, return false.
 bool IsSubtypeOf(EdmType firstType, EdmType secondType){...}
 /// Returns the subtype of the EntityType in the current itemCollection
 IEnumerable<EntityType> GetSubtypesOf(EntityType type, ItemCollection itemCollection, bool includeAbstractTypes){...}
 //
 static bool TryGetStringMetadataPropertySetting(MetadataItem item, string propertyName, out string value)

}

MetadataTools

Responsible for loading EdmItemCollection, StoreItemCollection, andStorageMappingItemCollection objects from an .edmx or .csdl file.

/// Responsible for loading an EdmItemCollection from a .edmx file or .csdl files
class MetadataLoader {
  /// Initializes an MetadataLoader Instance  with the
  /// TextTransformation (T4 generated class) that is currently running
  MetadataLoader(object textTransformation) {...}
  /// Load the metadata for Edm, Store, and Mapping collections and register them
  /// with a new MetadataWorkspace, returns false if any of the parts can't be
  /// created, some of the ItemCollections may be registered and usable even if false is
  /// returned
  bool TryLoadAllMetadata(string inputFile, out MetadataWorkspace metadataWorkspace) {...}
  /// Create an EdmItemCollection loaded with the metadata provided
  EdmItemCollection CreateEdmItemCollection(string sourcePath, params string[] referenceSchemas) {...}
  /// Attempts to create a EdmItemCollection from the specified metadata file
  bool TryCreateEdmItemCollection(string sourcePath, out EdmItemCollection edmItemCollection) {...}
  /// Attempts to create a EdmItemCollection from the specified metadata file
  bool TryCreateEdmItemCollection(string sourcePath, string[] referenceSchemas, out EdmItemCollection edmItemCollection) {...}
  /// Attempts to create a StoreItemCollection from the specified metadata file
  bool TryCreateStoreItemCollection(string sourcePath, out StoreItemCollection storeItemCollection) {...}
  /// Attempts to create a StorageMappingItemCollection from the specified metadata file, EdmItemCollection, and StoreItemCollection
  bool TryCreateStorageMappingItemCollection(string sourcePath, EdmItemCollection edmItemCollection, 
        StoreItemCollection storeItemCollection, out StorageMappingItemCollection storageMappingItemCollection) {...}
  /// Gets the Model Namespace from the provided schema file.
  string GetModelNamespace(string sourcePath) {...}
}

Other stuff that is useful the static Accessibility class:

/// Responsible for encapsulating the retrieval and translation of the CodeGeneration
/// annotations in the EntityFramework Metadata to a form that is useful in code generation.
static class Accessibility {
  /// Gets the accessibility that should be applied to a type being generated from the provided GlobalItem.
  /// defaults to if no annotation is found.
  static string ForType(GlobalItem item){...}
  /// Gets the accessibility that should be applied at the property level for a property being
  /// generated from the provided EdmMember.
  /// defaults to if no annotation is found.
  static string ForProperty(EdmMember member){...}
  /// Gets the accessibility that should be applied at the property level for a Read-Only property being
  /// generated from the provided EdmMember.
  /// defaults to if no annotation is found.
  static string ForReadOnlyProperty(EdmMember member){...}
  /// Gets the accessibility that should be applied at the property level for a property being
  /// generated from the provided EntitySet.
  /// defaults to if no annotation is found.
  static string ForReadOnlyProperty(EntitySet set){...}
  /// Gets the accessibility that should be applied at the property level for a Write-Only property being
  /// generated from the provided EdmMember.
  /// defaults to if no annotation is found.
  static string ForWriteOnlyProperty(EdmMember member){...}

  /// Gets the accessibility to apply to a property getter.
  static string ForGetter(EdmMember member){...}
  /// Gets the accessibility to apply to a property setter.
  static string ForSetter(EdmMember member){...}
  /// Gets the accessibility to apply to a method being generated from the provided EdmFunction.
  /// defaults to if no annotation is found.
  static string ForMethod(EdmFunction function){...}
}

CodeRegion

/// Responsible for creating code regions (if contains code).
class CodeRegion {
  /// Initializes an CodeRegion instance with the
  /// TextTransformation (T4 generated class) that is currently running
  CodeRegion(object textTransformation){...}
  /// Initializes an CodeRegion instance with the
  /// TextTransformation (T4 generated class) that is currently running,
  /// and the indent level to start the first region at.
  CodeRegion(object textTransformation, int firstIndentLevel){...}
  /// Starts the begining of a region
  void Begin(string regionName){...}
  /// Start the begining of a region, indented the numbers of levels specified
  void Begin(string regionName, int levelsToIncreaseIndent){...}
  /// Ends a region, or totaly removes it if nothing was generted since the begining of the region.
  void End(){...}
  /// Ends a region, or totaly removes it if nothing was generted since the begining of the region, also outdents
  /// the number of levels specified.
  void End(int levelsToDecrease){...}
  /// Gets the current indent level that the next end region statement will be written at
  int CurrentIndentLevel { get { return _regionIndentLevel; } }
  /// Get a string of spaces equivelent to the number of indents desired.
  static string GetIndent(int indentLevel){...}
}
  • /home/skysigal/public_html/data/pages/it/ad/t4/syntax/ttinclude.txt
  • Last modified: 2023/11/04 02:00
  • by 127.0.0.1