Tuesday, June 10, 2014

Managed Extensibility Framework

Managed Extensibility Framework:
Three core concepts with MEF:
1)      Export(s) : It exposes Contracts and contract like .NET Interface or Class or property
Code:
[Export(typeof(ICache))]
Public class Caching: ICache
{
               Public object Get(string cache_key)
{
               //Caching implementation
}
}
2)      Imports: Used to consume exported instances.
Code:
[Import()]
Private ICache cache;
3)      Catalog: hosts components that need to be composed.
Code:
Public static void Compose(object o)
{
               var container = new CompositionContainer(
                                             new DirectoryCatalog(Path.Combine(
AppDomain.CurrentDomain.BaseDirectory,
@”bin\MEFBin”)));
                              Var batch = new CompostionBatch();
batch.AddPart(o);
               container.Compose(batch);

}

Monday, June 9, 2014

Application Design - Layered Architecture

 Layered Architecture:
           1)      Presentation Layer - User Interface of application
           2)      Business Logic Layer – Rules of application
           3)      Data Access Layer – Responsible for connecting to data source and interacting with data that is stored in that location.
e.g. database, some XML files, text files or web service.  
4)   Utility /Components Layer – Mechanism of caching, logging errors, reading from configuration files.
Create independent project called Component layer   

           a)      Presentation layer – Web
           b)      Business layer – entities, business logic, components, interfaces
           c)      Data Layer – Entities, Data Access
           d)      Components Layer – Caching, logging, Configuration