CodeGen/Builders/Utils/CodeFileHelper.cs
(开头部分) 6KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using ComLib;
using ComLib.Models;
namespace ComLib.CodeGeneration
{
/// <summary>
/// Helper class for code generation.
/// </summary>
public class CodeFileHelper
{
/// <summary>
/// Writes out the autogenerated file, after processing the substitutions.
/// </summary>
/// <param name="templateFile">The name of the initial template file.</param>
/// <param name="generatedFile">The full location of the file to generate.</param>
/// <param name="generatedFileDirectory">The location of the directory to put the autogenerated file.</param>
/// <param name="substitutions">The substituions (key/value) pairs.</param>
public static void Write(string templateFile, string generatedFile, string generatedFileDirectory, IDictionary<string, string> substitutions)
{
// Read in the input / template file.
string fileContent = File.ReadAllText(templateFile);
// Create the directory if it doesn't exist.
if (!Directory.Exists(generatedFileDirectory))
Directory.CreateDirectory(generatedFileDirectory);
// Replace the values.
IEnumerator<KeyValuePair<string, string>> enumerator = substitutions.GetEnumerator();
while(enumerator.MoveNext())
fileContent = fileContent.Replace(enumerator.Current.Key, enumerator.Current.Value);
// Write out the generated file.
File.WriteAllText(generatedFile, fileContent);
}
/// <summary>
/// Get the names of all the procedures in the stored proc template folder
/// </summary>
/// <param name="codeTemplatePath"></param>
/// <returns></returns>
public static List<string> GetProcNames(string codeTemplatePath)
{
string[] files = Directory.GetFiles(codeTemplatePath);
if (files == null || files.Length == 0)
return new List<string>();
List<FileInfo> fileInfos = new List<FileInfo>();
Dictionary<string, string> fileMap = new Dictionary<string, string>();
files.ForEach(f => fileInfos.Add(new FileInfo(f)));
后面还有 64 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
