/// <summary> /// Sets the encoded string factory. /// </summary> /// <param name="factory">The encoded string factory.</param> /// <returns>The current configuration builder.</returns> public IConfigurationBuilder EncodeUsing(IEncodedStringFactory factory) { Contract.Requires(factory != null); _config.EncodedStringFactory = factory; return(this); }
/// <summary>Sets the encoded string factory.</summary> /// <param name="factory">The encoded string factory.</param> /// <returns>The current configuration builder.</returns> public IConfigurationBuilder EncodeUsing(IEncodedStringFactory factory) { if (factory == null) { throw new ArgumentNullException(nameof(factory)); } this.config.EncodedStringFactory = factory; return(this); }
/// <summary> /// Create a new readonly view (and copy) of the given configuration. /// </summary> /// <param name="config">the configuration to copy.</param> public ReadOnlyTemplateServiceConfiguration(ITemplateServiceConfiguration config) { if (config == null) { throw new ArgumentNullException("config"); } _allowMissingPropertiesOnDynamic = config.AllowMissingPropertiesOnDynamic; _activator = config.Activator; if (_activator == null) { throw new ArgumentNullException("config", "the configured Activator cannot be null!"); } _baseTemplateType = config.BaseTemplateType; // Check if the baseTemplateType is valid. if (_baseTemplateType != null && (!typeof(ITemplate).IsAssignableFrom(_baseTemplateType) || typeof(ITemplate) == _baseTemplateType)) { throw new ArgumentOutOfRangeException("config", "the configured BaseTemplateType must implement ITemplate!"); } _cachingProvider = config.CachingProvider; if (_cachingProvider == null) { throw new ArgumentNullException("config", "the configured CachingProvider cannot be null!"); } #if !RAZOR4 #pragma warning disable 0618 // Backwards Compat. _codeInspectors = config.CodeInspectors; if (_codeInspectors == null) { throw new ArgumentNullException("config", "the configured CodeInspectos cannot be null!"); } _codeInspectors = new List <ICodeInspector>(_codeInspectors); #pragma warning restore 0618 // Backwards Compat. #endif _compilerServiceFactory = config.CompilerServiceFactory; if (_compilerServiceFactory == null) { throw new ArgumentNullException("config", "the configured CompilerServiceFactory cannot be null!"); } _debug = config.Debug; _disableTempFileLocking = config.DisableTempFileLocking; _encodedStringFactory = config.EncodedStringFactory; if (_encodedStringFactory == null) { throw new ArgumentNullException("config", "the configured EncodedStringFactory cannot be null!"); } _language = config.Language; _namespaces = config.Namespaces; if (_namespaces == null) { throw new ArgumentNullException("config", "the configured Namespaces cannot be null!"); } _namespaces = new HashSet <string>(_namespaces); _referenceResolver = config.ReferenceResolver; if (_referenceResolver == null) { throw new ArgumentNullException("config", "the configured ReferenceResolver cannot be null!"); } _templateManager = config.TemplateManager; #if NO_CONFIGURATION if (_templateManager == null) { throw new ArgumentNullException("config", "the configured TemplateManager cannot be null!"); } #else #pragma warning disable 0618 // Backwards Compat. _resolver = config.Resolver; if (_templateManager == null) { if (_resolver != null) { _templateManager = new Xml.WrapperTemplateManager(_resolver); } else { throw new ArgumentNullException("config", "the configured TemplateManager and Resolver cannot be null!"); } } #pragma warning restore 0618 // Backwards Compat. #endif ConfigureCompilerBuilder = config.ConfigureCompilerBuilder; }
/// <summary> /// Create a new readonly view (and copy) of the given configuration. /// </summary> /// <param name="config">the configuration to copy.</param> public ReadOnlyTemplateServiceConfiguration(ITemplateServiceConfiguration config) { if (config == null) { throw new ArgumentNullException("config"); } _allowMissingPropertiesOnDynamic = config.AllowMissingPropertiesOnDynamic; _activator = config.Activator; if (_activator == null) { throw new ArgumentNullException("config", "the configured Activator cannot be null!"); } _baseTemplateType = config.BaseTemplateType; // Check if the baseTemplateType is valid. if (_baseTemplateType != null && (!typeof(ITemplate).IsAssignableFrom(_baseTemplateType) || typeof(ITemplate) == _baseTemplateType)) { throw new ArgumentOutOfRangeException("config", "the configured BaseTemplateType must implement ITemplate!"); } _cachingProvider = config.CachingProvider; if (_cachingProvider == null) { throw new ArgumentNullException("config", "the configured CachingProvider cannot be null!"); } #if !RAZOR4 #pragma warning disable 0618 // Backwards Compat. _codeInspectors = config.CodeInspectors; if (_codeInspectors == null) { throw new ArgumentNullException("config", "the configured CodeInspectos cannot be null!"); } _codeInspectors = new List<ICodeInspector>(_codeInspectors); #pragma warning restore 0618 // Backwards Compat. #endif _compilerServiceFactory = config.CompilerServiceFactory; if (_compilerServiceFactory == null) { throw new ArgumentNullException("config", "the configured CompilerServiceFactory cannot be null!"); } _debug = config.Debug; _disableTempFileLocking = config.DisableTempFileLocking; _encodedStringFactory = config.EncodedStringFactory; if (_encodedStringFactory == null) { throw new ArgumentNullException("config", "the configured EncodedStringFactory cannot be null!"); } _language = config.Language; _namespaces = config.Namespaces; if (_namespaces == null) { throw new ArgumentNullException("config", "the configured Namespaces cannot be null!"); } _namespaces = new HashSet<string>(_namespaces); _referenceResolver = config.ReferenceResolver; if (_referenceResolver == null) { throw new ArgumentNullException("config", "the configured ReferenceResolver cannot be null!"); } #pragma warning disable 0618 // Backwards Compat. _resolver = config.Resolver; _templateManager = config.TemplateManager; if (_templateManager == null) { if (_resolver != null) { _templateManager = new Xml.WrapperTemplateManager(_resolver); } else { throw new ArgumentNullException("config", "the configured TemplateManager and Resolver cannot be null!"); } } #pragma warning restore 0618 // Backwards Compat. }
/// <summary> /// Create a new readonly view (and copy) of the given configuration. /// </summary> /// <param name="config">the configuration to copy.</param> public ReadOnlyTemplateServiceConfiguration(ITemplateServiceConfiguration config) { if (config == null) { throw new ArgumentNullException("config"); } _allowMissingPropertiesOnDynamic = config.AllowMissingPropertiesOnDynamic; _activator = config.Activator; if (_activator == null) { throw new ArgumentNullException("config", "the configured Activator cannot be null!"); } _baseTemplateType = config.BaseTemplateType; // Check if the baseTemplateType is valid. if (_baseTemplateType != null && (!typeof(ITemplate).IsAssignableFrom(_baseTemplateType) || typeof(ITemplate) == _baseTemplateType)) { throw new ArgumentOutOfRangeException("config", "the configured BaseTemplateType must implement ITemplate!"); } _cachingProvider = config.CachingProvider; if (_cachingProvider == null) { throw new ArgumentNullException("config", "the configured CachingProvider cannot be null!"); } _compilerServiceFactory = config.CompilerServiceFactory; if (_compilerServiceFactory == null) { throw new ArgumentNullException("config", "the configured CompilerServiceFactory cannot be null!"); } _debug = config.Debug; _disableTempFileLocking = config.DisableTempFileLocking; _encodedStringFactory = config.EncodedStringFactory; if (_encodedStringFactory == null) { throw new ArgumentNullException("config", "the configured EncodedStringFactory cannot be null!"); } _language = config.Language; _namespaces = config.Namespaces; if (_namespaces == null) { throw new ArgumentNullException("config", "the configured Namespaces cannot be null!"); } _namespaces = new HashSet <string>(_namespaces); _referenceResolver = config.ReferenceResolver; if (_referenceResolver == null) { throw new ArgumentNullException("config", "the configured ReferenceResolver cannot be null!"); } _templateManager = config.TemplateManager; if (_templateManager == null) { throw new ArgumentNullException("config", "the configured TemplateManager cannot be null!"); } ConfigureCompilerBuilder = config.ConfigureCompilerBuilder; }