|
Project Information
|
note: these documented changes are for the next pending release this month. IntroductionBCL Contrib-Abstract strives to provide standard interfaces or contracts for common services typicality re-implemented in various projects/assemblies. Utilizing a standards based type allows services to flow between otherwise disconnected assemblies. Coherence is achieved by a reduction of a service's members to only those base enough to be common across multiple service implementations. Implementation specific extensions to the base interfaces enable access to the uncommon methods. A simple example of this would be the COM implementation of the IUnknown interface, containing the AddRef, QueryInterface and Release methods. IUnknown provides a common type that all COM systems are aware of, allowing COM services to flow between various COM aware systems. A COM system would then be queried using the QueryInterface method to get the specific implementation requested. Of course with .Net, simple casting is all that is necessary to move from a common IServiceLocator to a Unity specific IUnityServiceLocator. For greater adaptation and ease of use, implementations for some of the more common abstracted systems are included as multiple assemblies to optionally chose from. Unit tests are held in a separate project: http://code.google.com/p/bclcontrib-tests/ NuGetNuGet Packages:
Abstracters for common systems
Abstracters implemented in BclContrib-Abstract
SystemsSomething about these systems. Event Sourcing :: Events as a Storage Mechanismabstracts an event sourcing system http://cqrsinfo.com/documents/events-as-storage-mechanism/.
// example event
public class MyEvent : Event { }
// example aggregate-root
public class MyAggregate : AggregateRoot
{
// method exposed to the domain
public void DoMethod() { ApplyEvent(new MyEvent()); }
// apply the event
private void Handle(MyEvent e) { }
}var aggregateRoot = new AggregateRootRepository(new SqlEventStore("connectionString"), new SqlAggregateRootSnapshotStore("connectionString"));var myAggregate = aggregateRoot.GetById<MyAggregate>("ID");
myAggregate.DoMethod();
if (myAggregate.HasChanged)
aggregateRoot.Save(myAggregate);Service Bus :: Enterprise service busabstracts an enterprise service bus pattern http://en.wikipedia.org/wiki/Enterprise_service_bus.
ServiceBusManager.SetProvider(() => new ApplicationServiceBus());
from a singleton: public class MyServiceHandler : IServiceMessageHandler<MyService>
{
public void Handle(MyService message)
{
// DO WORK
}
}Service Locator :: Service locator patternabstracts a service locator pattern http://en.wikipedia.org/wiki/Service_locator_pattern along the lines of Inversion of Control (IOC) http://en.wikipedia.org/wiki/Inversion_of_control.
ServiceLocatorManager.SetProvider(() => new UnityServiceLocator());
from an assembly type scan during creation:ServiceLocatorManager.SetProvider(() => new UnityServiceLocator()) .RegisterByNamingConvention();place registration in a service locator:ServiceLocatorManager.SetProvider(() => new UnityServiceLocator()) .RegisterByNamingConvention() .RegisterWithServiceLocator();from an injected dependency:
from a singleton:var myService = ServiceLocator.Resolve<IMyService>();from an injected dependency: Service Cacheabstracts cache algorithms implementations http://en.wikipedia.org/wiki/Cache_algorithms.
ServiceCacheManager.SetProvider(() => new WebServiceCache());
from a singleton: Service Logabstracts logging implementations.
ServiceLogManager.SetProvider(() => new Log4NetServiceLog());
from a singleton:TBDfrom an injected dependency: |