public override void Init(string taskName, CodeBuilderConfiguration configuration) { // 名称空间前缀 this.NamespacePrefix = ((string.IsNullOrEmpty(configuration.NamespaceRoot)) ? string.Empty : (configuration.NamespaceRoot + ".")) + configuration.Tasks[taskName].Properties["NamespacePrefix"].Value; // 名称空间 this.Namespace = ((string.IsNullOrEmpty(configuration.NamespaceRoot)) ? string.Empty : (configuration.NamespaceRoot + ".")) + configuration.Tasks[taskName].Properties["Namespace"].Value; // 接口名称 this.InterfaceName = configuration.Tasks[taskName].Properties["InterfaceName"].Value; // 实体类名称 this.EntityClass = configuration.Tasks[taskName].Properties["EntityClass"].Value; // 设置 输出文件 if (configuration.Tasks[taskName].Properties["File"] == null) { configuration.Tasks[taskName].Properties.Add(new TaskProperty("File", configuration.Tasks[taskName].Properties["InterfaceName"].Value + ".cs")); } else if (string.IsNullOrEmpty(configuration.Tasks[taskName].Properties["File"].Value)) { configuration.Tasks[taskName].Properties["File"].Value = configuration.Tasks[taskName].Properties["InterfaceName"].Value + ".cs"; } }
/// <summary>根据配置信息初始化对象</summary> /// <param name="generatorName"></param> /// <param name="configuration"></param> public override void Init(string taskName, CodeBuilderConfiguration configuration) { // 模板文件位置 this.TemplateFile = configuration.Tasks[taskName].Properties["TemplateFile"] == null ? null : configuration.Tasks[taskName].Properties["TemplateFile"].Value; // 实体类名称 this.ClassName = configuration.Tasks[taskName].Properties["ClassName"].Value; // 实体类名称 this.Namespace = configuration.Tasks[taskName].Properties["Namespace"].Value; // 实体类名称 this.ServiceName = configuration.Tasks[taskName].Properties["ServiceName"].Value; // 请求路径 this.LocationPath = configuration.Tasks[taskName].Properties["LocationPath"].Value; // 设置 输出文件 if (configuration.Tasks[taskName].Properties["File"] == null) { configuration.Tasks[taskName].Properties.Add(new X3Platform.CodeBuilder.Configuration.TaskProperty("File", configuration.Tasks[taskName].Properties["ClassName"].Value + ".js")); } else if (string.IsNullOrEmpty(configuration.Tasks[taskName].Properties["File"].Value)) { configuration.Tasks[taskName].Properties["File"].Value = configuration.Tasks[taskName].Properties["ClassName"].Value + ".js"; } }
/// <summary>根据配置信息初始化对象</summary> /// <param name="generatorName"></param> /// <param name="configuration"></param> public override void Init(string taskName, CodeBuilderConfiguration configuration) { // 模板文件位置 this.TemplateFile = configuration.Tasks[taskName].Properties["TemplateFile"] == null ? null : configuration.Tasks[taskName].Properties["TemplateFile"].Value; // 实体类名称 this.ClassName = configuration.Tasks[taskName].Properties["ClassName"].Value; // 数据表名称 this.DataTableName = configuration.Tasks[taskName].Properties["DataTable"].Value; // 设置 table 信息 IDbSchemaProvider provider = (IDbSchemaProvider)Assembly.Load(configuration.DatabaseProvider.Assembly).CreateInstance(configuration.DatabaseProvider.ClassName, false, BindingFlags.Default, null, new object[] { configuration.DatabaseProvider.ConnectionString }, null, null); DatabaseSchema database = new DatabaseSchema(); database.Name = provider.GetDatabaseName(); database.OwnerName = configuration.DatabaseProvider.OwnerName; var table = provider.GetTable(database.Name, database.OwnerName, configuration.Tasks[taskName].Properties["DataTable"].Value); this.fields = GetFields(table); // 设置 输出文件 if (configuration.Tasks[taskName].Properties["File"] == null) { configuration.Tasks[taskName].Properties.Add(new X3Platform.CodeBuilder.Configuration.TaskProperty("File", configuration.Tasks[taskName].Properties["ClassName"].Value + ".py")); } else if (string.IsNullOrEmpty(configuration.Tasks[taskName].Properties["File"].Value)) { configuration.Tasks[taskName].Properties["File"].Value = configuration.Tasks[taskName].Properties["ClassName"].Value + ".py"; } }
public static void Run() { CodeBuilderConfiguration configuration = CodeBuilderConfiguration.Instance; for (int i = 0; i < configuration.Tasks.Count; i++) { TemplateGenerator generator = TemplateFactory.CreateObject( configuration.Tasks[i].Name, configuration.Tasks[i].Generator, configuration); ITemplateObserver observer; foreach (TaskObserver item in configuration.Tasks[i].Observeres) { switch (item.Type) { case "Console": observer = new ConsoleObserver(); generator.AddObserver(observer); break; case "File": observer = new FileObserver(configuration.Tasks[i]); generator.AddObserver(observer); break; default: break; } } generator.Generate(); } }
public override void Init(string taskName, CodeBuilderConfiguration configuration) { // 名称空间 this.Namespace = ((string.IsNullOrEmpty(configuration.NamespaceRoot)) ? string.Empty : (configuration.NamespaceRoot + ".")) + configuration.Tasks[taskName].Properties["Namespace"].Value; // 类名称 this.ClassName = configuration.Tasks[taskName].Properties["ClassName"].Value; // 类名称 this.ApplicationName = configuration.Tasks[taskName].Properties["ApplicationName"].Value; // 类名称 this.SectionName = configuration.Tasks[taskName].Properties["SectionName"].Value; // 设置 输出文件 if (configuration.Tasks[taskName].Properties["File"] == null) { configuration.Tasks[taskName].Properties.Add(new X3Platform.CodeBuilder.Configuration.TaskProperty("File", this.ClassName + ".cs")); } else if (string.IsNullOrEmpty(configuration.Tasks[taskName].Properties["File"].Value)) { configuration.Tasks[taskName].Properties["File"].Value = this.ClassName + ".cs"; } }
public override void Init(string taskName, CodeBuilderConfiguration configuration) { // 名称空间前缀 this.NamespacePrefix = ((string.IsNullOrEmpty(configuration.NamespaceRoot)) ? string.Empty : (configuration.NamespaceRoot + ".")) + configuration.Tasks[taskName].Properties["NamespacePrefix"].Value; // 名称空间 this.Namespace = ((string.IsNullOrEmpty(configuration.NamespaceRoot)) ? string.Empty : (configuration.NamespaceRoot + ".")) + configuration.Tasks[taskName].Properties["Namespace"].Value; // 类名称 this.ClassName = configuration.Tasks[taskName].Properties["ClassName"].Value; // 实体类名称 this.EntityClass = configuration.Tasks[taskName].Properties["EntityClass"].Value; // 应用名称 this.ApplicationName = configuration.Tasks[taskName].Properties["ApplicationName"].Value; // 业务层接口 this.BusinessLogicInterface = configuration.Tasks[taskName].Properties["BusinessLogicInterface"].Value; // 业务层服务实例 this.BusinessLogicServiceInstance = configuration.Tasks[taskName].Properties["BusinessLogicServiceInstance"].Value; //设置 输出文件 if (configuration.Tasks[taskName].Properties["File"] == null) { configuration.Tasks[taskName].Properties.Add(new X3Platform.CodeBuilder.Configuration.TaskProperty("File", configuration.Tasks[taskName].Properties["ClassName"].Value + ".cs")); } else if (string.IsNullOrEmpty(configuration.Tasks[taskName].Properties["File"].Value)) { configuration.Tasks[taskName].Properties["File"].Value = configuration.Tasks[taskName].Properties["ClassName"].Value + ".cs"; } }
public override void Init(string taskName, CodeBuilderConfiguration configuration) { // 作者 this.Author = configuration.Author; // 名称空间 this.Package = ((string.IsNullOrEmpty(configuration.NamespaceRoot)) ? string.Empty : (configuration.NamespaceRoot + ".")) + configuration.Tasks[taskName].Properties["Package"].Value; // 类名称 this.InterfaceName = configuration.Tasks[taskName].Properties["InterfaceName"].Value; // 实体类名称 this.EntityClassPackage = configuration.Tasks[taskName].Properties["EntityClassPackage"].Value; // 实体类名称 this.EntityClass = configuration.Tasks[taskName].Properties["EntityClass"].Value; //设置 输出文件 if (configuration.Tasks[taskName].Properties["File"] == null) { configuration.Tasks[taskName].Properties.Add(new X3Platform.CodeBuilder.Configuration.TaskProperty("File", configuration.Tasks[taskName].Properties["InterfaceName"].Value + ".java")); } else if (string.IsNullOrEmpty(configuration.Tasks[taskName].Properties["File"].Value)) { configuration.Tasks[taskName].Properties["File"].Value = configuration.Tasks[taskName].Properties["InterfaceName"].Value + ".java"; } }
public override void Init(string taskName, CodeBuilderConfiguration configuration) { // 作者 this.Author = configuration.Author; // 名称空间前缀 this.DataTableName = configuration.Tasks[taskName].Properties["DataTable"].Value; // 名称空间 this.Package = ((string.IsNullOrEmpty(configuration.NamespaceRoot)) ? string.Empty : (configuration.NamespaceRoot + ".")) + configuration.Tasks[taskName].Properties["Package"].Value; // 类名称 this.ClassName = configuration.Tasks[taskName].Properties["ClassName"] == null ? "" : configuration.Tasks[taskName].Properties["ClassName"].Value; // 实体类所在的包名称 this.EntityClassPackage = configuration.Tasks[taskName].Properties["EntityClassPackage"] == null ? "" : configuration.Tasks[taskName].Properties["EntityClassPackage"].Value; // 实体类名称 this.EntityClass = configuration.Tasks[taskName].Properties["EntityClass"].Value; // 应用名称 this.ApplicationName = configuration.Tasks[taskName].Properties["ApplicationName"] == null ? "" : configuration.Tasks[taskName].Properties["ApplicationName"].Value; // 数据层接口 this.DataAccessInterface = configuration.Tasks[taskName].Properties["DataAccessInterface"] == null ? "" : configuration.Tasks[taskName].Properties["DataAccessInterface"].Value; // 数据层接口 this.SupportAuthorization = configuration.Tasks[taskName].Properties["SupportAuthorization"] == null ? "" : configuration.Tasks[taskName].Properties["SupportAuthorization"].Value; //设置 table 信息 IDbSchemaProvider provider = (IDbSchemaProvider)Assembly.Load(configuration.DatabaseProvider.Assembly).CreateInstance(configuration.DatabaseProvider.ClassName, false, BindingFlags.Default, null, new object[] { configuration.DatabaseProvider.ConnectionString }, null, null); DatabaseSchema database = new DatabaseSchema(); database.Name = provider.GetDatabaseName(); database.OwnerName = configuration.DatabaseProvider.OwnerName; table = provider.GetTable(database.Name, database.OwnerName, this.DataTableName); var noPrimaryKeyColumns = provider.GetNoPrimaryKeyColumns(table); this.fields = GetFields(table); // 设置 输出文件 if (configuration.Tasks[taskName].Properties["File"] == null) { configuration.Tasks[taskName].Properties.Add(new X3Platform.CodeBuilder.Configuration.TaskProperty("File", this.ClassName + ".cs")); } else if (string.IsNullOrEmpty(configuration.Tasks[taskName].Properties["File"].Value)) { configuration.Tasks[taskName].Properties["File"].Value = this.ClassName + ".cs"; } }
public override void Init(string taskName, CodeBuilderConfiguration configuration) { provider = (X3Platform.CodeBuilder.Data.IDbSchemaProvider)Assembly.Load(configuration.DatabaseProvider.Assembly).CreateInstance(configuration.DatabaseProvider.ClassName, false, BindingFlags.Default, null, new object[] { configuration.DatabaseProvider.ConnectionString }, null, null); database = new X3Platform.CodeBuilder.Data.DatabaseSchema(); database.Name = provider.GetDatabaseName(); database.OwnerName = configuration.DatabaseProvider.OwnerName; string dataTables = configuration.Tasks[taskName].Properties["DataTables"].Value; string[] tableNames = dataTables.Split(','); this.tables = new List <DataTableSchema>(); // List<DataTableSchema> foreach (string tableName in tableNames) { DataTableSchema table = provider.GetTable(database.Name, database.OwnerName, tableName); this.tables.Add(table); } // 补全 for (int i = 0; i < tables.Count; i++) { DataTableSchema table = this.tables[i]; Dictionary <string, int> dict = GetDisplayLength(table); for (int j = 0; j < table.Columns.Count; j++) { DataColumnSchema column = table.Columns[j]; column.Name = Padding(column.Name, dict["Name"]); column.NativeType = Padding(column.NativeType, dict["NativeType"]); column.Description = Padding(column.Description, dict["Description"]); } } //设置 输出文件 if (configuration.Tasks[taskName].Properties["File"] == null) { configuration.Tasks[taskName].Properties.Add(new TaskProperty("File", taskName + ".md")); } else if (string.IsNullOrEmpty(configuration.Tasks[taskName].Properties["File"].Value)) { configuration.Tasks[taskName].Properties["File"].Value = taskName + ".md"; } }
public static CodeBuilderTask GetTaskConfiguration(string taskName) { CodeBuilderConfiguration configuration = CodeBuilderConfiguration.Instance; for (int i = 0; i < configuration.Tasks.Count; i++) { if (configuration.Tasks[i].Name.ToLower() == taskName.ToLower()) { return(configuration.Tasks[i]); } } return(null); }
public override void Init(string taskName, CodeBuilderConfiguration configuration) { provider = (X3Platform.CodeBuilder.Data.IDbSchemaProvider)Assembly.Load(configuration.DatabaseProvider.Assembly).CreateInstance(configuration.DatabaseProvider.ClassName, false, BindingFlags.Default, null, new object[] { configuration.DatabaseProvider.ConnectionString }, null, null); database = new X3Platform.CodeBuilder.Data.DatabaseSchema(); database.Name = provider.GetDatabaseName(); database.OwnerName = configuration.DatabaseProvider.OwnerName; // table = provider.GetTable(database.Name, database.OwnerName, configuration.Tasks[taskName].Properties["DataTable"].Value); // 设置 输出文件 if (configuration.Tasks[taskName].Properties["File"] == null) { configuration.Tasks[taskName].Properties.Add(new X3Platform.CodeBuilder.Configuration.TaskProperty("File", configuration.Tasks[taskName].Properties["DataTable"].Value + ".StorageProcedure.sql")); } else if (string.IsNullOrEmpty(configuration.Tasks[taskName].Properties["File"].Value)) { configuration.Tasks[taskName].Properties["File"].Value = configuration.Tasks[taskName].Properties["DataTable"].Value + ".StorageProcedure.sql"; } }
/// <summary>初始化配置</summary> /// <param name="taskName"></param> /// <param name="configuration"></param> public virtual void Init(string taskName, CodeBuilderConfiguration configuration) { }
/// <summary>创建模板生成器对象 <summary> public static TemplateGenerator CreateObject(string taskName, string className, CodeBuilderConfiguration configuration) { TemplateGenerator template = (TemplateGenerator)KernelContext.CreateObject(className); if (template == null) { throw new Exception("创建[" + className + "]类型对象失败,请确认此类型是否存在."); } template.Init(taskName, configuration); return(template); }