示例#1
0
        private ComponentCacheEntry CreateComponent(ContractIdentity contract, IEnumerable <ICompositionListener> listenerChain)
        {
            // Prepare the constructor information for instantiating the object.

            var constructorArguments = PrepareConstructorArguments();
            var targetConstructor    = FindTargetConstructor(constructorArguments);

            // Save the original component instance reference, so that
            // we can apply initialization points to it later, as the
            // composition listeners may change the reference to a
            // wrapped one.

            object originalComponentInstance = targetConstructor.Invoke(constructorArguments.ToArray());

            // After constructing the component object, first process
            // all composition listeners so that if the reference should
            // change, it changes before setting it to the cache.
            // Otherwise, in circular dependency scenarios, dependent
            // components may get unwrapped component where the component
            // is wrapped by composition listeners.

            object componentInstance = NotifyCreated(originalComponentInstance, contract, listenerChain);

            // Store the cache, so that if there is a circular dependency,
            // applying initialization points is not blocked and chained
            // recursively.

            var result = new ComponentCacheEntry
            {
                ComponentInstance         = componentInstance,
                OriginalComponentInstance = originalComponentInstance
            };

            _componentCache?.PutInCache(contract, result);

            // Complete the object initialization by applying the initialization
            // points. They should be applied to the original component instance,
            // as the reference may have been changed by composition listeners to
            // an instance that does not have the original configuration points.

            var initializationPointResults = ApplyInitializationPoints(originalComponentInstance);

            // Inform all composition listeners of the newly composed
            // component instance by calling OnComponentComposed method.

            NotifyComposed(componentInstance, originalComponentInstance, initializationPointResults, contract, listenerChain);

            // The composition is now finished for the component instance.
            // See if an [OnCompositionComplete] method is specified, call it.
            // This should be called on the original component instance
            // for the same reason stated above.

            InvokeCompositionNotifications(componentInstance);
            return(result);
        }
 public void PutInCache(ContractIdentity contract, ComponentCacheEntry entry)
 {
     _cacheContent[contract] = entry;
 }
示例#3
0
 public void PutInCache(ContractIdentity contract, ComponentCacheEntry entry)
 {
     HttpContext.Current.Items[contract] = entry;
 }
 public void PutInCache(ContractIdentity contract, ComponentCacheEntry entry)
 {
     GetCacheDictionary(OwinRequestScopeContext.Current)[contract] = entry;
 }
        public void PutInCache(ContractIdentity contract, ComponentCacheEntry entry)
        {
            var contractString = GetContractString(contract);

            HttpContext.Current.Session[contractString] = entry;
        }
示例#6
0
 public void PutInCache(ContractIdentity contract, ComponentCacheEntry entry)
 {
     HttpContext.Current.Application.Set(GetIdentityString(contract), entry);
 }