public Type GetAdapter(Type typeToBeAdapted)
		{
			try
			{
				lock (_cacheLock)
				{
					Type adapterType;
					if (!TypeAdapterCache.TryGetValue(typeToBeAdapted, out adapterType))
					{
						DynamicAdapterBuilder builder = new DynamicAdapterBuilder(typeToBeAdapted, _Module);
						adapterType = builder.Build();
						TypeAdapterCache.Add(typeToBeAdapted, adapterType);
					}
					return adapterType;
				}
			}
			catch 
			{
				//On exception, reset module scope
				_Module = new ModuleScope(false);
				throw;
			}
		}
Example #2
0
 public Type GetAdapter(Type typeToBeAdapted)
 {
     try
     {
         lock (_cacheLock)
         {
             Type adapterType;
             if (!TypeAdapterCache.TryGetValue(typeToBeAdapted, out adapterType))
             {
                 DynamicAdapterBuilder builder = new DynamicAdapterBuilder(typeToBeAdapted, _Module);
                 adapterType = builder.Build();
                 TypeAdapterCache.Add(typeToBeAdapted, adapterType);
             }
             return(adapterType);
         }
     }
     catch
     {
         //On exception, reset module scope
         _Module = new ModuleScope(false);
         throw;
     }
 }