in

CodeSmith Community

Your Code. Your Way. Faster!

Robert Hinojosa

  • Give instant generation feedback with the ProgressBar

    One of the easiest ways to show instant template feedback for long running templates is by using the Progress Bar that the CodeSmith Engine API provides. If you've ever used the Progress control in Winforms you'll find this control very similar in usage and very easy to use.

    The progress bar is meant to be a way to show a series of steps during the generation process. This lets the user know how long the generation process will take relative to the steps which have already been completed.  To access and configure the progress bar, there is a property exposed from the CodeTemplate class called Progress, so you will easily be able to apply this to any new or existing template. Typing this.Progress from anywhere in your templates will give you access to configure the Progress class.

    The important properties and methods from the Progress class are:
    • MaximumValue = The maximum value that the series can step to. Once the steps have counted to this value the progress bar will be full.
    • Step = This is the increment value you want to perform each step. This is most commonly 1, since each step should be for a unit of work.
    • Value = This is the current value of the progress bar.
    • PerformStep() = This method triggers a step to be processed.

    Example:

    Let's say we want to run through all of the tables in the Database and for this example, we're going to generate against the table's meta-data information. 

    Steps

    1. OnInit of the template Setup the Progress Bar
    2. Progress' MaximumValue  with the amount of tables found in the database.
    3. Set the Step = 1, since we will be processing each table individually.
    4. During the generation process, after each unit of work, call PerformStep().


     

    Result:

    The result is that as the generation progress is occurring from CodeSmith Studio or Windows Explorer, the progress bar will be shown to give instant feedback to the user.

     

  • Tips & Tricks: ActiveSnippets

    CodeSmith 4.0 delivers strong integration within Visual Studio and ActiveSnippets are a driver toward increasing developer productivity. ActiveSnippets, at a high level, are CodeSmith templates with exposure to the entire .Net Framework which you can utilize with a few keystrokes inside of Visual Studio 2005. The output of your ActiveSnippet will be rendered right where you invoke the ActiveSnippet.

    ActiveSnippet Features:

    • You have access to the entire .Net Framework, SchemaExplorer, XmlProperty, Custom Assemblies, or another rich meta-data source.
    • Complex Objects such as an XmlProperty and SchemaExplorer types can exist as properties in your CodeSmith Template, and can be used as arguments to an ActiveSnippet.
    • An ActiveSnippet can be configured inside Visual Studio for any valid existing CodeSmith Template.
    • Use CTRL + E, CTRL+ E to expand an ActiveSnippet alias or to view all ActiveSnippets Configured.
    • Use CTRL + E, CTRL + R to view usage information for a particular ActiveSnippet.
    • Sample Table Data Enumeration Template found in the video.

    Watch a 5 minute video on ActiveSnippets

  • CodeSmith and DevConnections

    Looks like Eric is getting so anxious about CodeSmith Tool's presence at Dev Connections, he decided to give away money,  just to seal the deal and  CodeSmith, Vegas Style!!!  Yes, I used CodeSmith as a verb, if you haven't tried it, I highly recommend it. Let's see, I learned this one in grade school: CodeSmith Tools + Surprises + $ 5,000 + Dev Connections + Vegas + Vegas ============= House Money & Then Some! Start playing with the house's...(read more)
  • Codesmith Rocks!!!

    Ok, yes, I work for Codesmith!  Let's put that aside for a second, since i've been a huge Codesmith fan long before I became a proud Codesmith Employee, that's what makes my job that much better, because I truly believe in this product 110%!It's soo easy to use codesmith that quite honestly, if you're not having Codesmith generate at least 25% of your work, in the future, i'm certain you will wake up one day and realize how much time you could have saved and think of me, ok, maybe not me, but...(read more)
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems