public override void Generate() { var metaKey1 = _model.MetaData.FirstOrDefault(x => x.Key.ToLower() == "xsdprojectname"); var metaKey2 = _model.MetaData.FirstOrDefault(x => x.Key.ToLower() == "xsdfilename"); var metaKey3 = _model.MetaData.FirstOrDefault(x => x.Key.ToLower() == "xsdschemaname"); var metaKey4 = _model.MetaData.FirstOrDefault(x => x.Key.ToLower() == "xsddroprelations"); if (metaKey2 == null || metaKey3 == null) { OnProjectItemGeneratedError(this, new ProjectItemGeneratedErrorEventArgs() { Text = "The XSD generation template requires the model metadata 'XSDFileName' and 'XSDSchemaName' be set. Also an optional 'XSDProjectName' meta tag may be set.", ShowError = true } ); return; } var fileName = metaKey2.Value; var schemaName = metaKey3.Value; var projectName = string.Empty; if (metaKey1 != null) { projectName = metaKey1.Value; } var droprelations = false; if (metaKey4 != null) { bool.TryParse(metaKey4.Value, out droprelations); } //Prepend Module name if necessary if (!string.IsNullOrEmpty(_model.ModuleName)) { fileName = _model.ModuleName + "." + fileName; } var noPathFileName = fileName.Split('\\').Last(); var template = new XSDSchemaTemplate(_model, schemaName, noPathFileName, droprelations); var eventArgs = new ProjectItemGeneratedEventArgs(fileName, template.FileContent, projectName, this, true) { RunCustomTool = true, CustomToolName = "MSDataSetGenerator" }; OnProjectItemGenerated(this, eventArgs); var gcEventArgs = new ProjectItemGenerationCompleteEventArgs(this); OnGenerationComplete(this, gcEventArgs); }
public override void Generate() { var metaKey1 = _model.MetaData.FirstOrDefault(x => x.Key.ToLower() == "xsdprojectname"); var metaKey2 = _model.MetaData.FirstOrDefault(x => x.Key.ToLower() == "xsdfilename"); var metaKey3 = _model.MetaData.FirstOrDefault(x => x.Key.ToLower() == "xsdschemaname"); var metaKey4 = _model.MetaData.FirstOrDefault(x => x.Key.ToLower() == "xsddroprelations"); if (metaKey2 == null || metaKey3 == null) { OnProjectItemGeneratedError(this, new ProjectItemGeneratedErrorEventArgs() { Text = "The XSD generation template requires the model metadata 'XSDFileName' and 'XSDSchemaName' be set. Also an optional 'XSDProjectName' meta tag may be set.", ShowError = true } ); return; } var fileName = metaKey2.Value; var schemaName = metaKey3.Value; var projectName = string.Empty; if (metaKey1 != null) projectName = metaKey1.Value; var droprelations = false; if (metaKey4 != null) { bool.TryParse(metaKey4.Value, out droprelations); } //Prepend Module name if necessary if (!string.IsNullOrEmpty(_model.ModuleName)) { fileName = _model.ModuleName + "." + fileName; } var noPathFileName = fileName.Split('\\').Last(); var template = new XSDSchemaTemplate(_model, schemaName, noPathFileName, droprelations); var eventArgs = new ProjectItemGeneratedEventArgs(fileName, template.FileContent, projectName, this, true) { RunCustomTool = true, CustomToolName = "MSDataSetGenerator" }; OnProjectItemGenerated(this, eventArgs); var gcEventArgs = new ProjectItemGenerationCompleteEventArgs(this); OnGenerationComplete(this, gcEventArgs); }