Skip to content

Commit 3a97e3f

Browse files
committed
Library updates
Note that due to having new libraries some minor functionality has changed: - Custom helper functions (e.g. stringcompare, stringdiff) need a hash (#) before them, same as the built-in helpers - The #if helper needs double quotes around the name of the object that is evaluated.
1 parent e22501f commit 3a97e3f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+357
-93956
lines changed

ClassLibrary/DataWarehouseAutomation/DataWarehouseAutomation/DataWarehouseAutomation.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Handlebars.Net.1.8.0.Signed" Version="1.8.0" />
11-
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
12-
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.13" />
10+
<PackageReference Include="Handlebars.Net" Version="2.0.7" />
11+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
12+
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.14" />
1313
</ItemGroup>
1414

1515
</Project>

ClassLibrary/DataWarehouseAutomation/DataWarehouseAutomation/HandleBarsHelpers.cs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.IO;
32
using System.Text;
43
using HandlebarsDotNet;
54

@@ -31,10 +30,10 @@ public static DateTime GetRandomDate(int startYear = 1995)
3130
public static void RegisterHandleBarsHelpers()
3231
{
3332
// Generation Date/Time functional helper
34-
Handlebars.RegisterHelper("now", (writer, context, parameters) => { writer.WriteSafeString(DateTime.Now); });
33+
Handlebars.RegisterHelper("now", (output, context, arguments) => { output.WriteSafeString(DateTime.Now); });
3534

3635
// Generation random date, based on an integer input value
37-
Handlebars.RegisterHelper("randomdate", (writer, context, arguments) =>
36+
Handlebars.RegisterHelper("randomdate", (output, context, arguments) =>
3837
{
3938
int length = 1995;
4039

@@ -52,11 +51,11 @@ public static void RegisterHandleBarsHelpers()
5251
}
5352
}
5453

55-
writer.WriteSafeString(GetRandomDate(length).Date);
54+
output.WriteSafeString(GetRandomDate(length).Date);
5655
});
5756

5857
// Generation random string, based on an integer input value
59-
Handlebars.RegisterHelper("randomnumber", (writer, context, arguments) =>
58+
Handlebars.RegisterHelper("randomnumber", (output, context, arguments) =>
6059
{
6160
int length = 10;
6261

@@ -74,11 +73,11 @@ public static void RegisterHandleBarsHelpers()
7473
}
7574
}
7675

77-
writer.WriteSafeString(GetRandomNumber(length));
76+
output.WriteSafeString(GetRandomNumber(length));
7877
});
7978

