/// <summary>
        /// Get the specified persister type
        /// </summary>
        public IAdoPersistenceService GetPersister(Type tDomain)
        {
            IAdoPersistenceService retVal = null;

            if (!this.m_persistenceCache.TryGetValue(tDomain, out retVal))
            {
                // Scan type heirarchy as well
                var sDomain = tDomain;
                var idpType = typeof(IDataPersistenceService <>).MakeGenericType(sDomain);
                retVal = ApplicationServiceContext.Current.GetService(idpType) as IAdoPersistenceService;
                while (retVal == null && sDomain != typeof(object))
                {
                    idpType = typeof(IDataPersistenceService <>).MakeGenericType(sDomain);
                    retVal  = ApplicationServiceContext.Current.GetService(idpType) as IAdoPersistenceService;
                    sDomain = sDomain.BaseType;
                }

                if (retVal != null)
                {
                    lock (this.m_persistenceCache)
                        if (!this.m_persistenceCache.ContainsKey(tDomain))
                        {
                            this.m_persistenceCache.Add(tDomain, retVal);
                        }
                }
            }
            return(retVal);
        }
Example #2
0
        /// <summary>
        /// Get persister for the specified type
        /// </summary>
        internal static IAdoPersistenceService GetPersister(Type type)
        {
            IAdoPersistenceService retVal = null;

            if (!s_persistenceCache.TryGetValue(type, out retVal))
            {
                var idt = typeof(IDataPersistenceService <>).MakeGenericType(type);
                retVal = ApplicationServiceContext.Current.GetService(idt) as IAdoPersistenceService;
                if (retVal != null)
                {
                    lock (s_persistenceCache)
                        if (!s_persistenceCache.ContainsKey(type))
                        {
                            s_persistenceCache.Add(type, retVal);
                        }
                }
            }
            return(retVal);
        }