Through trial and error I learned UserCodeRegion names carries significance. The name in the TDL must match the name in the commented code.
How can I index or rename the region in a foreach loop? I want to generate the FieldValidate code with all the field indexes listed. with user generated code within each case. Template Code Below
/// <summary>Validates the new value for the <[CurrentEntityName]>Entity field.</summary>
/// <param name="involvedEntity">The related <[CurrentEntityName]>Entity as an IEntityCore.</param>
/// <param name="fieldIndex">Value of the <[CurrentEntityName]>FieldIndex enumerator.</param>
/// <param name="value">proposed value for the <[CurrentEntityName]>Entity field.</param>
/// <returns>True if valid. False if invalid.</returns>
public override bool ValidateFieldValue(IEntityCore involvedEntity, int fieldIndex, object value)
{
bool toReturn = true;
<[ UserCodeRegion "FieldBegin" ]>
// __LLBLGENPRO_USER_CODE_REGION_START FieldBegin
// __LLBLGENPRO_USER_CODE_REGION_END
<[ EndUserCodeRegion ]>
switch ((<[CurrentEntityName]>FieldIndex)fieldIndex)
{<[ Foreach EntityField ]>
case <[CurrentEntityName]>FieldIndex.<[ EntityFieldName ]>:
<[ UserCodeRegion "Field" ]>
// __LLBLGENPRO_USER_CODE_REGION_START Field
// __LLBLGENPRO_USER_CODE_REGION_END
<[ EndUserCodeRegion ]>
break;<[ NextForeach ]>
default:
toReturn = false;
}
return toReturn;
}
the problem is Field is repeated for every section. the only code preserved is the first Field block. So if the first field has no validion all fields have no validation. if the first field does have code then all fields will contain the same validation code.
I tried using the EntityFieldName for the UserCodeRegion, but that produced incorrect syntax.
can I dynamically set the name of the UserCodeRegion using TDL? If not TDL can I use LogicC#? Is there a reference manual on LogicC# syntax?