コード例 #1
0
        /// <summary>
        /// Creates an instance of a template service from configuration.
        /// </summary>
        /// <param name="config">The configuration of the template service.</param>
        /// <returns>An instance of <see cref="TemplateService"/>.</returns>
        public static TemplateService CreateTemplateService(TemplateServiceConfigurationElement config)
        {
            if (config == null)
                throw new ArgumentNullException("config");

            MarkupParser parser = null;
            if (!string.IsNullOrWhiteSpace(config.MarkupParser))
                parser = CreateMarkupParser(config.MarkupParser);

            return CreateTemplateService(config.Language, config.StrictMode, parser);
        }
コード例 #2
0
        /// <summary>
        /// Creates an instance of <see cref="TemplateService"/> from the specified configuration.
        /// </summary>
        /// <param name="config">The template service configuration.</param>
        /// <returns>An instance of <see cref="TemplateService"/>.</returns>
        public static TemplateService CreateTemplateService(TemplateServiceConfigurationElement config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            var service = TemplateServiceFactory.CreateTemplateService(config);

            AddNamespaces(service, config.Namespaces);

            if (!string.IsNullOrWhiteSpace(config.Activator))
            {
                service.SetActivator(CreateInstance <IActivator>(config.Activator));
            }

            return(service);
        }