Beispiel #1
0
 /// <inheritdoc/>
 public abstract bool IsSupportingTemplate(TemplateDescription templateDescription);
Beispiel #2
0
        /// <summary>
        ///   Finds a template generator supporting the specified template description.
        /// </summary>
        /// <typeparam name="TParameters">The type of <see cref="TemplateGeneratorParameters"/> of a template generator.</typeparam>
        /// <param name="description">The description of a template generator.</param>
        /// <returns>A template generator supporting the specified description; or <c>null</c> if not found.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="description"/> is a <c>null</c> reference.</exception>
        public static ITemplateGenerator <TParameters> FindTemplateGenerator <TParameters>(TemplateDescription description)
            where TParameters : TemplateGeneratorParameters
        {
            if (description is null)
            {
                throw new ArgumentNullException(nameof(description));
            }

            lock (managerLock)
            {
                // From most recently registered to older
                for (int i = Generators.Count - 1; i >= 0; i--)
                {
                    if (Generators[i] is ITemplateGenerator <TParameters> generator &&
                        generator.IsSupportingTemplate(description))
                    {
                        return(generator);
                    }
                }
            }

            return(null);
        }