Пример #1
0
        private static ProjectItemWrapper CreateProjectItemWrapper(ProjectItem item)
        {
            var targetFileName = item.Project.AllEvaluatedProperties.First(property => property.Name == "TargetFileName")
                                 .EvaluatedValue;
            var appendTargetFrameworkToOutputPath = item.Project.AllEvaluatedProperties.FirstOrDefault(property => property.Name == "AppendTargetFrameworkToOutputPath")
                                                    ?.EvaluatedValue;
            var outputPath      = GetEvaluatedValue(item, "OutputPath");
            var targetFramework = item.Project.AllEvaluatedProperties.FirstOrDefault(property => property.Name == "TargetFramework")?.EvaluatedValue;

            if ($"{appendTargetFrameworkToOutputPath}".ToLower() == "true")
            {
                outputPath += targetFramework;
            }
            var fullPath = GetEvaluatedValue(item, "ProjectDir");

            var projectItemWrapper = new ProjectItemWrapper {
                Name                 = GetName(item),
                ModelFileName        = Path.GetFileName(item.EvaluatedInclude),
                OutputPath           = outputPath,
                OutputFileName       = targetFileName,
                FullPath             = fullPath,
                UniqueName           = Path.GetDirectoryName(fullPath) + @"\" + GetEvaluatedValue(item, "ProjectFileName"),
                LocalPath            = Path.GetDirectoryName(fullPath) + @"\" + item.EvaluatedInclude,
                TargetFramework      = targetFramework,
                IsApplicationProject =
                    File.Exists(
                        $"{Path.GetFullPath($"{fullPath}")}\\{outputPath}\\{Path.GetFileNameWithoutExtension(targetFileName)}.exe") || IsWeb(fullPath)
            };

            return(projectItemWrapper);
        }
Пример #2
0
 private void OpenModelEditor(ProjectItemWrapper projectItemWrapper)
 {
     _dte.InitOutputCalls("OpenModelEditor");
     try{
         new ModelEditorRunner().Start(projectItemWrapper);
     }
     catch (Exception e) {
         _dte.WriteToOutput(e.ToString());
     }
 }
Пример #3
0
        private static bool FilterLocalizedItems(ProjectItemWrapper item, ProjectItemWrapper[] items)
        {
            var match = Regex.Match(item.ModelFileName, @"\A(.*)_(.*)\.xafml\z");

            if (match.Success && item.ModelFileName.EndsWith(match.Groups[2].Value + ".xafml"))
            {
                return(items.Any(wrapper => wrapper.ModelFileName == match.Groups[1].Value + ".xafml"));
            }
            return(item.ModelFileName.Contains("Model.DesignedDiffs.Localization."));
        }
Пример #4
0
        public void Start(ProjectItemWrapper projectItemWrapper)
        {
            string outputFileName = projectItemWrapper.OutputFileName;

            string path = MePath;

            if (path == null)
            {
                path = GridHelper.ExtractME();
            }
            StartMEProcess(projectItemWrapper, outputFileName, path);
        }
Пример #5
0
        public IObservable <Unit> Start(ProjectItemWrapper projectItemWrapper)
        {
            string outputFileName = projectItemWrapper.OutputFileName;
            var    fullPath       = projectItemWrapper.FullPath;
            string assemblyPath   = Path.Combine(fullPath, Path.Combine(projectItemWrapper.OutputPath, outputFileName));

            if (!File.Exists(assemblyPath))
            {
                MessageBox.Show($@"Assembly {assemblyPath} not found, recompilling....", null, MessageBoxButtons.OK);
                return(Observable.Start(() => projectItemWrapper.Project.Build()).Where(b => b)
                       .SelectMany(_ => Start(projectItemWrapper)));
            }
            return(MePath(projectItemWrapper)
                   .SelectMany(path => StartMEProcess(projectItemWrapper, assemblyPath, path)));
        }
Пример #6
0
 private IObservable <string> MePath(ProjectItemWrapper projectItemWrapper)
 {
     if (projectItemWrapper.TargetFramework != null && (projectItemWrapper.TargetFramework.StartsWith("netcore") ||
                                                        projectItemWrapper.TargetFramework == "netstandard2.1"))
     {
         var assembly  = projectItemWrapper.GetType().Assembly;
         var ns        = $"{typeof(ModelEditorRunner).Namespace}.WinDesktop.";
         var resources = Resources(projectItemWrapper, assembly, ns);
         return(BufferUntilCompleted(WriteFiles(resources)).ObserveOn(System.Reactive.Concurrency.Scheduler.Default)
                .SelectMany(strings => ConfigureEnvironment(projectItemWrapper, strings.ToObservable()).Concat(strings.ToObservable()))
                .FirstAsync(s => {
             var fileName = Path.GetFileName(s);
             return !fileName.EndsWith("nuget.exe") && fileName.EndsWith(".exe");
         }));
     }
     return(GridHelper.ExtractME());
 }
Пример #7
0
        void StartMEProcess(ProjectItemWrapper projectItemWrapper, string outputFileName, string path)
        {
            try{
                var    fullPath     = projectItemWrapper.FullPath;
                string assemblyPath = Path.Combine(fullPath, Path.Combine(projectItemWrapper.OutputPath, outputFileName));
                if (!File.Exists(assemblyPath))
                {
                    MessageBox.Show($@"Assembly {assemblyPath} not found", null, MessageBoxButtons.OK);
                    return;
                }

                var destFileName = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(assemblyPath) + "", Path.GetFileName(path) + ""));
                KillProcess(destFileName);
                if (!string.Equals(path, destFileName, StringComparison.OrdinalIgnoreCase))
                {
                    File.Copy(path, destFileName, true);
                    var configPath = Path.Combine(Path.GetDirectoryName(path) + "", Path.GetFileName(path) + ".config");
                    if (File.Exists(configPath))
                    {
                        _dte.WriteToOutput("Copying App.config");
                        File.Copy(configPath, Path.Combine(Path.GetDirectoryName(destFileName) + "", Path.GetFileName(configPath)), true);
                    }
                }
                string debugMe   = OptionClass.Instance.DebugME ? "d":null;
                string arguments = String.Format("{0} {4} \"{1}\" \"{3}\" \"{2}\"", debugMe, Path.GetFullPath(assemblyPath), fullPath, projectItemWrapper.LocalPath, projectItemWrapper.IsApplicationProject);
                if (File.Exists(destFileName))
                {
                    try{
                        _dte.WriteToOutput($"Starting {destFileName} with arguments {arguments}");
                        Process.Start(destFileName, arguments);
                    }
                    catch (IOException) {
                        MessageBox.Show(@"You have probably open the same model from another ME instance. If not please report this with reproduction details in eXpandFramework bugs forum");
                    }
                }
                else
                {
                    MessageBox.Show($@"Model editor not found at {destFileName}");
                }
            }
            catch (Exception e) {
                MessageBox.Show(e.ToString());
            }
        }
Пример #8
0
 private static IObservable <(string path, Stream stream)> Resources(ProjectItemWrapper projectItemWrapper, Assembly assembly, string ns)
 => assembly.GetManifestResourceNames().Where(s => s.StartsWith(ns))