Castle.DynamicProxy.ModuleScope.LoadAssemblyIntoCache C# (CSharp) Method

LoadAssemblyIntoCache() public method

Loads the generated types from the given assembly into this ModuleScope's cache.
This method can be used to load previously generated and persisted proxy types from disk into this scope's type cache, eg. in order to avoid the performance hit associated with proxy generation.
public LoadAssemblyIntoCache ( Assembly assembly ) : void
assembly System.Reflection.Assembly The assembly to load types from. This assembly must have been saved via or /// , or it must have the manually applied.
return void
		public void LoadAssemblyIntoCache(Assembly assembly)
		{
			if (assembly == null)
			{
				throw new ArgumentNullException("assembly");
			}

			var cacheMappings =
				(CacheMappingsAttribute[])assembly.GetCustomAttributes(typeof(CacheMappingsAttribute), false);

			if (cacheMappings.Length == 0)
			{
				var message = string.Format(
					"The given assembly '{0}' does not contain any cache information for generated types.",
					assembly.FullName);
				throw new ArgumentException(message, "assembly");
			}

			foreach (var mapping in cacheMappings[0].GetDeserializedMappings())
			{
				var loadedType = assembly.GetType(mapping.Value);

				if (loadedType != null)
				{
					RegisterInCache(mapping.Key, loadedType);
				}
			}
		}
#endif