Custom Application Block

Topics: Building and extending application blocks, General discussion
Jul 19, 2008 at 9:43 PM
I am thinking about creating a custom application block called Object Pool Application Block.  I was reading through Enterprise Library 4.0 help and I don't see anything about creating a Custom Application Block.  I did however find  Brian's Animal Application Block example at http://weblogs.asp.net/adalon/archive/2007/02/22/howto-application-block-software-factory-absf-part-i.aspx.  Does anyone know if the architecture of creating a Custom Application Block has changed at all?  Also, in general how difficult is it creating a custom application block?

Thanks
Jul 21, 2008 at 12:10 PM
Hi,

The architecture hasn't changed, you should be able to use previous samples with only minimal changes.

Creating a new block is not very hard, as long as your block matches the configuration-driven provider architecture; there are a few pieces that must be kept in sync but they are covered in Brian's examples. Creating blocks that depart from this architecture, like EntLib's PIAB and VAB, requires additional effort.

Fernando


mastrauckas wrote:
I am thinking about creating a custom application block called Object Pool Application Block.  I was reading through Enterprise Library 4.0 help and I don't see anything about creating a Custom Application Block.  I did however find  Brian's Animal Application Block example at http://weblogs.asp.net/adalon/archive/2007/02/22/howto-application-block-software-factory-absf-part-i.aspx.  Does anyone know if the architecture of creating a Custom Application Block has changed at all?  Also, in general how difficult is it creating a custom application block?

Thanks



Jan 2, 2009 at 3:38 PM
Hello people,
I think the application block software factory is a beautiful software. I had this idea to use it to build a sequencing application block.
Why? I needed to generate sequences of numbers for entities. e.g. account numbers, etc. This numbers would need to be generated before the entity hits the database and would be generated from a source shared by multiple instances of a system such as in a server farm or from different deployments - eg. windows forms, web application etc.
I also needed to be able to combine different sequences to get a sort of composite sequence.

I have started this and would like to put it up as a project here on codeplex.
However, I have a problem with the defaultInstance configuration property. i.e. I've been able to get the entlibconfig tool to display a default sequence provider instance node for the sequencer settings node but this doesn't persist/read to/from the configuration file.

P.S. Does anyone know how one can store configuration in say, sql server . perhaps with like an implemenation of a configuration source.

Thanks for any help. + pointers
Jan 5, 2009 at 7:03 AM
You can use the SqlConfigurationSource if you want to store config in a database.  I haven't tried creating a custom application block but feel free to send your code so I can investigate.

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Jan 7, 2009 at 7:59 AM
@Sarah.
Thanks for the tip on the sqlconfiguration source. After a closer look I found more info @ http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=17125
Plus it's part of the quickstarts. I didn't know that.
I will try it out but It appears the version in the quickstart was built against the unsigned enterprise library binaries.  Recompiling with the unsigned binaries should fix this.

Anyway, I have put the code for the  sequencing application block @ www.codeplex.com/sequencingblock.

Feel free to review. Thanks.
Cheers
Jan 8, 2009 at 1:13 AM
Edited Jan 8, 2009 at 1:47 AM
I'm currently looking into this. I'll let you know what I can find out.  You can also try checking out these screencasts..
http://www.codeplex.com/entlib/Wiki/View.aspx?title=Videos

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Jan 13, 2009 at 1:10 AM
Hi, sorry for the late reply.  I had trouble setting up the environment for 3.1 in order to use ABSF since I'm already using VS2008, etc.  The designer was able to save the changes you made.  However, there are types that looks like they are not being read from the configuration file when opening in the designer.  It's only the cache manager and the default sequence provider type which are not being read from the config file. We might be missing an extra step when using reference types.  I'm not sure yet what that could be, it's my first time to create an application block.  I'm still trying to find out more, there's not that much documentation or discussion about this topic, but I'll let you know. 


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Jan 22, 2009 at 12:31 PM
I was now able to figure this out.  Sorry for the late reply but I figured out this still might help you as I didn't see any update to the solution you posted here in codeplex.  You have to add the following lines to the OpenCore method of the ConfigurationDesignManager class.

foreach (NumericSequenceProviderNode node in hierarchy.FindNodesByType(typeof(NumericSequenceProviderNode)))
{
    
foreach (CacheManagerNode cacheNode in hierarchy.FindNodesByType(typeof(CacheManagerNode)))
    {
        
if (cacheNode.Name == ((NumericSequenceProviderData)node.SequenceProviderData).cacheManager
        {
            node.CacheManager = cacheNode;
        }
    }
}

 


It's basically looking up every cachemanager node defined in your configuration file and selecting the one which match the cache manager name of your numericsequenceprovidernode.  Implement the same logic for other values that are not being read from the configuration file to the editor.  Check out the EntLib source code and you can see some of the design manager class doing the same thing.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com