public override void WriteTo(TextWriter writer, object value) { if (value == null) { return; } var encodedString = value as IEncodedString; if (encodedString != null) { writer.Write(encodedString); } else { var factory = new HtmlEncodedStringFactory(); writer.Write(factory.CreateEncodedString(value)); } }
public RazorViewServiceConfiguration(Registration<IRazorViewLoader> razorViewLoaderRegistration) { if (razorViewLoaderRegistration == null) throw new ArgumentNullException(nameof(razorViewLoaderRegistration)); RazorViewLoader = razorViewLoaderRegistration; CompilerServiceFactory = new DefaultCompilerServiceFactory(); EncodedStringFactory = new HtmlEncodedStringFactory(); CachingProvider = new DefaultCachingProvider(); Namespaces = new HashSet<string>() { "System", "System.Collections.Generic", "System.Linq" }; RazorEngineConfigurationSection configuration = RazorEngineConfigurationSection.GetConfiguration(); Language = configuration?.DefaultLanguage ?? Language.CSharp; }