8079
// Generation random string, based on an integer input value
81-
Handlebars.RegisterHelper("randomstring", (writer, context, arguments) =>
80+
Handlebars.RegisterHelper("randomstring", (output, context, arguments) =>
8281
{
8382
int length = 10;
8483

@@ -98,21 +97,21 @@ public static void RegisterHandleBarsHelpers()
9897

9998
var array = new[]
10099
{
101-
"0","2","3","4","5","6","8","9",
100+
"0","1","2","3","4","5","6","8","9",
102101
"a","b","c","d","e","f","g","h","j","k","m","n","p","q","r","s","t","u","v","w","x","y","z",
103102
"A","B","C","D","E","F","G","H","J","K","L","M","N","P","R","S","T","U","V","W","X","Y","Z"
104103
};
105104
var sb = new StringBuilder();
106105
for (var i = 0; i < length; i++) sb.Append(array[GetRandomNumber(53)]);
107106

108-
writer.WriteSafeString(sb.ToString());
107+
output.WriteSafeString(sb.ToString());
109108
});
110109

111110

112111
// Accept two values, and see if they are the same, use as block helper.
113112
// Usage {{#stringcompare string1 string2}} do something {{else}} do something else {{/stringcompare}}
114113
// Usage {{#stringcompare string1 string2}} do something {{/stringcompare}}
115-
Handlebars.RegisterHelper("stringcompare", (TextWriter output, HelperOptions options, dynamic context, object[] arguments) =>
114+
Handlebars.RegisterHelper("stringcompare", (output, options, context, arguments) =>
116115
{
117116
if (arguments.Length != 2) throw new HandlebarsException("The {{stringcompare}} functions requires exactly two arguments.");
118117

@@ -121,18 +120,18 @@ public static void RegisterHandleBarsHelpers()
121120

122121
if (leftString == rightString)
123122
{
124-
options.Template(output, (object)context);
123+
options.Template(output, context);
125124
}
126125
else
127126
{
128-
options.Inverse(output, (object)context);
127+
options.Inverse(output, context);
129128
}
130129
});
131130

132131
// Accept two values, and do something if they are the different.
133132
// Usage {{#stringdiff string1 string2}} do something {{else}} do something else {{/stringdiff}}
134-
// Usage {{#stringdiff string1 string2}} do something {{/strinstringdiffgcompare}}
135-
Handlebars.RegisterHelper("stringdiff", (TextWriter output, HelperOptions options, dynamic context, object[] arguments) =>
133+
// Usage {{#stringdiff string1 string2}} do something {{/stringdiff}}
134+
Handlebars.RegisterHelper("stringdiff", (output, options, context, arguments) =>
136135
{
137136
if (arguments.Length != 2) throw new HandlebarsException("The {{stringdiff}} functions requires exactly two arguments.");
138137

@@ -149,9 +148,7 @@ public static void RegisterHandleBarsHelpers()
149148
}
150149
});
151150

152-
153-
154-
Handlebars.RegisterHelper("replicate", (TextWriter output, HelperOptions options, dynamic context, object[] arguments) =>
151+
Handlebars.RegisterHelper("replicate", (output, options, context, arguments) =>
155152
{
156153
if (arguments.Length != 1) throw new HandlebarsException("The {{replicate}} functions requires a single integer value as input.");
157154

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<startup>
44
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
55
</startup>
6+
<runtime>
7+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
8+
<dependentAssembly>
9+
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
10+
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
11+
</dependentAssembly>
12+
</assemblyBinding>
13+
</runtime>
614
</configuration>

ClassLibrary/DataWarehouseAutomation/Example_Project/Examples.csproj

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,14 @@
3232
<WarningLevel>4</WarningLevel>
3333
</PropertyGroup>
3434
<ItemGroup>
35-
<Reference Include="Handlebars, Version=1.0.0.0, Culture=neutral, PublicKeyToken=623b39d890c8829c, processorArchitecture=MSIL">
36-
<HintPath>..\packages\Handlebars.Net.1.8.0.Signed.1.8.0\lib\portable-net45+sl50+win+wpa81\Handlebars.dll</HintPath>
35+
<Reference Include="Handlebars, Version=2.0.7.0, Culture=neutral, PublicKeyToken=22225d0bf33cd661, processorArchitecture=MSIL">
36+
<HintPath>..\packages\Handlebars.Net.2.0.7\lib\net46\Handlebars.dll</HintPath>
3737
</Reference>
38-
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
39-
<SpecificVersion>False</SpecificVersion>
40-
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
38+
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
39+
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
4140
</Reference>
4241
<Reference Include="Newtonsoft.Json.Schema, Version=3.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
43-
<HintPath>..\packages\Newtonsoft.Json.Schema.3.0.13\lib\net45\Newtonsoft.Json.Schema.dll</HintPath>
42+
<HintPath>..\packages\Newtonsoft.Json.Schema.3.0.14\lib\net45\Newtonsoft.Json.Schema.dll</HintPath>
4443
</Reference>
4544
<Reference Include="System" />
4645
<Reference Include="System.Core" />

ClassLibrary/DataWarehouseAutomation/Example_Project/Program.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.IO;
33
using DataWarehouseAutomation;
44
using HandlebarsDotNet;
5+
using Newtonsoft.Json;
56
using Newtonsoft.Json.Linq;
67

78

@@ -13,6 +14,7 @@ static void Main(string[] args)
1314
{
1415
HandleBarsHelpers.RegisterHandleBarsHelpers();
1516

17+
1618
DisplayPatternResult(AppDomain.CurrentDomain.BaseDirectory + @"..\..\..\Sample_Templates\TemplateSampleBasic.handlebars", AppDomain.CurrentDomain.BaseDirectory + @"..\..\..\Sample_Metadata\sampleBasic.json");
1719
DisplayPatternResult(AppDomain.CurrentDomain.BaseDirectory + @"..\..\..\Sample_Templates\TemplateSampleBasicWithExtensions.handlebars", AppDomain.CurrentDomain.BaseDirectory + @"..\..\..\Sample_Metadata\sampleBasicWithExtensions.json");
1820
DisplayPatternResult(AppDomain.CurrentDomain.BaseDirectory + @"..\..\..\Sample_Templates\TemplateSampleMultipleDataItemMappings.handlebars", AppDomain.CurrentDomain.BaseDirectory + @"..\..\..\Sample_Metadata\sampleMultipleDataItemMappings.json");
@@ -21,6 +23,7 @@ static void Main(string[] args)
2123
DisplayPatternResult(AppDomain.CurrentDomain.BaseDirectory + @"..\..\..\Sample_Templates\TemplateSatelliteView.handlebars", AppDomain.CurrentDomain.BaseDirectory + @"..\..\..\Sample_Metadata\sampleVDW_Sat_Customer_v161.json");
2224
DisplayPatternResult(AppDomain.CurrentDomain.BaseDirectory + @"..\..\..\Sample_Templates\TemplateSampleFreeForm.handlebars", AppDomain.CurrentDomain.BaseDirectory + @"..\..\..\Sample_Metadata\sampleFreeForm.json");
2325

26+
2427
Console.ReadKey();
2528
}
2629

@@ -35,7 +38,7 @@ private static void DisplayPatternResult(string patternFile, string jsonMetadata
3538
// Fetch the content of the Json files
3639
string jsonInput = File.ReadAllText(jsonMetadataFile);
3740

38-
//deserialisedMapping = JsonConvert.DeserializeObject<DataObjectMappings>(jsonInput);
41+
//var deserialisedMapping = JsonConvert.DeserializeObject<DataObjectMappings>(jsonInput);
3942
var deserialisedMapping = JObject.Parse(jsonInput);
4043

4144
var result = template(deserialisedMapping);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Handlebars.Net.1.8.0.Signed" version="1.8.0" targetFramework="net461" />
4-
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" />
5-
<package id="Newtonsoft.Json.Schema" version="3.0.13" targetFramework="net461" />
3+
<package id="Handlebars.Net" version="2.0.7" targetFramework="net461" />
4+
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net461" />
5+
<package id="Newtonsoft.Json.Schema" version="3.0.14" targetFramework="net461" />
66
</packages>

ClassLibrary/DataWarehouseAutomation/RunDwhAutomation/Program.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ static int Main(string[] args)
1414
// An optimistic start.
1515
Environment.ExitCode = (int)ExitCode.Success;
1616

17+
HandleBarsHelpers.RegisterHandleBarsHelpers();
18+
1719
#region unit testing
1820
// Unit testing only.
1921
//var testArgs = new string[]
@@ -35,6 +37,16 @@ static int Main(string[] args)
3537
// ,"-f", "roelant"
3638
// ,"-v"
3739
//};
40+
41+
//var testArgs = new string[]
42+
//{
43+
// "-i", @"D:\RunDwhAutomation\Input\dbo.SAT_DeliveryTypeSalesControl_InforLN.json"
44+
// ,"-p", @"D:\RunDwhAutomation\Pattern\test.handlebars"
45+
// ,"-o"
46+
// ,"-f", "tst"
47+
// ,"-v"
48+
//};
49+
3850
#endregion
3951

4052
CommandLineArgumentHelper environmentHelper = new CommandLineArgumentHelper();
@@ -94,7 +106,7 @@ static int Main(string[] args)
94106

95107
#region Core
96108
// Do the main stuff
97-
HandleBarsHelpers.RegisterHandleBarsHelpers();
109+
//HandleBarsHelpers.RegisterHandleBarsHelpers();
98110

99111
if (isPath)
100112
{
@@ -139,7 +151,7 @@ static int Main(string[] args)
139151
//Console.WriteLine(helpText);
140152

141153

142-
//Console.ReadKey();
154+
Console.ReadKey();
143155

144156
return Environment.ExitCode;
145157
}
@@ -151,8 +163,9 @@ private static void RunAutomation(Options options, string inputFileName, string
151163
var jsonInput = File.ReadAllText(inputFileName);
152164
var stringTemplate = File.ReadAllText(options.pattern);
153165
var template = Handlebars.Compile(stringTemplate);
154-
// var deserialisedMapping = JsonConvert.DeserializeObject<VdwDataObjectMappings>(jsonInput);
155-
var freeFormMapping = JObject.Parse(jsonInput);
166+
167+
//var deserialisedMapping = JsonConvert.DeserializeObject<VdwDataObjectMappings>(jsonInput);
168+
var freeFormMapping = JObject.Parse(jsonInput);
156169

157170
var result = template(freeFormMapping);
158171

ClassLibrary/DataWarehouseAutomation/RunDwhAutomation/RunDwhAutomation.csproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
<Reference Include="Costura, Version=5.3.0.0, Culture=neutral, processorArchitecture=MSIL">
5858
<HintPath>..\packages\Costura.Fody.5.3.0\lib\netstandard1.0\Costura.dll</HintPath>
5959
</Reference>
60-
<Reference Include="Handlebars, Version=1.0.0.0, Culture=neutral, PublicKeyToken=623b39d890c8829c, processorArchitecture=MSIL">
61-
<HintPath>..\packages\Handlebars.Net.1.8.0.Signed.1.8.0\lib\portable-net45+sl50+win+wpa81\Handlebars.dll</HintPath>
60+
<Reference Include="Handlebars, Version=2.0.7.0, Culture=neutral, PublicKeyToken=22225d0bf33cd661, processorArchitecture=MSIL">
61+
<HintPath>..\packages\Handlebars.Net.2.0.7\lib\net46\Handlebars.dll</HintPath>
6262
</Reference>
6363
<Reference Include="Microsoft.Win32.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
6464
<HintPath>..\packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll</HintPath>
@@ -227,12 +227,6 @@
227227
<None Include="Example.bat" />
228228
<None Include="packages.config" />
229229
</ItemGroup>
230-
<ItemGroup>
231-
<ProjectReference Include="..\DataWarehouseAutomation\DataWarehouseAutomation.csproj">
232-
<Project>{f0458983-9646-42e6-9e18-90ad91288b40}</Project>
233-
<Name>DataWarehouseAutomation</Name>
234-
</ProjectReference>
235-
</ItemGroup>
236230
<ItemGroup>
237231
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
238232
<Visible>False</Visible>
@@ -245,6 +239,12 @@
245239
<Install>false</Install>
246240
</BootstrapperPackage>
247241
</ItemGroup>
242+
<ItemGroup>
243+
<ProjectReference Include="..\DataWarehouseAutomation\DataWarehouseAutomation.csproj">
244+
<Project>{f0458983-9646-42e6-9e18-90ad91288b40}</Project>
245+
<Name>DataWarehouseAutomation</Name>
246+
</ProjectReference>
247+
</ItemGroup>
248248
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
249249
<Import Project="..\packages\Fody.6.5.1\build\Fody.targets" Condition="Exists('..\packages\Fody.6.5.1\build\Fody.targets')" />
250250
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

ClassLibrary/DataWarehouseAutomation/RunDwhAutomation/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<package id="CommandLineParser" version="2.8.0" targetFramework="net472" />
44
<package id="Costura.Fody" version="5.3.0" targetFramework="net472" developmentDependency="true" />
55
<package id="Fody" version="6.5.1" targetFramework="net472" developmentDependency="true" />
6-
<package id="Handlebars.Net.1.8.0.Signed" version="1.8.0" targetFramework="net472" />
6+
<package id="Handlebars.Net" version="2.0.7" targetFramework="net472" />
77
<package id="Microsoft.NETCore.Platforms" version="5.0.2" targetFramework="net472" />
88
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net472" />
99
<package id="NETStandard.Library" version="2.0.3" targetFramework="net472" />
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<startup>
44
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
55
</startup>
6+
<runtime>
7+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
8+
<dependentAssembly>
9+
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
10+
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
11+
</dependentAssembly>
12+
</assemblyBinding>
13+
</runtime>
614
</configuration>

0 commit comments

Comments
 (0)