public AbstractAccessor GetAccessorType(Type type, IPropertyInfo property) { WeakReference accessorR = typeToAccessorMap.Get(type, property.Name); AbstractAccessor accessor = accessorR != null ? (AbstractAccessor)accessorR.Target : null; if (accessor != null) { return(accessor); } Object writeLock = this.writeLock; lock (writeLock) { // concurrent thread might have been faster accessorR = typeToAccessorMap.Get(type, property.Name); accessor = accessorR != null ? (AbstractAccessor)accessorR.Target : null; if (accessor != null) { return(accessor); } Type enhancedType = GetAccessorTypeIntern(type, property); if (enhancedType == typeof(AbstractAccessor)) { throw new Exception("Must never happen. No enhancement for " + typeof(AbstractAccessor) + " has been done"); } ConstructorInfo constructor = enhancedType.GetConstructor(new Type[] { typeof(Type), typeof(String) }); accessor = (AbstractAccessor)constructor.Invoke(new Object[] { type, property }); typeToAccessorMap.Put(type, property.Name, new WeakReference(accessor)); return(accessor); } }
public Type GetType(String name, String namespaceString) { ParamChecker.AssertParamNotNull(name, "name"); if (namespaceString == null) { namespaceString = String.Empty; } XmlTypeKey xmlTypeKey = new XmlTypeKey(); xmlTypeKey.Name = name; xmlTypeKey.Namespace = namespaceString; readLock.Lock(); try { Type type = xmlTypeToClassMap.Get(name, namespaceString); if (type == null) { if (Log.DebugEnabled) { LoggerHistory.DebugOnce(Log, this, "XmlTypeNotFound: name=" + name + ", namespace=" + namespaceString); } return(null); } return(type); } finally { readLock.Unlock(); } }
public ICacheMapEntryFactory GetCacheMapEntryType(Type entityType, sbyte idIndex) { if (BytecodeEnhancer == null) { return(ci); } ICacheMapEntryFactory factory = typeToConstructorMap.Get(entityType, idIndex); if (factory != null) { return(factory); } Lock writeLock = this.writeLock; writeLock.Lock(); try { // concurrent thread might have been faster factory = typeToConstructorMap.Get(entityType, idIndex); if (factory != null) { return(factory); } try { Type enhancedType = BytecodeEnhancer.GetEnhancedType(typeof(CacheMapEntry), new CacheMapEntryEnhancementHint(entityType, idIndex)); if (enhancedType == typeof(CacheMapEntry)) { // Nothing has been enhanced factory = ci; } else { factory = AccessorTypeProvider.GetConstructorType <ICacheMapEntryFactory>(enhancedType); } } catch (Exception e) { if (Log.WarnEnabled) { Log.Warn(e); } // something serious happened during enhancement: continue with a fallback factory = ci; } typeToConstructorMap.Put(entityType, idIndex, factory); return(factory); } finally { writeLock.Unlock(); } }
public override ObjRefStore CreateObjRefStore(Type entityType, sbyte idIndex, Object id) { IObjRefStoreFactory objRefConstructorDelegate = constructorDelegateMap.Get(entityType, idIndex); if (objRefConstructorDelegate == null) { objRefConstructorDelegate = BuildDelegate(entityType, idIndex); } ObjRefStore objRefStore = objRefConstructorDelegate.CreateObjRef(); objRefStore.Id = id; return(objRefStore); }
public IGarbageProxyConstructor <T> CreateGarbageProxyConstructor <T>(params Type[] additionalInterfaceTypes) { Object writeLock = this.writeLock; lock (writeLock) { IGarbageProxyConstructor gpContructor = interfaceTypesToConstructorMap.Get(typeof(T), additionalInterfaceTypes); if (gpContructor != null) { return((IGarbageProxyConstructor <T>)gpContructor); } Type gpType = LoadClass(typeof(GCProxy), typeof(T), additionalInterfaceTypes); gpContructor = AccessorTypeProvider.GetConstructorType <IGarbageProxyConstructor <T> >(gpType); interfaceTypesToConstructorMap.Put(typeof(T), additionalInterfaceTypes, gpContructor); return((IGarbageProxyConstructor <T>)gpContructor); } }
protected IPreparedObjRefFactory BuildDelegate(Type realType, int idIndex) { lock (writeLock) { IPreparedObjRefFactory objRefConstructorDelegate = constructorDelegateMap.Get(realType, idIndex); if (objRefConstructorDelegate != null) { return(objRefConstructorDelegate); } Type enhancedType = BytecodeEnhancer.GetEnhancedType(typeof(Object), new ObjRefEnhancementHint(realType, idIndex)); objRefConstructorDelegate = AccessorTypeProvider.GetConstructorType <IPreparedObjRefFactory>(enhancedType); constructorDelegateMap.Put(realType, idIndex, objRefConstructorDelegate); return(objRefConstructorDelegate); } }