As a consultant, the latter is rather compelling. Maybe I'm only licensing my clients to use accelerators during our engagement. If I leave files on the file system after I roll off, or they image my computer and accidentally collect them, I am David fighting Goliath. CallBimlScriptContent is a means to protect myself and my IP. Let's look at a trivial example. I set a C# string with an empty Package tag (hooray for doubling up my double quotes). Within my Packages collection, I invoke CallBimlScriptContent passing in my Biml content.
<Biml xmlns="http://schemas.varigence.com/biml.xsd"> <# // Do something here to populate myBimlFile string myBimlFile = @"<Package Name=""ABC"" />"; #> <Packages> <#=CallBimlScriptContent(myBimlFile)#> </Packages> </Biml>The rendered Biml for the above would look like
<Biml xmlns="http://schemas.varigence.com/biml.xsd"> <Packages> <Package Name="ABC" /> </Packages> </Biml>
It's super that it works, but that's not convenient. Like, at all! Plus, good luck trying to embed any complexity in that string.
So, let's try something a little more complex. Conceptually, imagine we have two Biml Scripts we might choose to call inc_Package_00.biml and inc_Package_10.biml <#@ property name="parameterName" type="string" #>
inc_Package_00.biml
<Package Name="ABC" />
inc_Package_10.biml
<#@ property name="packageName" type="string" #> <Package Name="packageName" />Our original code could then look like
<Biml xmlns="http://schemas.varigence.com/biml.xsd"> <# // Do something here to populate myBimlFile string myBimlFile =System.IO.File.ReadAllText(@"C:\tmp\inc_Package_00.biml"); #> <Packages> <#=CallBimlScriptContent(myBimlFile, "Package_00)"#> </Packages> </Biml>Do you need to pass parameters? It's no different than what you're used to doing
<Biml xmlns="http://schemas.varigence.com/biml.xsd"> <# // Do something here to populate myBimlFile string myBimlFile =System.IO.File.ReadAllText(@"C:\tmp\inc_Package_10.biml"); #> <Packages> <#=CallBimlScriptContent(myBimlFile, "Package_10)"#> </Packages> </Biml>
In the next post, I'll show you how to use reference data stored in tables or Azure as your BimlScript Content. Stay tuned!
No comments:
Post a Comment