Search blog.co.uk

  • Enterprise Library Contrib v3.1 May 2009 Release

    This release of Enterprise Library Contrib is a final round up of all of the Microsoft patterns & practices Enterprise Library 3.1 core user contributions containing the following:

    Common extensions

    • TypeConfigurationElement<T> - Polymorphic Configuration Element without having to be part of a PolymorphicConfigurationElementCollection.
    • AnonymousConfigurationElement - Configuration element that can be uniquely identified without having to define its name explicitly.

    Data Access Application Block extensions

    • MySql Provider - MySql provider for the Data Access Application Block.
    • SQLite Provider - SQLite provider for the Data Access Application Block.
    • SqlEx Provider - This provider extends the SqlDatabase provider included in the Enterprise Library Data Access Application Block. It provides additional overloads for the UpdateDataSet method so that a collection of rows or a table can be passed to the DataAdapter for update. These methods were developed to support updating datasets that have multiple tables and cascading hierarchies.

    Exception Handling Application Block extensions

    • SqlException Wrap Handler - Exception handler that will wrap an SqlException with different exceptions based on the SQL Server error code.

    Logging Application Block extensions

    • LogParser - Combines the benefits of the Enterprise Library Logging Application Block with the ability to deserialize from a human readable log text file all LogEntry objects back. This enables sophisticated log filter capabilities with LINQ on normal log files (.NET 2.0 and Orcas samples) with very few lines of code. The Log parser now includes a TimeStamp parser.

    Policy Injection Application Block extensions

    • PostSharp4EntLib - Combines the benefits of the Enterprise Library Policy Injection and compile-time weaving by removing the limitations due to the use of remoting proxies.

    PIAB Matching Rules

    • And Matching Rule: Combines 2 Matching Rules and evaluates to "true" only if both of contained Matching Rules evalute to "true".
    • Or Matching Rule: Combines 2 Matching Rules and evaluates to "true" if either one of contained Matching Rules evalutes to "true"
    • Not Matching Rule: Contains another Matching Rules and evaluates to "true" if the contained Matching Rules evalutes to "false".

    PIAB Call Handlers

    • CursorCallHandler: Temporarily changes the cursor while the next handler is being processed.
    • OneWayCallHandler: Queues the call to the next handler on the ThreadPool
    • SynchronizedCallHandler: Uses ISynchronizeInvoke to invoke the next handler
    • ThreadSafeCallHandler: Synchronizes access to the next handler
    • TransactionScopeCallHandler: Wraps the next handler with a TransactionScope

    Resource Application Block

    • Resource Application Block 3.1 - A Full Application Block of configurable providers for Globalization and Localization

    Validation Application Block extensions
    Validators

    • CollectionCountValidator
    • CompositeRulesetValidator - Allows for composition of multiple rulesets
    • TypeValidator<T>
    • ObjectValidator<T>
    • EnumDefinedValidator

    Designtime enhancements

    • Lightweight type picker: An alternative type-picker that allows you to enter a typename in a text-box instead of using the tree-view.
    • Test command for Validation Rules: A dialog that allows to test and play around with validators inside the configuration console.

    Other extensions

    • Default Validators: The DefaultValidators class provides pre-allocated validators. Use them instead of instantiating new ones every time you need common validators.
    • ArgumentValidation: Validate pre/post conditions of method calls.
  • Resource Application Block v4.1 Launched

    This is an upgraded version of the Resource Application Block to go with the Enterprise Library v4.1 It was actually launched on April 21st 2009 but I have only just got around to blog about it as very few people visit this blog anyway. This version, whilst not as massive an upgrade as v3.1 was, incorporates all the new features of the Enterprise Library v4.1 including Unity v1.2 integration.

    I have now become a Co-Ordinator for the EntLib Contrib project on CodePlex and am working on releasing a final cut for the Enterprise Library v3.1 before upgrading the user contrib project to v4.1.

    Web Sample Windows Sample
    Message of the Day Web Page Message of the Day Viewer

    The Resource Application Block is all about resource management, localization and globalization. The Resource Application Block gives developers a provider model to get to resources from a variety of different sources and source types using the features of the Enterprise Library 4.1. All configuration of those resources naturally uses the Enterprise Library Configuration Console.

    ResourceApplicationBlock2

    Improvements made since v3.1
    In addition to porting to the Enterprise library v4.1 core the following improvements and new features have been added:

    • Unity v1.2 integration - now objects are created using the dependency injection block.
    • Custom Resource Manager - you can now create you own custom resource managers, using the new IResourceManager interface, as well as resource providers.
    • Partial Access support - RAB v4.1 now supports users with partial access.

    The source code can be downloaded from here and extracted from the EntLibContrib41Src branch

  • Resource Application Block v3.1 Launched

    Finally a version of the Resource Application Block for the Enterprise Library v3.1 is available. I have now become a developer contributor for the EntLib Contrib project on CodePlex

    Message of the Day Web Page

    The Resource Application Block is all about resource management, localization and globalization. The Resource Application Block gives developers a provider model to get to resources from a variety of different sources and source types using the features of the Enterprise Library 3.1. All configuration of those resources naturally uses the Enterprise Library Configuration Console.

    The developer is not limited to the providers out-of-the-box but can extend the block by adding providers of their own in the normal Enterprise Library extensible fashion.

    Main Features
    The following are the main features associated with the Resource Application Block:

    Greater flexibility to choose how you host your resources. With the Resource Application Block you can now choose whether to centralise or distribute resources, whether to leave resources in editable files rather than embed into assemblies, pull in resources from other projects and thus treat resources like reusable modules as per the Object Oriented paradigm,
    You can use either the stand-alone Enterprise Library Configuration Console or the Visual Studio integrated Console to manage all Resource Application Block settings.

    You have a choice of resource providers to manage resources from a variety of sources such as assembly embedded resources, xml resources (.resx files), binary resources (.resources files) and database resources (any DB you can get to from the Data Access Application Block).

    If you need to manage resources from a source type not currently supported then you can extend the application block by creating custom resource providers.

    You can generate strongly typed resource classes for any resource provider type directly from the Enterprise Library Configuration Console in either C# or VB.

    A web resource provider is included to enable the developer to use the Resource Application Block with the localization features provided within ASP.NET. This works for both local and global resources.

    All Resource Application Block managers are based on an extended ComponentResourceManager to enable reflection-style resource assignments to be made to Windows Forms component properties using the ApplyResources method within the ExtendedComponentResourceManager. Unfortunately, owing to the current closed nature of the Windows Forms designer CodeDomProvider model, with respect to localization, it has not been possible to extend the full Windows Forms localization feature, however see Windows Forms Designer for what you can do with the ExtendedComponentResourceManager.

    A resource provider presents the developer with an appropriate resource manager type. Each resource manager supported within the Resource Application Block is provided with a corresponding resource writer to enable editing of the various resource storage types using any IResourceWriter enabled resource editor. These resource writers also support the extended data node interface allowing for comments, file references and custom types to be stored (except for binary resource files that do not support comments).

    Management and monitoring features include Windows Active Directory Group Policy integration and instrumentation features such as Performance Counters, Windows EventLog logging and WMI events.

    Key Uses
    If you need convincing as to why you would use this block, have a look at the following reasons:

    You need to localize your application. The Resource Application Block gives you way more choices for managing localization than with standard means.

    You have a large number of resources spread between many files. The standard approach is to hold a set of resources for each assembly of an application. If you have a large number of assemblies in your application and you are supporting several different cultures then the number of resource files can be considerable, managing these files and managing translators and translations etc becomes a complex operation. You can use the Resource Application Block to centralise those resources or at least break them down into a manageable set. The database provider is an ideal choice when things start to get out of hand.

    You think you might need to manage some of your resources on-the-fly without having to re-compile and re-install assemblies each time. The Resource Application Block can provide resources directly from source files (e.g. .resx or .resources files) and does not hold those files open once read. This allows for on-the-fly changes to resource values e.g. spelling corrections, word replacement, change of colour etc.

    You may need to change from assembly embedded resources to a database as an application scales up. Because all resource storage types are managed through configuration it makes it very easy to swap from one storage type to another.

    A Quick Code Sample
    The following code sample shows the basic function of the block, how to get the default resource manager and use its resources. Note that an indexer is used, based on a string key and an optional type (string is the default) to get at the resources. The standard GetString(), GetObject() and GetStream() methods are still available however:

    [C#]

    // get the default resource manager. Note: this is an
    //EntLibContrib.Resource.ResourceManager NOT System.Resources.ResourceManager
    ResourceManager rm = ResourceFactory.GetResourceManager();
    // get a string resource
    string myString = rm["StringKey"];
    // get an integer resource, this works for any type of resource
    int myInt = (int)rm["IntegerKey", typeof(int)];
    // get an audio resource, you would normally need to use the GetStream()
    // method for this type of resource.
    UnManagedMemoryStream myAudio = (UnManagedMemoryStream)rm["AudioKey", typeof(UnManagedMemoryStream)];

    This next code sample shows how to get a named resource manager instance, set a specific culture and also how do do string formatting using the optional params parameter of the indexer:

    [C#]

    // get the named instance resource manager, this is the name you have given
    // the configured resource manager in the console.
    ResourceManager rm = ResourceFactory.GetResourceManager("named instance");
    // set the culture to generic french.
    rm.CultureInfo = new CultureInfo("fr");
    // get a formatted string resource and format the string
    string friendlyResponse = "bonjour";
    string myFormattedString = rm["FriendlyMessageKey", friendlyResponse];

    If the resource value is something like "mon ami dit {0}" then myFormattedString will contain "mon ami dit bonjour". Note: you can have more than one replaceable format string parameter in the same fashion as String.Format().

    Installing the Assemblies
    When you build the Resource Application Block the assemblies are compiled without a strong name key. If you want to put these assemblies into the GAC then you will need to assign a strong name key to each assembly and recompile (this is not neccessary for any design.dll assembly). If you use the BuildLibraryAndCopyAssemblies.bat console script then the assemblies are copied to the EntLibContrib bin folder. You can reference the assemblies from here for your application however; to use the Configuration console you will need to copy all of the following assemblies to your installation of the Enterprise Library Configuration Console which is usually in C:\Program Files\Microsoft Enterprise Library 3.1 - May 2007\Bin:

    The Resource Application Block 3.1 consists of the following assemblies:

    EntLibContrib.Resource.dll - the main assembly for the block
    EntLibContrib.Resource.Store.dll - the Resource Application Block uses itself to supply its own resources. These are held in this resource only assembly.
    EntLibContrib,Resource.Database.dll - to comply with the rule that all application blocks must be able to work independantly of any other block, the data resource manager and provider, which has a dependancy on the Data Access Application Block was separated out to its own assembly.
    EntLibContrib,Resource.Configuration.Design.dll - the plug-in interface to the Enterprise Library Configuration Console for the Resource Application Block.
    EntLibContrib,Resource.Database.Configuration.Design.dll - the plug-in interface to the Enterprise Library Configuration Console for the Resource Application Block data provider.

    For full documentation and to download the source code go here

  • Resource Application Block v2.0 Updated

    Hi Folks,

    I have finally fixed the irritating little performance counters problem. It was found in the InternalResourceProvider in the end. RAB no longer needs instrumentation to be installed in order to use it. In addition to this fix I have improved the installer so that it will now optionally build the block and move dll's to their proper places during the install if you wish. The outcome of this is that as soon as the installer has finished you should be able to go straight to the Enterprise Library Configuration tool and start using the RAB straight away.

    One last little extra is that now I am using VS2005 Team Services I have added the VSTS unit tests to the source code.

    To get the latest version go to: GotDotNet User Samples - Resource Application Block v2.0

  • Resource Application Block v2.0

    I have at last completed my rewrite of the Resource Application Block for the Enterprise Library v2.0 it is the update of the application block for managing localized resources and fully integrates with Enterprise Library v2.0 – January 2006.
    ResourceApplicationBlock2
    This block provides a simple interface for a developer to use resources of any type (not just strings) without needing to know where the resources come from. An application can use a single centralised or multiple resources from assemblies, binary files and now a Database, even from a shared store across a network. You can extend the block with Resource Providers of your own and there is an Internal Resource Provider for the Enterprise library itself. New to v2.0 is the inclusion of a Data Resource Provider to allow the use of a Database as a Resource Store. Also, in addition to integrating with Configuration Source from the Enterprise Library – Jan 2006, there is the inclusion of instrumentation so that you can keep track of Resource activity.

    Download
    To get the download go to GotDotNet User Samples - Resource Application Block v2.0. The installer will work exactly the same way as the Enterprise Library installer and once you have built and copied the assemblies and installed the instrumentation you will be able to use the Block straight away.

  • Resource Application Block v1.1 Errata

    Just as soon as I get the block uploaded so I spot a mistake. I have corrected the mistake and posted an updated version (this could take 3 days to appear), however, for those of you that are keen and have already downloaded the block there are two dodgy references that break when not loaded on my computer.

    If you load the solution for the block into Visual Studio and go to the Resource project and expand the references you will find a reference to Ewdev.EnterpriseLibrary.Resource.Store. remove this reference and add a reference to Resource.Store. Now go into the Resource.Tests project and remove the reference to Interop.MSDASC and re-add it making sure you get it from your copy of the Enterprise Library June 2005 version.

    When you have done this everything should compile and you can use the quick "Build Assemblies" menu option. When you use the "Copy Assemblies to bin Folder" option the assemblies are copied to acommon bin folder AND to your Enterprise Library June 2005 common bin folder. The Configuration Console will pick up the new block automatically.

    If the block does NOT appear in the Configuration Console it is most likely to be because you have a copy of the enterprise library January version lying around. Make sure the Resource Application Block is referencing the June 2005 enterprise library dll's. Who said dll hell was a thing of the past????

  • Resource Application Block v1.1

    Today I uploaded the Enterprise Library Resource Application Block v1.1 to the Microsoft GotDotNet web site

    Resource Application Block v1.1 is an application block for managing localized resources and integrates with Enterprise Library v1.1. This block provides a simple interface for a developer to use resources of any type (not just strings) without needing to know where the resources come from. An application can use multiple resources from assemblies and binary files, even from a shared store across a network. You can extend the block with Resource Providers of your own and there is even an Internal Resource Provider for the Enterprise library itself instead of using SR.strings.

    Included in the download is a QuickStart sample called MessageOfTheDay. This is a simple multi-lingual message of the day viewer to demonstrate the use of the Resource Application Block.

    Message of the Day Viewer

    What Next?

    If this block sparks any interest then I will add some Instrumentation and a Database Resource Provider to enable resources to be stored on a SQL database.... and if anyone is still interested then I shall work on a .NET v2.0 version.

Footer:

The content of this website belongs to a private person, blog.co.uk is not responsible for the content of this website.