getTemplateByClassId static method

TypeTemplate? getTemplateByClassId(
  1. Guid classId, [
  2. TemplateType templateType = TemplateType.Unspecified
])
Get a template by class Id from the templates warehouse. If not in the warehouse, a new TypeTemplate is created and added to the warehouse. Class Id.

Implementation

static TypeTemplate? getTemplateByClassId(Guid classId,
    [TemplateType templateType = TemplateType.Unspecified]) {
  if (templateType == TemplateType.Unspecified) {
    // look in resources
    var template = _templates[TemplateType.Resource]?[classId];
    if (template != null) return template;

    // look in records
    template = _templates[TemplateType.Record]?[classId];
    if (template != null) return template;

    // look in wrappers
    template = _templates[TemplateType.Wrapper]?[classId];
    return template;
  } else {
    return _templates[templateType]?[classId];
  }
}