Пример #1
0
        /// <summary>
        /// Get Entry
        /// </summary>
        /// <param name="entryType"></param>
        /// <returns></returns>
        public ProxyEntryDao GetDaoEntry(Type entryType)
        {
            var lKey             = entryType.Assembly.FullName;
            ProxyAssemblyDao pxa = null;

            //Controlla presenza
            if (!this.mCacheDao.TryGetValue(lKey, out pxa))
            {
                //Lock Scrittura
                lock (this.mCacheDao.WriteLock)
                {
                    //Ricontrolla
                    if (!this.mCacheDao.TryGetValue(lKey, out pxa))
                    {
                        //Invia evento
                        pxa = new ProxyAssemblyDao()
                        {
                            Key            = lKey,
                            SrcAss         = entryType.Assembly,
                            TypeDaoEntries = new ProxyEntryDaoDic(100),
                        };

                        //Avvia evento
                        ProxyTypeBuilder.BuildDaoProxyFromAssembly(pxa);

                        //Rigenera nuovo elenco Proxy
                        var newCache = new ProxyAssemblyDaoDiz(this.mCacheDao);
                        newCache.Add(lKey, pxa);

                        //Rigenera nuovo elenco Resolvers
                        Dictionary <string, string> newResolver = new Dictionary <string, string>(this.mResolver);
                        newResolver.Add(pxa.DynAss.FullName, lKey);

                        //Assegnazione
                        this.mCacheDao = newCache;
                        this.mResolver = newResolver;
                    }
                }
            }

            //Ritorna entry
            return(pxa.TypeDaoEntries[entryType.TypeHandle.Value.ToInt64()]);
        }
Пример #2
0
        public ProxyEntryBiz GetBizEntry(Type tBiz)
        {
            long             lKey = tBiz.Assembly.ManifestModule.MetadataToken;
            ProxyAssemblyBiz pxa  = null;

            //Controlla presenza
            if (!this.mCacheBiz.TryGetValue(lKey, out pxa))
            {
                //Lock Scrittura
                lock (this.mCacheBiz.WriteLock)
                {
                    //Ricontrolla
                    if (!this.mCacheBiz.TryGetValue(lKey, out pxa))
                    {
                        //Invia evento
                        pxa = new ProxyAssemblyBiz()
                        {
                            Key            = lKey,
                            SrcAss         = tBiz.Assembly,
                            TypeBizEntries = new ProxyEntryBizDic(30)
                        };

                        //Avvia evento
                        ProxyTypeBuilder.BuildBizProxyFromAssembly(pxa);

                        //Rigenera nuovo elenco Proxy
                        var newCache = new ProxyAssemblyBizDiz(this.mCacheBiz);
                        newCache.Add(lKey, pxa);

                        //Assegnazione
                        this.mCacheBiz = newCache;
                    }
                }
            }

            //Ritorna entry
            return(pxa.TypeBizEntries[tBiz.TypeHandle.Value.ToInt64()]);
        }