- Home
- LLBLGen Pro
- LLBLGen Pro Runtime Framework
Talkin' bout MyGeneration
ok, since I have no replies, I take it that nobody uses MyGeneration.
I have not use it but I was seeing if it was worth looking into. It seems that some of you guys use CodeSmith which looks very interesting as well.
So, having said that, have some of you created scripts for creating the spit (generated controls) region for things like two grids. The first grid being an Order Master the second grid being the Order Detail for example? If so, I think it would be great if someone could publish this like that.
Thanks,
Fishy
Fishy wrote:
ok, since I have no replies, I take it that nobody uses MyGeneration.
It's sort of a clone of codesmith. It uses the same principle: generate a class with code from a template, in memory, compile it in memory to an assembly and call the method you added to start the code with. Pretty simple . I'm halfway through such a task performer, the parser is ready, I just have to add some preprocessor directives and the actual assembly compile code and it's ready to rock
Otis wrote:
It's sort of a clone of codesmith. It uses the same principle: generate a class with code from a template, in memory, compile it in memory to an assembly and call the method you added to start the code with. Pretty simple
. I'm halfway through such a task performer, the parser is ready, I just have to add some preprocessor directives and the actual assembly compile code and it's ready to rock
![]()
So, let me understand this, you are creating a task performer that will allow llblgen to behave like codesmith?
Cadmium wrote:
Otis wrote:
It's sort of a clone of codesmith. It uses the same principle: generate a class with code from a template, in memory, compile it in memory to an assembly and call the method you added to start the code with. Pretty simple
. I'm halfway through such a task performer, the parser is ready, I just have to add some preprocessor directives and the actual assembly compile code and it's ready to rock
![]()
So, let me understand this, you are creating a task performer that will allow llblgen to behave like codesmith?
Yes. . And you'll get the full sourcecode of it. I will use it for basic gui templates.
Otis wrote:
Cadmium wrote:
Otis wrote:
It's sort of a clone of codesmith. It uses the same principle: generate a class with code from a template, in memory, compile it in memory to an assembly and call the method you added to start the code with. Pretty simple
. I'm halfway through such a task performer, the parser is ready, I just have to add some preprocessor directives and the actual assembly compile code and it's ready to rock
![]()
So, let me understand this, you are creating a task performer that will allow llblgen to behave like codesmith?
Yes.
. And you'll get the full sourcecode of it. I will use it for basic gui templates.
Would you mine elaborating on this? Because my imagination is running wild as to what this_ could_ mean.
All right!
Almost there!
Generator config for test:
<generatorConfiguration>
<name>Lpt template tester config</name>
<description>Tests the new Lpt (C# based templates) engine.</description>
<vendor>Solutions Design</vendor>
<version>1.0.2004.1.100304</version>
<tasks>
<taskGroup description="Test generation group">
<task name="TestsDirectoryCreator" assemblyFilename="SD.LLBLGen.Pro.TaskPerformers.dll" taskPerformerClass="SD.LLBLGen.Pro.TaskPerformers.DirectoryCreator">
<parameter name="folderToCreate" value="TestClasses"/>
<parameter name="failWhenExistent" value="false"/>
<parameter name="clearWhenExistent" value="false"/>
</task>
<task name="TestsGenerator" assemblyFilename="SD.LLBLGen.Pro.LptParser.dll" taskPerformerClass="SD.LLBLGen.Pro.LptParser.CsTemplateEngine">
<parameter name="destinationFolder" value="TestClasses"/>
<parameter name="failWhenExistent" value="false"/>
<parameter name="filenameFormat" value="testclass.[extension]"/>
<parameter name="templateID" value="LPT_TestTemplate"/>
<parameter name="emitType" value="generic"/>
</task>
</taskGroup>
</tasks>
</generatorConfiguration>
Templateset config for test:
<templateSetDefinition>
<vendor>Solutions Design</vendor>
<name>Lpt Test template set</name>
<version>1.0.2004.1.100304</version>
<trueKeyword>true</trueKeyword>
<falseKeyword>false</falseKeyword>
<thisKeyword>this</thisKeyword>
<nullKeyword>null</nullKeyword>
<targetLanguageDescription>C#</targetLanguageDescription>
<fileExtension>cs</fileExtension>
<arrayIndexOperatorOpenChar>[</arrayIndexOperatorOpenChar>
<arrayIndexOperatorCloseChar>]</arrayIndexOperatorCloseChar>
<hasArrayIndexOperatorOnIdentifier>false</hasArrayIndexOperatorOnIdentifier>
<lineConcatenator></lineConcatenator>
<templateBindings>
<!-- test template bindings -->
<templateBinding templateID="LPT_TestTemplate" templateFilename="..\..\..\LptTemplates\testtemplate.lpt" />
<templateBinding templateID="LPT_TestTemplate2" templateFilename="..\..\..\LptTemplates\testtemplate2.lpt" />
</templateBindings>
</templateSetDefinition>
testtemplate.lpt (lpt is from LLBLGen Pro Template )
<$ C:\Myprojects\VS.NET Projects\LLBLGen Pro\RuntimeLibraries\DotNet11\SD.LLBLGen.Pro.ORMSupportClasses.NET11.dll $>
<[ System.IO ]>
<[ System.Text ]>
<[ SD.LLBLGen.Pro.ORMSupportClasses ]>
<# LPT_TestTemplate2 #>
//////////////////////
// this is testcode
// Project name: <%=_executingGenerator.ProjectDefinition.ProjectName%>
//////////////////////
using System;
public class Doh
{
public Doh()
{
<%
for(int i=0;i<10;i++)
{
%>
// Does: <%=WriteNonsense()%>
Console.WriteLine("lalala");
<%
}
%>
// some sense: <%= WriteSense()%>
<%
%>
}
}
<~
public string WriteNonsense()
{
return "Foo!";
}
~>
testtemplate2.lpt
<~
public string WriteSense()
{
return "Bar!";
}
~>
will be parsed / generated into this C# code:
using SD.LLBLGen.Pro.ORMSupportClasses;
using SD.LLBLGen.Pro.ApplicationCore;
using SD.LLBLGen.Pro.DBDriverCore;
using System;
using System.Collections;
using SD.LLBLGen.Pro.GeneratorCore;
using System.Text;
using SD.LLBLGen.Pro.LptParser;
using System.IO;
public class LPT_TestTemplate2 : ITemplateClass {
private StreamWriter __outputWriter;
private IGenerator _executingGenerator;
private Hashtable _parameters;
public LPT_TestTemplate2() {
__outputWriter=null;_executingGenerator=null;_parameters=null;
}
public string WriteSense()
{
return "Bar!";
}
private void __ScriptCode() {
}
public void ___RUN(IGenerator executingGenerator, Hashtable parameters, StreamWriter outputWriter) {
__outputWriter = outputWriter; _parameters = parameters; _executingGenerator=executingGenerator;
__ScriptCode();
}
}
public class LPT_TestTemplate : ITemplateClass {
private StreamWriter __outputWriter;
private IGenerator _executingGenerator;
private Hashtable _parameters;
public LPT_TestTemplate() {
__outputWriter=null;_executingGenerator=null;_parameters=null;
}
public string WriteSense()
{
return "Bar!";
}
public string WriteNonsense()
{
return "Foo!";
}
private void __ScriptCode() {
__outputWriter.Write("\n//////////////////////");
__outputWriter.Write("\n// this is testcode");
__outputWriter.Write("\n// Project name: ");
__outputWriter.Write(_executingGenerator.ProjectDefinition.ProjectName);
__outputWriter.Write("\n//////////////////////");
__outputWriter.Write("\nusing System;");
__outputWriter.Write("\npublic class Doh");
__outputWriter.Write("\n{");
__outputWriter.Write("\n public Doh() ");
__outputWriter.Write("\n {");
for(int i=0;i<10;i++)
{
__outputWriter.Write("\n // Does: ");
__outputWriter.Write(WriteNonsense());
__outputWriter.Write("\n Console.WriteLine(\"lalala\");");
__outputWriter.Write("\n ");
}
__outputWriter.Write("\n // some sense: ");
__outputWriter.Write( WriteSense());
__outputWriter.Write("\n ");
__outputWriter.Write("\n }");
__outputWriter.Write("\n}");
}
public void ___RUN(IGenerator executingGenerator, Hashtable parameters, StreamWriter outputWriter) {
__outputWriter = outputWriter; _parameters = parameters; _executingGenerator=executingGenerator;
__ScriptCode();
}
}
... which is then compiled into a library assembly and executed by the engine, which results into this code in the file testclass.cs:
//////////////////////
// this is testcode
// Project name: TestDB
//////////////////////
using System;
public class Doh
{
public Doh()
{
// Does: Foo!
Console.WriteLine("lalala");
// Does: Foo!
Console.WriteLine("lalala");
// Does: Foo!
Console.WriteLine("lalala");
// Does: Foo!
Console.WriteLine("lalala");
// Does: Foo!
Console.WriteLine("lalala");
// Does: Foo!
Console.WriteLine("lalala");
// Does: Foo!
Console.WriteLine("lalala");
// Does: Foo!
Console.WriteLine("lalala");
// Does: Foo!
Console.WriteLine("lalala");
// Does: Foo!
Console.WriteLine("lalala");
// some sense: Bar!
}
}
!! !!
Needless to say, I'm very happy . I hope to finalize the code on monday and upload a beta.
(there are more parameters thinkable for this, these will come up in the coming days I think when people start testing the bits )
Note: the syntaxis is as simple as 1 2 3 (beat that, codesmith!
)
<$ referenced assembly $> , for referencing additional assemblies
<[ referenced namespace ]> , for referencing namespaces (using ... )
<# include template id #> , for including (can be nested) other templates
<% C# code %> , non-output C# code.
<%= C# code %>, output C# code. Single statement, do not append a ';'
<~ C# code ~> , code block, used to specify member variables for the template class, methods to use etc. etc.
all <% %> code will be added to a single method, (as well as the literal text between %> and <% ) which is called by ___RUN(). ___RUN() is called by the engine to execute the template.
That's about it
bertcord wrote:
This looks awesome! Cant wait to check it out!
It is beyond what I expected
I'm not sure what I'll do with the language thing. I think it's best to make it a bit more generic and also support VB.NET as a template language. This is not hard to do: check the extension in the template set config and for 'cs' go the C# compiler route and for 'vb' go the VB.NET compiler route. Usage of the compiled code is the same
Otis wrote:
I will use it for basic gui templates.
What basic templates are you planning?
Just some basic gui stuff, entity editing forms for webapplications. But no plans are finalized yet.
I've made it more general so it now also supports VB.NET template code
<$ C:\Myprojects\VS.NET Projects\LLBLGen Pro\RuntimeLibraries\DotNet11\SD.LLBLGen.Pro.ORMSupportClasses.NET11.dll $>
<[ System.IO ]>
<[ System.Text ]>
<[ SD.LLBLGen.Pro.ORMSupportClasses ]>
<# LPT_TestTemplate2 #>
' //////////////////////
' // this is testcode
' // Project name: <%=_executingGenerator.ProjectDefinition.ProjectName%>
' //////////////////////
Imports System
Public Class Doh
Public Sub New()
<%
Dim i As Integer
For i=0 to 9
%>
' Does: <%=WriteNonsense()%>
Console.WriteLine("lalala")
<%
Next i
%>
' some sense: <%= WriteSense()%>
<%
%>
End Sub
End Class
<~
Public Function WriteNonsense() As String
Return "Foo!"
End Function
~>
output:
' //////////////////////
' // this is testcode
' // Project name: TestDB
' //////////////////////
Imports System
Public Class Doh
Public Sub New()
' Does: Foo!
Console.WriteLine("lalala")
' Does: Foo!
Console.WriteLine("lalala")
' Does: Foo!
Console.WriteLine("lalala")
' Does: Foo!
Console.WriteLine("lalala")
' Does: Foo!
Console.WriteLine("lalala")
' Does: Foo!
Console.WriteLine("lalala")
' Does: Foo!
Console.WriteLine("lalala")
' Does: Foo!
Console.WriteLine("lalala")
' Does: Foo!
Console.WriteLine("lalala")
' Does: Foo!
Console.WriteLine("lalala")
' some sense: Bar!
End Sub
End Class
That's great that it works using vb.net scripts.
I take it that we will have access to Entities and EntityCollections.
So, for example, a Lookup helper class could be generated which would create an Infragistic's ValueList object. Perhaps this would be done using the Custom Properties to identify which fields should be part of the valuelist. Would the be correct?
Would you have an IDE for this? Could you incorporate this within the llblgen IDE?
Thanks,
Fishy.
Fishy wrote:
That's great that it works using vb.net scripts.
It was 50 lines of code extra
I take it that we will have access to Entities and EntityCollections.
You have access to the IGenerator object, which has a reference to the project object, the tasks being executed, the template set... and you've access to the parameters passed to the task.
So, for example, a Lookup helper class could be generated which would create an Infragistic's ValueList object. Perhaps this would be done using the Custom Properties to identify which fields should be part of the valuelist. Would the be correct?
Yes, you could do that.
Would you have an IDE for this? Could you incorporate this within the llblgen IDE?
I'm thinking about it. Or at least a simple tool to find bugs in the template code. With the command line generator you can easily test if your templates contain errors, and a parameter can be set to write the generated template sourcecode to disk, so you can examine that as well. It's not a priority though.
Otis wrote:
I will use it for basic gui templates.
What basic templates are you planning?
Just some basic gui stuff, entity editing forms for webapplications. But no plans are finalized yet.
Just keep me in the loop of what you are planning becasue if you are planning on doing some ASP.net edit forums I am sure they will be better than what I got , and I will spend my time on other things like my server controls
Otis wrote:
You have access to the IGenerator object, which has a reference to the project object, the tasks being executed, the template set... and you've access to the parameters passed to the task.
very kewl, this will make the transition of my ASP.Net codesmith templete to LLBLGen easy (famous last words right? )
Otis wrote:
Fishy wrote:
Would you have an IDE for this? Could you incorporate this within the llblgen IDE?
I'm thinking about it. Or at least a simple tool to find bugs in the template code. With the command line generator you can easily test if your templates contain errors, and a parameter can be set to write the generated template sourcecode to disk, so you can examine that as well. It's not a priority though
I think this would be awesome, and without it (for me a least) make it difficult to develop templates. My style of development is what I call instant gratification, sometimes I will write a few lines and then want to see it work. Yeah yeah...I know that's not good, and I am sure Otis that you can write an entire program from start to finish...but not I...and since I do this mostly as a hobby then I do what makes me happy...
sooo anyhow have you seen this control http://www.actiprosoftware.com/Products/DotNet/SyntaxEditor/Default.aspx
Bert
bertcord wrote:
Otis wrote:
I will use it for basic gui templates.
What basic templates are you planning?
Just some basic gui stuff, entity editing forms for webapplications. But no plans are finalized yet.
Just keep me in the loop of what you are planning becasue if you are planning on doing some ASP.net edit forums I am sure they will be better than what I got
, and I will spend my time on other things like my server controls
Well, we're not the greatest in ASP.NET over here, but we'll give it a try. I have to say, the screenshots of your templates looked amazingly good.
Otis wrote:
You have access to the IGenerator object, which has a reference to the project object, the tasks being executed, the template set... and you've access to the parameters passed to the task.
very kewl, this will make the transition of my ASP.Net codesmith templete to LLBLGen easy (famous last words right?
)
It should be easy. Just remove the declaration crap at the top of your templates and replace it with easier statements, and the <script runat="template"> things can be changed to <~ and ~> And because it supports includes, you can create very powerful templates with not that much code
Otis wrote:
Fishy wrote:
Would you have an IDE for this? Could you incorporate this within the llblgen IDE?
I'm thinking about it. Or at least a simple tool to find bugs in the template code. With the command line generator you can easily test if your templates contain errors, and a parameter can be set to write the generated template sourcecode to disk, so you can examine that as well. It's not a priority though
I think this would be awesome, and without it (for me a least) make it difficult to develop templates. My style of development is what I call instant gratification, sometimes I will write a few lines and then want to see it work. Yeah yeah...I know that's not good, and I am sure Otis that you can write an entire program from start to finish...but not I...and since I do this mostly as a hobby then I do what makes me happy... sooo anyhow have you seen this control http://www.actiprosoftware.com/Products/DotNet/SyntaxEditor/Default.aspx
Yes I've seen that control, it looks promising .
What works best is that you first write out what you want to generate, then create a template for that. This saves a lot fo trial & error time. The commandline generator can help you out with finding errors/producing results for now, it's not a gui with tabs, but that can come
Btw, I've uploaded the beta to the Extras section. I've added a small example and a readme with information. I hope to fix an issue with combined templates in one template set tomorrow.
There is no separate forum for the beta yet. I'll add that now.
The forum is now up: http://www.llblgen.com/tinyforum/Threads.aspx?ForumID=19&SectionID=2