private void GenerateDgml(List <Tuple <string, string> > modelResult, Project project) { var dgmlBuilder = new DgmlBuilder.DgmlBuilder(); ProjectItem item = null; foreach (var info in modelResult) { var dgmlText = dgmlBuilder.Build(info.Item2, info.Item1, GetTemplate()); if (info.Item1.IndexOfAny(Path.GetInvalidPathChars()) >= 0 || info.Item1.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0) { EnvDteHelper.ShowError("Invalid name: " + info.Item1); return; } var path = Path.Combine(Path.GetTempPath(), info.Item1 + ".dgml"); File.WriteAllText(path, dgmlText, Encoding.UTF8); item = project.ProjectItems.GetItem(Path.GetFileName(path)); if (item != null) { item.Delete(); } item = project.ProjectItems.AddFromFileCopy(path); } if (item != null) { var window = item.Open(); window.Document.Activate(); } }
private void GenerateDgml(string processResult, Project project) { var dgmlBuilder = new DgmlBuilder.DgmlBuilder(); var result = BuildModelResult(processResult); ProjectItem item = null; foreach (var info in result) { var dgmlText = dgmlBuilder.Build(info.Item2, info.Item1, GetTemplate()); var path = Path.GetTempPath() + info.Item1 + ".dgml"; File.WriteAllText(path, dgmlText, Encoding.UTF8); item = project.ProjectItems.GetItem(Path.GetFileName(path)); if (item != null) { item.Delete(); } item = project.ProjectItems.AddFromFileCopy(path); } if (item != null) { var window = item.Open(); window.Document.Activate(); } }
private async System.Threading.Tasks.Task GenerateDgmlAsync(List <Tuple <string, string> > modelResult, Project project) { var dgmlBuilder = new DgmlBuilder.DgmlBuilder(); string target = null; foreach (var info in modelResult) { var dgmlText = dgmlBuilder.Build(info.Item2, info.Item1, GetTemplate()); if (info.Item1.IndexOfAny(Path.GetInvalidPathChars()) >= 0 || info.Item1.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0) { VSHelper.ShowError($"{SharedLocale.InvalidName}: {info.Item1}"); return; } var path = Path.Combine(Path.GetTempPath(), info.Item1 + ".dgml"); File.WriteAllText(path, dgmlText, Encoding.UTF8); target = Path.Combine(Path.GetDirectoryName(project.FullPath), Path.GetFileName(path)); File.Copy(path, target, true); } if (target != null) { await VS.Documents.OpenAsync(target); } }
public static string AsDgml(this DbContext context) { Type type = context.GetType(); var dgmlBuilder = new DgmlBuilder.DgmlBuilder(); var debugView = CreateDebugView(context); var dgml = dgmlBuilder.Build(debugView, type.Name, GetTemplate()); return(dgml); }
public void GenerateDgml(string outputPath, Project project) { if (project.Properties.Item("TargetFrameworkMoniker") == null) { EnvDteHelper.ShowError("The selected project type has no TargetFrameworkMoniker"); return; } if (!project.Properties.Item("TargetFrameworkMoniker").Value.ToString().Contains(".NETFramework") && !project.Properties.Item("TargetFrameworkMoniker").Value.ToString().Contains(".NETCoreApp,Version=v2.0")) { EnvDteHelper.ShowError("Currently only .NET Framework and .NET Core 2.0 projects are supported - TargetFrameworkMoniker: " + project.Properties.Item("TargetFrameworkMoniker").Value); return; } bool isNetCore = project.Properties.Item("TargetFrameworkMoniker").Value.ToString().Contains(".NETCoreApp,Version=v2.0"); var dgmlBuilder = new DgmlBuilder.DgmlBuilder(); try { string launchPath; if (isNetCore) { launchPath = DropNetCoreFiles(outputPath); } else { launchPath = DropFiles(outputPath); } var modelInfo = LaunchProcess(outputPath, launchPath, isNetCore); if (modelInfo.StartsWith("Error:")) { throw new ArgumentException(modelInfo); } var result = BuildModelInfo(modelInfo); ProjectItem item = null; foreach (var info in result) { var dgmlText = dgmlBuilder.Build(info.Item2, info.Item1, GetTemplate()); var path = Path.GetTempPath() + info.Item1 + ".dgml"; File.WriteAllText(path, dgmlText, Encoding.UTF8); item = project.ProjectItems.AddFromFileCopy(path); } if (item != null) { var window = item.Open(); window.Document.Activate(); } } catch (Exception exception) { _package.LogError(new List <string>(), exception); } }