public Initialize ( string workingPath ) : void | ||
workingPath | string | |
Результат | void |
protected override void GenerateInternal(OperationStatus op, BuildType buildType) { if (OrmPackages.Length == 0) { return; } EnsureLibraries(); IFileInfo projectInfoPath = FileSystem.GetFileInfo(Path.Combine(FullProjectDirectory, "project.info.xml")); ProjectInfo local = ProjectInfo.Load(projectInfoPath); if (local == null || local.InstanceId != Project.InstanceId) { if (buildType == BuildType.Build) { Logging.BuildLog.Info("Full build required"); } buildType = BuildType.BuildAll; local = new ProjectInfo { InstanceId = Project.InstanceId }; if (projectInfoPath.Directory.Exists) { foreach (var file in projectInfoPath.Directory.GetFiles()) { file.Delete(); } } } CopyEntityInterfacesAssembly(); string path = FullProjectDirectory; var generatorList = new List <BaseEntityGenerator>(); // generate entities BaseEntityGenerator baseGen = new SDataClientEntityCodeGenerator(); baseGen.Initialize(WorkingDirectoryPath); generatorList.Add(baseGen); // Ensure all paths are created foreach (var gen in generatorList) { string relPath = Path.Combine(path, gen.RelativePath); if (!Directory.Exists(relPath)) { Directory.CreateDirectory(relPath); } } var model = (OrmModel)OrmPackages[0].Model; var engine = new Engine { DefaultToolsVersion = "3.5" }; bool atLeastOneFileWasGenerated = false; var buildItemFiles = new List <BuildItemFileInfo>(); foreach (var entity in OrmEntity.GetAll(model.Project).Where(item => item.Generate && item.GenerateSDataFeed)) { if (!op.CanContinue) { return; } foreach (var generator in generatorList) { string fullPath = Path.Combine(Path.Combine(path, generator.RelativePath), generator.FormatFileName(entity.Name)); var fi = new FileInfo(fullPath); if (BuildHelper.IsEntityNewer(buildType, fi.LastWriteTimeUtc, entity)) { using (var writer = new StreamWriter(fullPath)) { generator.Generate(entity, writer); } atLeastOneFileWasGenerated = true; } buildItemFiles.Add(new BuildItemFileInfo(generator, fullPath)); } } if (atLeastOneFileWasGenerated) { BuildProject(buildItemFiles, engine); } if (op.CanContinue) { local.Save(projectInfoPath); } }
protected override void GenerateInternal(OperationStatus op, BuildType buildType) { if (OrmPackages.Length == 0) return; EnsureLibraries(); IFileInfo projectInfoPath = FileSystem.GetFileInfo(Path.Combine(FullProjectDirectory, "project.info.xml")); ProjectInfo local = ProjectInfo.Load(projectInfoPath); if (local == null || local.InstanceId != Project.InstanceId) { if (buildType == BuildType.Build) Logging.BuildLog.Info("Full build required"); buildType = BuildType.BuildAll; local = new ProjectInfo { InstanceId = Project.InstanceId }; if (projectInfoPath.Directory.Exists) { foreach (var file in projectInfoPath.Directory.GetFiles()) { file.Delete(); } } } CopyEntityInterfacesAssembly(); string path = FullProjectDirectory; var generatorList = new List<BaseEntityGenerator>(); // generate entities BaseEntityGenerator baseGen = new SDataClientEntityCodeGenerator(); baseGen.Initialize(WorkingDirectoryPath); generatorList.Add(baseGen); // Ensure all paths are created foreach (var gen in generatorList) { string relPath = Path.Combine(path, gen.RelativePath); if (!Directory.Exists(relPath)) Directory.CreateDirectory(relPath); } var model = (OrmModel)OrmPackages[0].Model; var engine = new Engine { DefaultToolsVersion = "3.5" }; bool atLeastOneFileWasGenerated = false; var buildItemFiles = new List<BuildItemFileInfo>(); foreach (var entity in OrmEntity.GetAll(model.Project).Where(item => item.Generate && item.GenerateSDataFeed)) { if (!op.CanContinue) return; foreach (var generator in generatorList) { string fullPath = Path.Combine(Path.Combine(path, generator.RelativePath), generator.FormatFileName(entity.Name)); var fi = new FileInfo(fullPath); if (BuildHelper.IsEntityNewer(buildType, fi.LastWriteTimeUtc, entity)) { using (var writer = new StreamWriter(fullPath)) { generator.Generate(entity, writer); } atLeastOneFileWasGenerated = true; } buildItemFiles.Add(new BuildItemFileInfo(generator, fullPath)); } } if (atLeastOneFileWasGenerated) { BuildProject(buildItemFiles, engine); } if (op.CanContinue) { local.Save(projectInfoPath); } }