public IViewAdaper <OpenFromPackageTreeView, OpenFromPackageTreeViewResult> GetOpenFromPackageTreeView(string actualFolderPath, string package, string methodName, string selectedSearchType) { var viewModel = new OpenFromPackageTreeViewModel(this, this.iOWrapper, actualFolderPath, package, methodName, selectedSearchType); var view = new OpenFromPackageTreeView(); view.DataContext = viewModel; AttachToParentWindow(view); return(new OpenFromPackageTreeViewAdapter(view)); }
private void OnFolderBrowserCommandClicked(object window) { var actualFolderPath = GetActualFolderPath(); var viewModel = new OpenFromPackageTreeViewModel(actualFolderPath, this.Package, this.MethodName); var view = new OpenFromPackageTreeView(); view.DataContext = viewModel; view.Owner = window as Window; if (view.ShowDialog() == true) { this.Package = viewModel.SelectedPackageName.Split('\\')[0]; this.SelectedManifestFilePath = viewModel.SelectPathViewModel.SelectedPath; var xmlDocument = new XmlDocument(); xmlDocument.Load(viewModel.SelectedMethod.FullName); XmlNode itemXmlNode = xmlDocument.SelectSingleNode("AML/Item"); XmlNode commentsXmlNode = itemXmlNode.SelectSingleNode("comments"); XmlNode methodCodeXmlNode = itemXmlNode.SelectSingleNode("method_code"); XmlNode executionAllowedToXmlNode = itemXmlNode.SelectSingleNode("execution_allowed_to"); XmlNode methodTypeXmlNode = itemXmlNode.SelectSingleNode("method_type"); XmlNode nameTypeXmlNode = itemXmlNode.SelectSingleNode("name"); this.MethodLanguage = methodTypeXmlNode.InnerText; if (methodLanguage == "C#" || methodLanguage == "VB") { this.MethodType = "server"; } else { this.MethodType = "client"; } this.MethodComment = commentsXmlNode?.InnerText; this.MethodCode = methodCodeXmlNode.InnerText; this.IdentityKeyedName = executionAllowedToXmlNode.Attributes["keyed_name"].InnerText; this.IdentityId = executionAllowedToXmlNode.InnerText; this.MethodName = nameTypeXmlNode.InnerText; this.MethodConfigId = itemXmlNode.Attributes["id"].InnerText; this.MethodId = itemXmlNode.Attributes["id"].InnerText; // TODO : duplicated with OpenFromArasViewModel TemplateInfo template = null; string methodTemplatePattern = @"//MethodTemplateName\s*=\s*(?<templatename>[^\W]*)\s*"; Match methodTemplateNameMatch = Regex.Match(methodCode, methodTemplatePattern); if (methodTemplateNameMatch.Success) { string templateName = methodTemplateNameMatch.Groups["templatename"].Value; template = templateLoader.Templates.Where(t => t.TemplateLanguage == methodLanguage && t.TemplateName == templateName).FirstOrDefault(); if (template == null) { var messageWindow = new MessageBoxWindow(); messageWindow.ShowDialog(window as Window, $"The template {templateName} from selected method not found. Default template will be used.", "Open method from AML package", MessageButtons.OK, MessageIcon.Information); } } if (template == null) { template = templateLoader.Templates.Where(t => t.TemplateLanguage == methodLanguage && t.IsSupported).FirstOrDefault(); } this.SelectedTemplate = template; } }