コード例 #1
0
        /// <summary>
        /// Builds a class context with the data collected so far for the <see cref="TargetType"/> that inherits from other contexts.
        /// </summary>
        /// <param name="inheritedContexts">A collection of <see cref="ClassContext"/> instances the newly built context should inherit mixin data from.</param>
        /// <returns>A <see cref="ClassContext"/> for the <see cref="TargetType"/> holding all mixin configuration data collected so far.</returns>
        public virtual ClassContext BuildClassContext(IEnumerable <ClassContext> inheritedContexts)
        {
            var mixinContexts = MixinContextBuilders.Select(mixinContextBuilder => mixinContextBuilder.BuildMixinContext());
            var classContext  = new ClassContext(_targetType, mixinContexts, ComposedInterfaces);

            classContext = ApplyInheritance(classContext, inheritedContexts);
            classContext = classContext.SuppressMixins(SuppressedMixins);
            try
            {
                classContext = classContext.ApplyMixinDependencies(_mixinDependencies.Select(kvp => new MixinDependencySpecification(kvp.Key, kvp.Value)));
            }
            catch (InvalidOperationException ex)
            {
                var message = string.Format("The mixin dependencies configured for type '{0}' could not be processed: {1}", TargetType, ex.Message);
                throw new ConfigurationException(message, ex);
            }
            return(classContext);
        }