/// <inheritdoc/>
        public void WriteTypeDocument(TypeWithComment type, IClassDocumentFormatter formatter)
        {
            string filePath = GetTypeDocumentFilePath(type, false);

            if (!TypeDocumentTemplateState.IsCompiled)
            {
                TypeDocumentTemplateState.Compile(typeof(TypeWithComment));
            }

            WriteDocument(type, filePath, Settings.TypeDodumentSettings?.Encoding, TypeDocumentTemplateState.Key, formatter);
        }
Exemple #2
0
        /// <inheritdoc/>
        public void WriteTypeDocument(TypeWithComment type, IClassDocumentFormatter formatter)
        {
            string filePath = GetTypeDocumentFilePath(type, false);
            string dir      = Path.GetDirectoryName(filePath);

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            RazorEngine.Templating.DynamicViewBag viewBag = new RazorEngine.Templating.DynamicViewBag();
            viewBag.AddValue("Formatter", formatter);

            if (!TypeDocumentTemplateState.IsCompiled)
            {
                TypeDocumentTemplateState.Compile(typeof(TypeWithComment));
            }

            using (StreamWriter writer = new StreamWriter(filePath, false, Settings.TypeDodumentSettings.Encoding))
            {
                Engine.Run(TypeDocumentTemplateState.Key, writer, type.GetType(), type, viewBag: viewBag);
                writer.Flush();
            }
        }