Skip to content

Commit 5359014

Browse files
author
Steve Ives
committed
Added <HARMONYCORE_CUSTOM_FIELD_DATATYPE> and <IF HARMONYCORE_CUSTOM_DATATYPE>.
1 parent 2a9ba36 commit 5359014

File tree

5 files changed

+125
-2
lines changed

5 files changed

+125
-2
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
2+
import System
3+
import System.Collections.Generic
4+
import CodeGen.Engine
5+
import CodeGen.RepositoryAPI
6+
7+
namespace HarmonyCoreExtensions
8+
9+
public class CustomFieldDataType implements IExpansionToken
10+
11+
public property TokenName, String
12+
method get
13+
proc
14+
mreturn "HARMONYCORE_CUSTOM_FIELD_DATATYPE"
15+
endmethod
16+
endproperty
17+
18+
public property Description, String
19+
method get
20+
proc
21+
mreturn "An example of a custom field loop token."
22+
endmethod
23+
endproperty
24+
25+
public property Validity, TokenValidity
26+
method get
27+
proc
28+
mreturn TokenValidity.FieldLoop
29+
endmethod
30+
endproperty
31+
32+
public property TokenCase, TokenCaseMode
33+
method get
34+
proc
35+
mreturn TokenCaseMode.UppercaseOnly
36+
endmethod
37+
endproperty
38+
39+
public method Expand, String
40+
tkn, @Token
41+
template, @FileNode
42+
loops, @IEnumerable<LoopNode>
43+
endparams
44+
proc
45+
lambda doExpand(str, field)
46+
begin
47+
data textToSearch = field.LongDescription + field.UserText
48+
if (field.LongDescription.Contains("HARMONYCORE_CUSTOM_FIELD_DATATYPE="))
49+
begin
50+
data startPos = textToSearch.IndexOf("HARMONYCORE_CUSTOM_FIELD_DATATYPE=")
51+
data semiPos = -1
52+
if (startPos!=-1)
53+
semiPos = textToSearch.IndexOf(";",startPos)
54+
if ((startPos!=-1) && (semiPos!=-1) && (semiPos>(startPos+34)))
55+
mreturn textToSearch.SubString(startPos+34,semiPos-startPos-34)
56+
end
57+
mreturn field.SnType
58+
end
59+
mreturn TokenExpander.ExpandFieldLoopToken(tkn, template, loops, doExpand)
60+
endmethod
61+
62+
endclass
63+
64+
endnamespace

HarmonyCoreExtensions/CustomFieldType.dbl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import CodeGen.RepositoryAPI
66

77
namespace HarmonyCoreExtensions
88

9-
public class CustomFieldLoopToken implements IExpansionToken
9+
public class CustomFieldType implements IExpansionToken
1010

1111
public property TokenName, String
1212
method get

HarmonyCoreExtensions/HarmonyCoreExtensions.synproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@
6868
<Reference Include="System.Core" />
6969
</ItemGroup>
7070
<ItemGroup>
71+
<Compile Include="CustomFieldDataType.dbl" />
7172
<Compile Include="CustomFieldType.dbl" />
7273
<Compile Include="CustomRelationSpec.dbl" />
7374
<Compile Include="FieldProperty.dbl" />
7475
<Compile Include="FromRelationName.dbl" />
76+
<Compile Include="HasCustomDataType.dbl" />
7577
<Compile Include="Helpers.dbl" />
7678
<Compile Include="IsCustomField.dbl" />
7779
<Compile Include="ManyToOneToMany.dbl" />
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
2+
import System
3+
import System.Collections.Generic
4+
import CodeGen.Engine
5+
import CodeGen.RepositoryAPI
6+
7+
namespace HarmonyCoreExtensions
8+
9+
public class HasCustomDataType implements IExpressionToken
10+
11+
public property TokenName, String
12+
method get
13+
proc
14+
mreturn "HARMONYCORE_CUSTOM_DATATYPE"
15+
endmethod
16+
endproperty
17+
18+
public property Description, String
19+
method get
20+
proc
21+
mreturn "Does the field have a custom data type?"
22+
endmethod
23+
endproperty
24+
25+
public property Validity, TokenValidity
26+
method get
27+
proc
28+
mreturn TokenValidity.FieldLoop
29+
endmethod
30+
endproperty
31+
32+
public method Evaluate, Boolean
33+
tkn, @Token
34+
template, @FileNode
35+
loops, @IEnumerable<LoopNode>
36+
endparams
37+
proc
38+
lambda doEvaluate(str, field, index)
39+
begin
40+
data textToSearch = field.LongDescription + field.UserText
41+
;Add code here to determine the result of the expression, and return true or false
42+
if (textToSearch.Contains("HARMONYCORE_CUSTOM_FIELD_DATATYPE="))
43+
begin
44+
data startPos = textToSearch.IndexOf("HARMONYCORE_CUSTOM_FIELD_DATATYPE=")
45+
data semiPos = -1
46+
if (startPos!=-1)
47+
semiPos = textToSearch.IndexOf(";",startPos)
48+
mreturn (startPos!=-1) && (semiPos!=-1) && (semiPos>(startPos+34))
49+
end
50+
mreturn false
51+
end
52+
mreturn ExpressionEvaluator.EvaluateFieldLoopExpression(tkn, template, loops, doEvaluate)
53+
endmethod
54+
55+
endclass
56+
57+
endnamespace

HarmonyCoreExtensions/IsCustomField.dbl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import CodeGen.RepositoryAPI
66

77
namespace HarmonyCoreExtensions
88

9-
public class CustomFieldLoopExpression implements IExpressionToken
9+
public class IsCustomField implements IExpressionToken
1010

1111
public property TokenName, String
1212
method get

0 commit comments

Comments
 (0)