public static MathNet.Numerics.LinearAlgebra.Vector <T> vector <T>(int n) where T : struct, System.IEquatable <T>, System.IFormattable { if (typeof(T) == typeof(double) || ScriptingExtensions.IsNumericType(typeof(T))) { return (new MathNet.Numerics.LinearAlgebra.Double.DenseVector(n) as MathNet.Numerics.LinearAlgebra.Vector <T>); } if (typeof(T) == typeof(System.Numerics.Complex)) { return (new MathNet.Numerics.LinearAlgebra.Complex.DenseVector(n) as MathNet.Numerics.LinearAlgebra.Vector <T>); } throw new System.ArgumentException("Wrong type for vector creation, consider using real or complex"); }
private void _view_CalculateClicked(object sender, EventArgs e) { if (_expressionTextProvider.Text != "") { try { _customFunctionsEditor.ClearHighlightedErrors(); var function = _expressionsEvaluator.Evaluate(_expressionTextProvider.Text, _customFunctionsEditor.Text, _calculationsMode); var x = _view.X; var y = _view.Y; var z = new Complex(x, y); dynamic result = function.EvaluateDynamic(x, y); var resultStr = ScriptingExtensions.ToMathString(result); _view.AddResult(_expressionTextProvider.Text, _calculationsMode == CalculationsMode.Complex ? z.ToMathString() : (_calculationsMode == CalculationsMode.Fxy ? $"{x.ToMathString()}, {y.ToMathString()}" : x.ToMathString()), resultStr); } catch (Exception ex) { _exceptionsHandler.HandleException(ex); } } else { _errorHandler.DispalyError(Strings.GUI_addToChartButton_Click_Expression_should_not_be_empty_, Strings.GUI_numericalOperationButton_Click_Warning_); } }
private static void GenerateSqlScript() { //Create an audit tracking configuration var startup = new TenantContextStartup("jsmith", tenantId1); //Create SQL Script using (var context = new DataContext(startup, "NO_CONNECTIONSTRING")) { //Force model load context.ChangeTracker.AcceptAllChanges(); var rootPath = @"C:\code\ExtensionsLibrary\EFCoreTest.SqlInstaller\"; var modelPath = Path.Combine(rootPath, "Models"); var scriptPath = Path.Combine(rootPath, "Migrations"); var createPath = Path.Combine(rootPath, "Create"); if (!Directory.Exists(modelPath)) { Directory.CreateDirectory(modelPath); } if (!Directory.Exists(scriptPath)) { Directory.CreateDirectory(scriptPath); } if (!Directory.Exists(createPath)) { Directory.CreateDirectory(createPath); } var gen = new EFCore.Extensions.Scripting.SqlServer.SqlServerGeneration(context); //Create SQL generation object var sqlCreate = gen.GenerateCreateScript(); //EXECUTE THIS SQL BLOCK TO CREATE DATABASE File.WriteAllText(Path.Combine(createPath, "Create.sql"), sqlCreate); //Load version file var versionFile = Path.Combine(modelPath, "version.json"); var oldVersion = new Versioning(); if (File.Exists(versionFile)) { oldVersion = ScriptingExtensions.FromJson <Versioning>(File.ReadAllText(versionFile)); } var newVersion = new Versioning(oldVersion.ToString()); newVersion.Increment(); File.WriteAllText(versionFile, newVersion.ToJson()); //Load last model (if one) DataModel oldModel = null; var oldVersionFile = Path.Combine(modelPath, oldVersion.GetDiffFileName()) + ".model"; if (File.Exists(oldVersionFile)) { oldModel = ScriptingExtensions.FromJson <DataModel>(File.ReadAllText(oldVersionFile)); } //Diff Script if (oldModel != null) { var sqlDiff = gen.GenerateDiffScript(oldModel, newVersion); File.WriteAllText(Path.Combine(scriptPath, newVersion.GetDiffFileName() + ".sql"), sqlDiff); } //Write model to installer project var modelJson = gen.Model.ToJson(); File.WriteAllText(Path.Combine(modelPath, newVersion.GetDiffFileName()) + ".model", modelJson); } }
public void Run(string rootPath, EFCore.Extensions.IDbContext context, IScriptGenerator scriptProvider) { var modelPath = Path.Combine(rootPath, "Models"); var initializePath = Path.Combine(rootPath, "1_Initialize"); var scriptPath = Path.Combine(rootPath, "2_Migrations"); var createPath = Path.Combine(rootPath, "3_Create"); var customScriptPath = Path.Combine(rootPath, "4_Programmability"); var finializeScriptPath = Path.Combine(rootPath, "5_Finalize"); if (!Directory.Exists(modelPath)) { Directory.CreateDirectory(modelPath); } if (!Directory.Exists(initializePath)) { Directory.CreateDirectory(initializePath); } if (!Directory.Exists(scriptPath)) { Directory.CreateDirectory(scriptPath); } if (!Directory.Exists(createPath)) { Directory.CreateDirectory(createPath); } if (!Directory.Exists(customScriptPath)) { Directory.CreateDirectory(customScriptPath); } if (!Directory.Exists(finializeScriptPath)) { Directory.CreateDirectory(finializeScriptPath); } EnsureReadme(initializePath, true); EnsureReadme(scriptPath); EnsureReadme(createPath); EnsureReadme(customScriptPath, true); EnsureReadme(finializeScriptPath, true); //Create SQL generation object var sqlCreate = scriptProvider.GenerateCreateScript(); File.WriteAllText(Path.Combine(createPath, "Create.sql"), sqlCreate); //Load version file var versionFile = Path.Combine(modelPath, "version.json"); var oldVersion = new Versioning(); if (File.Exists(versionFile)) { oldVersion = ScriptingExtensions.FromJson <Versioning>(File.ReadAllText(versionFile)); } var newVersion = new Versioning(oldVersion.ToString()); newVersion.Increment(); File.WriteAllText(versionFile, newVersion.ToJson()); //Load last model (if one) DataModel oldModel = null; var oldVersionFile = Path.Combine(modelPath, oldVersion.GetDiffFileName()) + ".model"; if (File.Exists(oldVersionFile)) { oldModel = ScriptingExtensions.FromJson <DataModel>(File.ReadAllText(oldVersionFile)); } //Diff Script if (oldModel != null) { var sqlDiff = scriptProvider.GenerateDiffScript(oldModel, newVersion); File.WriteAllText(Path.Combine(scriptPath, newVersion.GetDiffFileName() + ".sql"), sqlDiff); } //Write model to installer project var modelJson = scriptProvider.Model.ToJson(); File.WriteAllText(Path.Combine(modelPath, newVersion.GetDiffFileName()) + ".model", modelJson); }