Spring.Objects.Factory.Config.SharedStateAwareProcessor.PostProcessBeforeInitialization C# (CSharp) Method

PostProcessBeforeInitialization() public method

Iterates over configured list of ISharedStateFactorys until the first provider is found that
a) true == provider.CanProvideState( instance, name )
b) null != provider.GetSharedState( instance, name )
public PostProcessBeforeInitialization ( object instance, string name ) : object
instance object
name string
return object
        public object PostProcessBeforeInitialization( object instance, string name )
        {
            if (SharedStateFactories.Length == 0)
            {
                return instance;
            }

            ISharedStateAware ssa = instance as ISharedStateAware;
            if (ssa != null && ssa.SharedState == null)
            {
                // probe for first factory willing to serve shared state
                foreach (ISharedStateFactory ssf in _sharedStateFactories)
                {
                    if (ssf.CanProvideState( ssa, name ))
                    {
                        IDictionary sharedState = ssf.GetSharedStateFor( ssa, name );
                        if (sharedState != null)
                        {
                            ssa.SharedState = sharedState;
                            break;
                        }
                    }
                }
            }
            return instance;
        }

Usage Example

        public void BeforeInitializationIsNoOp()
        {
            SharedStateAwareProcessor ssap = new SharedStateAwareProcessor();
            object res = ssap.PostProcessBeforeInitialization(this, null);

            Assert.AreSame(this, res);
        }
All Usage Examples Of Spring.Objects.Factory.Config.SharedStateAwareProcessor::PostProcessBeforeInitialization