void LoadDB_DoWork(object sender, DoWorkEventArgs e) { string conn; BaseSchemaReader sr; System.ComponentModel.BackgroundWorker worker; worker = (System.ComponentModel.BackgroundWorker)sender; worker.WorkerReportsProgress = true; // the language generator here is used to project the primitive variable types // this approach has been changed to have the types mapped to a logical model // the xslt defines the target type map for the specific language LanguageGenerator langGen = LanguageGenerator.CodeGenerator(ProjectDefinition.Settings.CodeLanguage); if (ProjectDefinition.Settings.ConnectionString == null) { // provide a popup to get the connection string conn = dataSource.ConnectionString; ProjectDefinition.Settings.ConnectionString = conn; } else { conn = ProjectDefinition.Settings.ConnectionString; } sr = new SqlSchemaReader(langGen, conn); sr.Filter = _filter; sr.WorkerThread = worker; ProjectDefinition.Model = new Model(); ProjectDefinition.Model.OnEntityAdding += new Model.EntityAdding(Model_OnEntityAdding); ProjectDefinition.Model.BuildModel(sr); }
/// <summary> /// Implementation of lookup by locale. This uses resourceId and ResourceExplorer to lookup. /// </summary> /// <param name="context">context.</param> /// <param name="locale">locale to lookup.</param> /// <param name="languageGenerator">found LanguageGenerator.</param> /// <returns>true if found.</returns> public override bool TryGetGenerator(ITurnContext context, string locale, out LanguageGenerator languageGenerator) { var lgm = context.TurnState.Get <LanguageGeneratorManager>(); var resourceId = string.IsNullOrEmpty(locale) ? this.ResourceId : this.ResourceId.Replace(".lg", $".{locale}.lg"); return(lgm.LanguageGenerators.TryGetValue(resourceId, out languageGenerator)); }
internal TypedDataSetGenerator( MySqlConnection con, string modelName, List <string> tables, string path, string artifactNamespace, LanguageGenerator Language, VSProject vsProj) : base(con, modelName, tables, path, artifactNamespace, Language) { _vsProj = vsProj; }
private DialogContext GetDialogContext(string locale = null, LanguageGenerator generator = null) { var resourceExplorer = new ResourceExplorer().LoadProject(GetProjectFolder(), monitorChanges: false); var context = new TurnContext(new TestAdapter(), new Activity() { Locale = locale ?? string.Empty, Text = string.Empty }); context.TurnState.Add(resourceExplorer); context.TurnState.Add(new LanguageGeneratorManager(resourceExplorer)); generator = generator ?? new MockLanguageGenerator(); if (generator != null) { context.TurnState.Add <LanguageGenerator>(generator); } var dc = new DialogContext(new DialogSet(), context, new DialogState()); foreach (var service in context.TurnState) { dc.Services[service.Key] = service.Value; } return(dc); }
internal StrategyConfig(IdentedStreamWriter Writer, string CanonicalTableName, Dictionary <string, Column> Columns, Dictionary <string, Column> DetailColumns, DataAccessTechnology DataAccessTech, GuiType Type, LanguageGenerator Language, bool ValidationsEnabled, List <ColumnValidation> ValidationColumns, List <ColumnValidation> DetailValidationColumns, string ConnectionString, string ConnectionStringWithPassword, string TableName, string DetailTableName, string ConstraintName, Dictionary <string, ForeignKeyColumnInfo> ForeignKeys, Dictionary <string, ForeignKeyColumnInfo> DetailForeignKeys) { this.Writer = Writer; this.CanonicalTableName = CanonicalTableName; this.Columns = Columns; this.DetailColumns = DetailColumns; this.DataAccessTech = DataAccessTech; this.Type = Type; this.Language = Language; this.ValidationsEnabled = ValidationsEnabled; this.ValidationColumns = ValidationColumns; this.ConnectionString = ConnectionString; this.ConnectionStringWithPassword = ConnectionStringWithPassword; this.TableName = TableName; this.DetailTableName = DetailTableName; this.DetailValidationColumns = DetailValidationColumns; this.ConstraintName = ConstraintName; this.ForeignKeys = ForeignKeys; this.DetailForeignKeys = DetailForeignKeys; }
/// <summary> /// Initializes a new instance of the <see cref="ItemTemplatesWinFormsWizard"/> class. /// </summary> /// <param name="language">The language generator (C# or VB.NET).</param> /// <param name="dte">The DTE object.</param> /// <param name="projectType">Type of the project.</param> public ItemTemplatesWinFormsWizard(LanguageGenerator language, DTE dte, ItemTemplateUtilities.ProjectWizardType projectType) { _language = language; _dte = dte; InitializeComponent(); modelEntitySelection_WinForms1.WinFormWizardForm = this; modelEntitySelection_WinForms1.Dte = dte; modelEntitySelection_WinForms1.projectType = projectType; modelEntitySelection_WinForms1.FillComboModels(); btnFinish.Enabled = false; }
/// <summary> /// Removes the temporary template form used to create the item template. /// </summary> /// <param name="proj">The VS project.</param> /// <param name="projectPath">The project path.</param> /// <param name="language">The language generator (C# or VB.NET).</param> internal static void RemoveTemplateForm(VSProject proj, string projectPath, LanguageGenerator language) { if (proj != null && !string.IsNullOrEmpty(projectPath)) { string formName = language == LanguageGenerator.CSharp ? "FormMySQL1.cs" : "FormMySQL1.vb"; string formDesigner = language == LanguageGenerator.CSharp ? "FormMySQL1.Designer.cs" : "FormMySQL1.Designer.vb"; ProjectItem pi = proj.Project.ProjectItems.Item(formName); pi.Remove(); File.Delete(Path.Combine(projectPath, formName)); File.Delete(Path.Combine(projectPath, formDesigner)); File.Delete(Path.Combine(projectPath, "FormMySQL1.resx")); } }
/// <summary> /// Constructor. Initializes a new instance of the <see cref="ItemTemplatesBaseWebWizard "/> class. /// </summary> /// <param name="language">The language generator (C# or VB .NET).</param> public ItemTemplatesBaseWebWizard(LanguageGenerator language) { _language = language; _projectType = ItemTemplateUtilities.ProjectWizardType.AspNetMVC; // get the general output window IVsOutputWindow outWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow; Guid generalPaneGuid = VSConstants.GUID_OutWindowGeneralPane; if (outWindow != null) { outWindow.CreatePane(ref generalPaneGuid, "General", 1, 0); outWindow.GetPane(ref generalPaneGuid, out _generalPane); _generalPane.Activate(); } }
internal ModelGenerator(MySqlConnection con, string modelName, List <string> tables, string path, string artifactNamespace, LanguageGenerator Language) { if (tables == null) { throw new ArgumentNullException("tables"); } _con = con; _modelName = modelName; _tables = tables; _path = path; _artifactNamespace = artifactNamespace; this.Language = Language; EnsureGeneralLogInitialized(); }
private ITurnContext GetTurnContext(string locale = null, LanguageGenerator generator = null) { var resourceExplorer = new ResourceExplorer().LoadProject(GetProjectFolder(), monitorChanges: false); var context = new TurnContext(new TestAdapter(), new Activity() { Locale = locale ?? string.Empty, Text = string.Empty }); context.TurnState.Add(resourceExplorer); context.TurnState.Add(new LanguageGeneratorManager(resourceExplorer)); generator = generator ?? new MockLanguageGenerator(); if (generator != null) { context.TurnState.Add <LanguageGenerator>(generator); } return(context); }
public static void Execute(IGraphOptions _ops) { json_reader = new JSONGraphReader(); nlg = new LanguageGenerator(); ops = _ops; string dir = ops.DirectoryName; string csvFilename = ops.CsvFilename; string inputFilename = ops.InputFilename; string[] json_files = Directory.GetFiles(dir, "*.json"); nlg.output_path = ops.OutputDir; processFile(inputFilename, null, null); log.Info("Successfully released the Excel handle. This is awesome."); IGraphConsole.WriteLine("Done."); Environment.Exit(IGraphConstants.EXIT_SUCCESS); }
public virtual async Task <string> BindAsync(DialogContext dialogContext, object data = null) { if (string.IsNullOrEmpty(this.Template)) { throw new ArgumentNullException(nameof(this.Template)); } LanguageGenerator languageGenerator = dialogContext.Services.Get <LanguageGenerator>(); if (languageGenerator != null) { var result = await languageGenerator.Generate( dialogContext, template : Template, data : data ?? dialogContext.State).ConfigureAwait(false); return(result.ToString()); } return(null); }
public virtual async Task <string> BindToDataAsync(ITurnContext turnContext, object data) { if (string.IsNullOrEmpty(this.Template)) { throw new ArgumentNullException(nameof(this.Template)); } LanguageGenerator languageGenerator = turnContext.TurnState.Get <LanguageGenerator>(); if (languageGenerator != null) { var result = await languageGenerator.Generate( turnContext, template : Template, data : data).ConfigureAwait(false); return(result); } return(null); }
internal BaseWizard(LanguageGenerator Language) { this.Language = Language; if (Language == LanguageGenerator.CSharp) { CodeProvider = CodeDomProvider.CreateProvider("CSharp"); } else if (Language == LanguageGenerator.VBNET) { CodeProvider = CodeDomProvider.CreateProvider("VisualBasic"); } // get the general output window IVsOutputWindow outWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow; Guid generalPaneGuid = VSConstants.GUID_OutWindowGeneralPane; if (outWindow != null) { outWindow.CreatePane(ref generalPaneGuid, "General", 1, 0); outWindow.GetPane(ref generalPaneGuid, out _generalPane); _generalPane.Activate(); } }
/// <summary> /// Fixes the namespaces for the created Visual Basic.NET item template. /// </summary> /// <param name="language">The language generator (C# or VB.NET).</param> /// <param name="projectPath">The project path.</param> /// <param name="projectNamespace">The project namespace.</param> /// <param name="dataAccessTechnology">The data access technology (EF5 or EF6).</param> internal static void FixNamespaces(LanguageGenerator language, string projectPath, string projectNamespace, DataAccessTechnology dataAccessTechnology) { if (language != LanguageGenerator.VBNET) { return; } string outputPath = Path.Combine(Path.Combine(projectPath, "My Project"), "Application.Designer.vb"); string contents = File.ReadAllText(outputPath); if (dataAccessTechnology == DataAccessTechnology.EntityFramework6) { contents = contents.Replace(string.Format("Me.MainForm = Global.{0}.frmMain", projectNamespace), string.Format("Me.MainForm = Global.{0}.{0}.frmMain", projectNamespace)); } else { contents = contents.Replace(string.Format("Me.MainForm = Global.{0}.frmMain", projectNamespace), string.Format("Me.MainForm = {0}.frmMain", projectNamespace)); } File.WriteAllText(outputPath, contents); }
public OracleSchemaReader(LanguageGenerator langGen, string connString) : base(langGen, connString) { }
/// <summary> /// Abstract method to get an ILanguageGenerator by locale. /// </summary> /// <param name="dialogContext">context.</param> /// <param name="locale">locale.</param> /// <param name="generator">generator to return.</param> /// <returns>true if found.</returns> public abstract bool TryGetGenerator(DialogContext dialogContext, string locale, out LanguageGenerator generator);
public ModificationGenerator(LanguageGenerator languageGenerator) { this.languageGenerator = languageGenerator; }
private void VisualizeLabels <T>(Graphics g, T instance) where T : IHasCityRender, IHasMesh, IHasHeights { var finalCityRender = instance.CityRender; var mesh = instance.Mesh; var h = instance.Heights; var terr = finalCityRender.Territories; var cities = finalCityRender.Cities; var nterrs = finalCityRender.AreaProperties.NumberOfTerritories; var avoids = new[] { finalCityRender.Rivers, finalCityRender.Coasts, finalCityRender.Borders }; var lang = LanguageGenerator.MakeRandomLanguage(); var citylabels = new List <PossibleLabelLocation>(); for (var i = 0; i < cities.Count; i++) { var x = mesh.Vxs[cities[i]].X; var y = mesh.Vxs[cities[i]].Y; var text = LanguageGenerator.MakeName(lang, "city"); var size = i < nterrs ? finalCityRender.AreaProperties.FontSizeCity : finalCityRender.AreaProperties.FontSizeTown; var sx = 0.65d * (float)size / _drawnBitmap.Width * (float)text.Length; var sy = size / (float)_drawnBitmap.Height; var possibleLabels = new[] { new PossibleLabelLocation() { X = x + 0.8 * sy, Y = y + 0.3 * sy, Align = PossibleLabelLocation.AlignLeft, X0 = x + 0.7 * sy, Y0 = y - 0.6 * sy, X1 = x + 0.7 * sy + sx, Y1 = y + 0.6 * sy, DebugIndex = 0 }, new PossibleLabelLocation() { X = x - 0.8 * sy, Y = y + 0.3 * sy, Align = PossibleLabelLocation.AlignRight, X0 = x - 0.9 * sy - sx, Y0 = y - 0.7 * sy, X1 = x - 0.9 * sy, Y1 = y + 0.7 * sy, DebugIndex = 1 }, new PossibleLabelLocation() { X = x, Y = y - 0.8 * sy, Align = PossibleLabelLocation.AlignCenterBottom, X0 = x - sx / 2, Y0 = y - 1.9 * sy, X1 = x + sx / 2, Y1 = y - 0.7 * sy, DebugIndex = 2 }, new PossibleLabelLocation() { X = x, Y = y + 1.2 * sy, Align = PossibleLabelLocation.AlignCenterTop, X0 = x - sx / 2, Y0 = y + 0.1 * sy, X1 = x + sx / 2, Y1 = y + 1.3 * sy, DebugIndex = 3 } }; var lowestPenalty = int.MaxValue; var lowestIndex = int.MaxValue; for (int j = 0; j < possibleLabels.Length; j++) { var penalty = Terrain.Penalty(possibleLabels[j], mesh, citylabels, cities, avoids); if (penalty < lowestPenalty) { lowestIndex = j; lowestPenalty = penalty; } } var label = possibleLabels[lowestIndex]; label.Text = text; label.Size = (float)size / 1000f; citylabels.Add(label); } DrawText(g, citylabels, true); var reglabels = new List <PossibleLabelLocation>(); for (var i = 0; i < nterrs; i++) { var city = cities[i]; var text = LanguageGenerator.MakeName(lang, "region"); var sy = finalCityRender.AreaProperties.FontSizeRegion / (float)_drawnBitmap.Height; var sx = 0.6d * text.Length * sy; var lc = Terrain.TerrCenter(mesh, h, terr, city, true); var oc = Terrain.TerrCenter(mesh, h, terr, city, false); var best = 0; var bestscore = -double.MaxValue; for (var j = 0; j < h.Length; j++) { var score = 0d; var v = mesh.Vxs[j]; score -= 3000d * Math.Sqrt((v.X - lc.X) * (v.X - lc.X) + (v.Y - lc.Y) * (v.Y - lc.Y)); score -= 1000d * Math.Sqrt((v.X - oc.X) * (v.X - oc.X) + (v.Y - oc.Y) * (v.Y - oc.Y)); if (terr[j] != city) { score -= 3000; } for (var k = 0; k < cities.Count; k++) { var u = mesh.Vxs[cities[k]]; if (Math.Abs(v.X - u.X) < sx && Math.Abs(v.Y - sy / 2 - u.Y) < sy) { score -= k < nterrs ? 4000 : 500; } if (v.X - sx / 2 < citylabels[k].X1 && v.X + sx / 2 > citylabels[k].X0 && v.Y - sy <citylabels[k].Y1 && v.Y> citylabels[k].Y0) { score -= 5000; } } for (var k = 0; k < reglabels.Count; k++) { var label = reglabels[k]; if (v.X - sx / 2 < label.X + label.Width / 2d && v.X + sx / 2 > label.X - label.Width / 2d && v.Y - sy < label.Y && v.Y > label.Y - label.Size) { score -= 20000; } } if (h[j] <= 0) { score -= 500; } if (v.X + sx / 2 > 0.5 * mesh.Extent.Width) { score -= 50000; } if (v.X - sx / 2 < -0.5 * mesh.Extent.Width) { score -= 50000; } if (v.Y > 0.5 * mesh.Extent.Height) { score -= 50000; } if (v.Y - sy < -0.5 * mesh.Extent.Height) { score -= 50000; } if (score > bestscore) { bestscore = score; best = j; } } reglabels.Add(new PossibleLabelLocation() { Text = text, X = mesh.Vxs[best].X, Y = mesh.Vxs[best].Y, Size = sy, Width = (int)sx }); } DrawText(g, reglabels); }
static void Main(string[] args) { var languageGenerator = new LanguageGenerator() .AddTokenType("identifier", "[a-zA-Z_][a-zA-Z_0-9]*") .AddTokenType("number", "\\d*\\.?\\d+") .AddTokenType("add", "\\+") .AddTokenType("subtract", "-") .AddTokenType("multiply", "\\*") .AddTokenType("divide", "/") .AddTokenType("power", "\\*\\*") .AddTokenType("increment", "#") .AddTokenType("decrement", "=") .AddTokenType("equality", "is") .AddTokenType("allocator", "pls") .AddTokenType("assign", "as") .AddTokenType("semicolon", ";") .AddTokenType("lbraces", "{") .AddTokenType("rbraces", "}") .AddTokenType("separator", "and") .AddTokenType("lparens", "\\(") .AddTokenType("rparens", "\\)"); languageGenerator.AddGrammaticalStructure("Expression'''", structure => structure .AddProductionRule("Assignment", rule => rule .SetDecomposition("identifier", "assign", "Expression") .SetEval(nodes => nodes[2].Eval()) ) .AddProductionRule("Number", rule => rule .SetDecomposition("number") .SetEval(nodes => Convert.ToDouble(nodes[0].tokens[0].text)) ) .AddProductionRule("Parenthesis", rule => rule .SetDecomposition("lparens", "Expression", "rparens") .SetEval(nodes => nodes[1].Eval()) ) .AddProductionRule("Method", rule => rule .SetDecomposition("identifier", "lparens", "Expression", "rparens") .SetEval(nodes => nodes[2].Eval()) ) ); languageGenerator.AddGrammaticalStructure("Expression''", structure => structure .AddProductionRule("BinaryPower", rule => rule .SetDecomposition("Expression'''", "power", "Expression''") .SetEval(nodes => Math.Pow(Convert.ToDouble(nodes[0].Eval()), Convert.ToDouble(nodes[2].Eval()))) ) .AddProductionRule("Fallthrough", rule => rule .SetDecomposition("Expression'''") .SetEval(nodes => nodes[0].Eval()) ) ); languageGenerator.AddGrammaticalStructure("Expression'", structure => structure .AddProductionRule("BinaryMultiplication", rule => rule .SetDecomposition("Expression''", "multiply", "Expression'") .SetEval(nodes => Convert.ToDouble(nodes[0].Eval()) * Convert.ToDouble(nodes[2].Eval())) ) .AddProductionRule("BinaryDivision", rule => rule .SetDecomposition("Expression''", "divide", "Expression'") .SetEval(nodes => Convert.ToDouble(nodes[0].Eval()) / Convert.ToDouble(nodes[2].Eval())) ) .AddProductionRule("Fallthrough", rule => rule .SetDecomposition("Expression''") .SetEval(nodes => nodes[0].Eval()) ) ); languageGenerator.AddGrammaticalStructure("Expression", structure => structure .AddProductionRule("BinaryAddition", rule => rule .SetDecomposition("Expression'", "add", "Expression") .SetEval(nodes => Convert.ToDouble(nodes[0].Eval()) + Convert.ToDouble(nodes[2].Eval())) ) .AddProductionRule("BinarySubtraction", rule => rule .SetDecomposition("Expression'", "subtract", "Expression") .SetEval(nodes => Convert.ToDouble(nodes[0].Eval()) - Convert.ToDouble(nodes[2].Eval())) ) .AddProductionRule("UnaryPlus", rule => rule .SetDecomposition("add", "Expression") .SetEval(nodes => Convert.ToDouble(nodes[1].Eval())) ) .AddProductionRule("UnaryMinus", rule => rule .SetDecomposition("subtract", "Expression") .SetEval(nodes => - Convert.ToDouble(nodes[1].Eval())) ) .AddProductionRule("Brackets", rule => rule .SetDecomposition("lbraces", "Start", "rbraces") .SetEval(nodes => nodes[1].Eval()) ) .AddProductionRule("Fallthrough", rule => rule .SetDecomposition("Expression'") .SetEval(nodes => nodes[0].Eval()) ) ); languageGenerator.AddGrammaticalStructure("Start", structure => structure .AddProductionRule("ExpressionTerminal", rule => rule .SetDecomposition("Expression", "semicolon") .SetEval(nodes => nodes[0].Eval()) ) .AddProductionRule("Expression", rule => rule .SetDecomposition("Expression", "semicolon", "Start") .SetEval(nodes => (nodes[0].Eval(), nodes[2].Eval()).Item1) ) .AddProductionRule("BlockStatementTerminal", rule => rule .SetDecomposition("Expression", "Expression") .SetEval(nodes => { object output = null; while (Convert.ToBoolean(nodes[0].Eval())) { output = nodes[1].Eval(); } return(output); }) ) .AddProductionRule("BlockStatement", rule => rule .SetDecomposition("Expression", "Expression", "Start") .SetEval(nodes => { object output = null; while (Convert.ToBoolean(nodes[0].Eval())) { output = nodes[1].Eval(); } nodes[2].Eval(); return(output); }) ) ); languageGenerator.SetStartingGrammaticalStructure("Start"); Language language = languageGenerator.Build(); var parseTree = language.Parse("132+232/32*(123+42)-32**2;"); var values = PrintParseTree(parseTree, "\t").ToArray(); Console.WriteLine(string.Join(Environment.NewLine, values)); //Console.WriteLine(parseTree.Eval()); }
/// <summary> /// Updates the name of the model. /// </summary> /// <param name="project">The project.</param> /// <param name="formName">Name of the form.</param> /// <param name="projectPath">The project path.</param> /// <param name="projectNamespace">The project namespace.</param> /// <param name="newModelName">New name of the model.</param> /// <param name="language">The language generator (C# or VB.NET).</param> internal static void UpdateModelName(Project project, string formName, string projectPath, string projectNamespace, string newModelName, LanguageGenerator language) { if (string.IsNullOrEmpty(projectPath)) { projectPath = Path.GetDirectoryName(project.FullName); } if (string.IsNullOrEmpty(projectNamespace)) { projectNamespace = project.Properties.Item("DefaultNamespace").Value.ToString(); } string formFile = Path.Combine(projectPath, language == LanguageGenerator.CSharp ? string.Format("{0}.cs", formName) : string.Format("{0}.vb", formName)); string contents = ""; contents = File.ReadAllText(Path.Combine(projectPath, formFile)); contents = contents.Replace("Model1Entities", string.Format("{0}", newModelName)); File.WriteAllText(formFile, contents); }
/// <summary> /// Adds the new form to the current project. /// </summary> /// <param name="project">The project.</param> /// <param name="formName">Name of the form.</param> /// <param name="projectPath">The project path.</param> /// <param name="projectNamespace">The project namespace.</param> /// <param name="language">The language generator (C# or VB.NET).</param> internal static void AddNewForm(Project project, string formName, string projectPath, string projectNamespace, LanguageGenerator language) { if (string.IsNullOrEmpty(projectPath)) { projectPath = Path.GetDirectoryName(project.FullName); } if (string.IsNullOrEmpty(projectNamespace)) { projectNamespace = project.Properties.Item("DefaultNamespace").Value.ToString(); } string formFile = Path.Combine(projectPath, language == LanguageGenerator.CSharp ? "FormMySQL1.cs".Replace("FormMySQL1", formName) : "FormMySQL1.vb".Replace("FormMySQL1", formName)); string formFileDesigner = Path.Combine(projectPath, language == LanguageGenerator.CSharp ? "FormMySQL1.Designer.cs".Replace("FormMySQL1", formName) : "FormMySQL1.Designer.vb".Replace("FormMySQL1", formName)); string formFileResx = Path.Combine(projectPath, "FormMySQL1.resx".Replace("FormMySQL1", formName)); string contents = ""; contents = File.ReadAllText(Path.Combine(projectPath, language == LanguageGenerator.CSharp ? "FormMySQL1.cs" : "FormMySQL1.vb")); contents = contents.Replace("FormMySQL1", formName); contents = contents.Replace("$safeprojectname$", projectNamespace); File.WriteAllText(formFile, contents); contents = File.ReadAllText(Path.Combine(projectPath, language == LanguageGenerator.CSharp ? "FormMySQL1.Designer.cs" : "FormMySQL1.Designer.vb")); contents = contents.Replace("FormMySQL1", formName); contents = contents.Replace("$safeprojectname$", projectNamespace); File.WriteAllText(formFileDesigner, contents); contents = File.ReadAllText(Path.Combine(projectPath, "FormMySQL1.resx")); contents = contents.Replace("FormMySQL1", formName); contents = contents.Replace("$safeprojectname$", projectNamespace); File.WriteAllText(formFileResx, contents); // Now add the form ProjectItem pi = project.ProjectItems.AddFromFile(formFile); ProjectItem pi2 = pi.ProjectItems.AddFromFile(formFileDesigner); ProjectItem pi3 = pi.ProjectItems.AddFromFile(formFileResx); pi3.Properties.Item("ItemType").Value = "EmbeddedResource"; pi.Properties.Item("SubType").Value = "Form"; }
/// <summary> /// Abstract method to get an ILanguageGenerator by locale. /// </summary> /// <param name="context">context.</param> /// <param name="locale">locale.</param> /// <param name="generator">generator to return.</param> /// <returns>true if found.</returns> public abstract bool TryGetGenerator(ITurnContext context, string locale, out LanguageGenerator generator);
/// <summary> /// Ensures the code is generated for a date time grid column. /// </summary> /// <param name="vsProj">The vs proj.</param> /// <param name="columns">The columns.</param> /// <param name="detailColumns">The detail columns.</param> /// <param name="language">The language generator (C# or VB.NET).</param> /// <param name="projectPath">The project path.</param> /// <param name="projectNamespace">The project namespace.</param> /// <returns></returns> internal static bool EnsureCodeForDateTimeGridColumn(VSProject vsProj, Dictionary <string, Column> columns, Dictionary <string, Column> detailColumns, LanguageGenerator language, string projectPath, string projectNamespace) { bool hasDateColumn = false; if (columns != null) { foreach (KeyValuePair <string, Column> kvp in columns) { if (kvp.Value.IsDateType()) { hasDateColumn = true; break; } } } if (!hasDateColumn && detailColumns != null) { foreach (KeyValuePair <string, Column> kvp in detailColumns) { if (kvp.Value.IsDateType()) { hasDateColumn = true; break; } } } // If is the case, then add support code. if (hasDateColumn) { string outFilePath = ""; Stream stream = null; switch (language) { case LanguageGenerator.CSharp: stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MySql.Data.VisualStudio.Wizards.WindowsForms.Templates.CS.MyDateTimePickerColumn.cs"); outFilePath = Path.Combine(projectPath, "MyDateTimePickerColumn.cs"); break; case LanguageGenerator.VBNET: stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MySql.Data.VisualStudio.Wizards.WindowsForms.Templates.VB.MyDateTimePickerColumn.vb"); outFilePath = Path.Combine(projectPath, "MyDateTimePickerColumn.vb"); break; } if (stream != null) { using (var sr = new StreamReader(stream)) { string contents = sr.ReadToEnd(); File.WriteAllText(outFilePath, contents.Replace("$ProjectNamespace$", projectNamespace)); } } vsProj.Project.ProjectItems.AddFromFile(outFilePath); } return(hasDateColumn); }
/// <summary> /// Generates the entity framework model. /// </summary> /// <param name="project">The project.</param> /// <param name="vsProj">The Visual Studio project object.</param> /// <param name="connection">The MySql connection.</param> /// <param name="modelName">Name of the "edmx" model.</param> /// <param name="tables">The tables.</param> /// <param name="modelPath">The model path.</param> /// <param name="currentEntityFrameworkVersion">The current entity framework version.</param> /// <param name="language">The language generator (C# or VB.NET).</param> /// <param name="columnMappings">The column mappings.</param> /// <param name="tablesIncludedInModel">The tables included in model.</param> internal static void GenerateEntityFrameworkModel(Project project, VSProject vsProj, MySqlConnection connection, string modelName, List <string> tables, string modelPath, string currentEntityFrameworkVersion, LanguageGenerator language, Dictionary <string, Dictionary <string, ColumnValidation> > columnMappings, ref Dictionary <string, string> tablesIncludedInModel) { if (project != null) { string projectNamespace = project.Properties.Item("DefaultNamespace").Value.ToString(); string ns = GetCanonicalIdentifier(projectNamespace); EntityFrameworkGenerator gen = new EntityFrameworkGenerator(connection, modelName, tables, modelPath, ns, currentEntityFrameworkVersion, language, vsProj, columnMappings); vsProj = project.Object as VSProject; project.DTE.Solution.SolutionBuild.Build(true); string projectPath = Path.GetDirectoryName(project.FullName); gen.GenerateItemTemplates(projectPath, modelName); if (gen.TablesInModel.Count() > 0) { tablesIncludedInModel = gen.TablesInModel.ToDictionary <string, string>(p => p); } TryErrorsEntityFrameworkGenerator(gen); } }
public static void Execute(IGraphOptions _ops) { // Atributes :) xl_reader = new ExcelGraphReader(); nlg = new LanguageGenerator(); ops = _ops; string dir = ops.DirectoryName; string csvFilename = ops.CsvFilename; string inputFilename = ops.InputFilename; if (ops.isFile) { processFile(inputFilename, null, null); } else if (ops.isCsv) { CsvFile[] xl_csvfiles = CsvParse.parse(csvFilename); string path_csvfile = Path.GetDirectoryName(Path.GetFullPath(csvFilename)); if (xl_csvfiles.Length == 0) { IGraphConsole.WriteError("CSV file found, but no Excel files in it." + "\n\tYou said: " + csvFilename); Environment.Exit(IGraphConstants.NO_GRAPH_FILES_IN_CSV); } // All's well so far, process each graph in each file in the dir log.Info(xl_csvfiles.Length + " Excel file(s) in the csv file."); foreach (CsvFile csvfile in xl_csvfiles) { string file = csvfile.Filename; string f = Path.Combine(path_csvfile, file); // full path of "file" if (File.Exists(f)) { processFile(f, csvfile.Language, csvfile.Title); } else { log.Warn("Excel file not found." + "\n\tThe Excel file must be in: " + f); } } } else { // Do Excel files exist in the directory? string[] xl_files = Directory.GetFiles(dir, "*.xls"); if (xl_files.Length == 0) { IGraphConsole.WriteError("Directory found, but no Excel files in it." + "\n\tYou said: " + (dir == "." ? ". (current directory)" : dir)); Environment.Exit(IGraphConstants.NO_GRAPH_FILES_IN_DIR); } log.Info(xl_files.Length + " Excel file(s) in the directory."); // All's well so far, process each graph in each file in the dir foreach (string file in xl_files) { processFile(file, null, null); } } log.Info("Successfully released the Excel handle. This is awesome."); IGraphConsole.WriteLine("Done."); Environment.Exit(IGraphConstants.EXIT_SUCCESS); }
public WindowsFormsWizard(LanguageGenerator language) : base(language) { WizardForm = new WindowsFormsWizardForm(this); projectType = ProjectWizardType.WindowsForms; }
#pragma warning restore CA2227 // Collection properties should be read only /// <summary> /// Implementation of lookup by locale. This uses internal dictionary to lookup. /// </summary> /// <param name="dialogContext">Context for the current turn of conversation with the user.</param>\ /// <param name="locale">locale.</param> /// <param name="languageGenerator">generator to return.</param> /// <returns>true if found.</returns> public override bool TryGetGenerator(DialogContext dialogContext, string locale, out LanguageGenerator languageGenerator) { return(this.LanguageGenerators.TryGetValue(locale, out languageGenerator)); }
protected BaseSchemaReader(LanguageGenerator langMap, string connString) { _CodeGenerator = langMap; _ConnectionString = connString; }
internal EntityFrameworkGenerator(MySqlConnection con, string modelName, List <string> tables, string path, string artifactNamespace, string EfVersion, LanguageGenerator Language, VSProject vsProj, Dictionary <string, Dictionary <string, ColumnValidation> > Mappings) : base(con, modelName, tables, path, artifactNamespace, Language) { efVersion = EfVersion; _mappings = Mappings; _vsProj = vsProj; }