/// <summary> /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code. /// Returns an <see cref="IDatabaseAssembler"/> that represents the building process for a a concrete <see cref="Database"/>. /// </summary> /// <param name="type">The concrete <see cref="Database"/> type.</param> /// <param name="name">The name of the instance to build, or <see langword="null"/> (<b>Nothing</b> in Visual Basic).</param> /// <param name="reflectionCache">The cache to use retrieving reflection information.</param> /// <returns>The <see cref="IDatabaseAssembler"/> instance.</returns> /// <exception cref="InvalidOperationException">when concrete <see cref="Database"/> type does have the required <see cref="DatabaseAssemblerAttribute"/>.</exception> public IDatabaseAssembler GetAssembler(Type type, string name, ConfigurationReflectionCache reflectionCache) { bool exists = false; IDatabaseAssembler assembler; lock (assemblersMappingLock) { exists = assemblersMapping.TryGetValue(type, out assembler); } if (!exists) { DatabaseAssemblerAttribute assemblerAttribute = reflectionCache.GetCustomAttribute <DatabaseAssemblerAttribute>(type); if (assemblerAttribute == null) { throw new InvalidOperationException( string.Format( Resources.Culture, Resources.ExceptionDatabaseTypeDoesNotHaveAssemblerAttribute, type.FullName, name)); } assembler = (IDatabaseAssembler)Activator.CreateInstance(assemblerAttribute.AssemblerType); lock (assemblersMappingLock) { assemblersMapping[type] = assembler; } } return(assembler); }
private InstrumentationListenerAttribute GetInstrumentationListenerAttribute(object createdObject, ConfigurationReflectionCache reflectionCache) { Type createdObjectType = createdObject.GetType(); InstrumentationListenerAttribute listenerAttribute = reflectionCache.GetCustomAttribute <InstrumentationListenerAttribute>(createdObjectType, true); return(listenerAttribute); }