Documentation

Ucommerce includes full API reference documentation and lots of helpful articles to help you build your e-commerce site as effortlessly as possible.

Topics Payment Providers
v7.18

Regestering a service in Ucommerce

And when you're extending Ucommerce in various ways, you often need to register a component whether it is a pipeline task, a payment method service or any other type that are extendable in Ucommerce. We use Castle Windsor and resolves services that can be registered. You can also append your own services - our container doesn't care at all. It just works. However to do so, you must follow a few basic principles.

General regestering a component

When you register a service, you do it in XML. And when you do so you need to specify 3 things:

  • An Id of your component
  • The service that your component is
  • The specific type that your component is

Also namespaces and assemblies must be specified. (If you base a component from a redirected assembly, version numbers to the assembly must also be specified). Last but not least, you need to register it under Custom.config to aviod us overriding your services when/if you're upgrading to a newer version of Ucommerce.

When registering a component, use the following format:

image

The above example is a regestering of our default PricingService. The service is registered under the Id "PriceService", which can be used to get the exact implementation of the service it is registered under, if you need to do so. More about that later.

It's based on the Interface IPricingService, which is an interface created in the assembly UCommerce, found under the namespace UCommerce.Catalog.

The implementation of the the service - interface if you will, is PricingService, which is found under the assembly UCommerce, found under the namespace UCommerce.Catalog.

Overriding a default component

When you need to override specific services, you must register your overrides by Id. Hence when you need to do custom logic in The transactionLibrary, you need to use the allready registered Id for TransactionLibrary - which in this case is TransactionLibraryInternal. You must also use TransactionLibraryInternal as the service. All registered types can be found under Ucommerce/Configuration.

Getting and using registered services

I bet you're the man, known to locate certain things from time to time.
And when you need to use any given service in Ucommerce, you need to resolve them from the container - either by Id for an exact implementation of a service or by service/interface for any given implementaion. You can also get a list of all implementation of a specific service/interface.

Fetching services is possible by using the static Methods on ObjectFactory. To use it, you need to reference UCommerce.Infrastructure in your solution.

    
    
    ObjectFactory.Instance
    	.Resolve<T>()
    	.Resolve<T>(id)
    	.ResolveAll<T>()
    	.RegisteredServicesFor<T>()