protected override bool LoadIncludeText(string requestFileName, out string content, out string location) { //FIXME: resolve from addins var substituted = StringParserService.Parse(requestFileName); return(base.LoadIncludeText(substituted, out content, out location)); }
private void InitializeComponent() { this.SuspendLayout(); //设置属性 this.Text = StringParserService.Parse("${res:SimplusD.name}"); this.Name = "WorkbenchForm"; this.IsMdiContainer = true; this.WindowState = defaultWindowState; this.KeyPreview = true; this.MinimumSize = new Size(640, 480); this.AllowDrop = true; this.ImeMode = ImeMode.On; //TabNavigationForm _tabNavigationForm = new TabNavigationForm(this); //DockPanel的初始化 MainDockPanel.Dock = DockStyle.Fill; MainDockPanel.DockTopPortion = 150; MainDockPanel.DockBottomPortion = 120; MainDockPanel.DockLeftPortion = 100; MainDockPanel.DockRightPortion = 260; this.FormClosing += new FormClosingEventHandler(WorkbenchForm_FormClosing); this.FormClosed += new FormClosedEventHandler(WorkbenchForm_FormClosed); this.ResumeLayout(false); }
protected override string ResolveAssemblyReference(string assemblyReference) { //FIXME: resolve from addins var substituted = StringParserService.Parse(assemblyReference); return(base.ResolveAssemblyReference(substituted)); }
public override object CreateInstance() { if (label == null) { label = Id; } label = StringParserService.Parse(label); if (icon != null) { icon = CommandCodon.GetStockId(Addin, icon); } CommandEntrySet cset = new CommandEntrySet(label, icon); cset.CommandId = Id; cset.AutoHide = autohide; foreach (InstanceExtensionNode e in ChildNodes) { CommandEntry ce = e.CreateInstance() as CommandEntry; if (ce != null) { cset.Add(ce); } else { throw new InvalidOperationException("Invalid ItemSet child: " + e); } } return(cset); }
void ParseCommand(StringTagModel tagSource, out string cmd, out string args) { if (command.Length > 0 && command [0] == '"') { int n = command.IndexOf('"', 1); if (n != -1) { cmd = command.Substring(1, n - 1); args = command.Substring(n + 1).Trim(); } else { cmd = command; args = string.Empty; } } else { int i = command.IndexOf(' '); if (i != -1) { cmd = command.Substring(0, i); args = command.Substring(i + 1).Trim(); } else { cmd = command; args = string.Empty; } } cmd = StringParserService.Parse(cmd, tagSource); args = StringParserService.Parse(args, tagSource); }
public override object CreateInstance() { if (Platform.IsMac && this.macLabel != null) { this.label = LanguageOption.GetValueBykey(this.macLabel); } if (this.label == null) { this.label = this.Id; } this.label = LanguageOption.GetValueBykey(this.label); this.label = StringParserService.Parse(this.label); if (this.icon != null) { this.icon = CommandCodon.GetStockId(this.Addin, this.icon); } CommandEntrySet commandEntrySet = new CommandEntrySet(this.label, (IconId)this.icon); commandEntrySet.CommandId = (object)this.Id; commandEntrySet.AutoHide = this.autohide; foreach (InstanceExtensionNode childNode in this.ChildNodes) { CommandEntry instance = childNode.CreateInstance() as CommandEntry; if (instance == null) { throw new InvalidOperationException("Invalid ItemSet child: " + (object)childNode); } commandEntrySet.Add(instance); } return((object)commandEntrySet); }
protected override void Run(object dataItem) { ExternalTools.ExternalTool tool = (ExternalTools.ExternalTool)dataItem; string argumentsTool = StringParserService.Parse(tool.Arguments, IdeApp.Workbench.GetStringTagModel()); //Save current file checkbox if (tool.SaveCurrentFile && IdeApp.Workbench.ActiveDocument != null) { IdeApp.Workbench.ActiveDocument.Save(); } if (tool.PromptForArguments) { string customerArguments = MessageService.GetTextResponse(GettextCatalog.GetString("Enter any arguments you want to use while launching tool, {0}:", tool.MenuCommand), GettextCatalog.GetString("Command Arguments for {0}", tool.MenuCommand), ""); if (customerArguments != String.Empty) { argumentsTool = StringParserService.Parse(customerArguments, IdeApp.Workbench.GetStringTagModel()); } } DispatchService.BackgroundDispatch(delegate { RunExternalTool(tool, argumentsTool); }); }
void ResolveCustomCommand(Project project, CustomCommand cmd, out string dir, out string exe, out string args) { dir = exe = args = null; string [,] customtags = new string [, ] { { "ProjectDir", "$(srcdir)" }, { "TargetName", "$(notdir $(ASSEMBLY))" }, { "TargetDir", "$(BUILD_DIR)" }, { "CombineDir", "$(top_srcdir)" } }; int i = cmd.Command.IndexOf(' '); if (i == -1) { exe = cmd.Command; args = string.Empty; } else { exe = cmd.Command.Substring(0, i); args = StringParserService.Parse(cmd.Command.Substring(i + 1), customtags); } dir = (string.IsNullOrEmpty(cmd.WorkingDir) ? "$(srcdir)" : StringParserService.Parse(cmd.WorkingDir, customtags)); }
void GotFocusEvent(object sender, EventArgs e) { lock (this) { if (wasChangedExternally) { wasChangedExternally = false; StringParserService stringParserService = (StringParserService)ServiceManager.Services.GetService(typeof(StringParserService)); string message = stringParserService.Parse("${res:NetFocus.DataStructure.DefaultEditor.Gui.Editor.TextEditorDisplayBinding.FileAlteredMessage}", new string[, ] { { "File", Path.GetFullPath(((TextEditorControl)this.Control).FileName) } }); if (MessageBox.Show(message, stringParserService.Parse("${res:MainWindow.DialogName}"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { LoadFile(((TextEditorControl)this.Control).FileName); } else { IsDirty = true; } } } }
/// <summary> /// 页面的Css设置 /// </summary> /// <param name="doc">对应的模板文档</param> public CssSetupForm(TmpltXmlDocument doc) { InitializeComponent(); if (!Service.Util.DesignMode) { this.tabControlGeneral.TabPages.Clear(); } Doc = doc; XmlElement ele = doc.DocumentElement; CSSText = ele.GetAttribute("webCss"); _webPageDicA = CssSection.Parse(ele.GetAttribute("a")); _webPageDicA_visited = CssSection.Parse(ele.GetAttribute("a_visited")); this.checkBoxUsingCurImg.Visible = false; checkBoxIsAutoSize.Enabled = true; tabControlGeneral.TabPages.Add(this.tabPageBackGroud); tabControlGeneral.TabPages.Add(this.tabPageBorder); tabControlGeneral.TabPages.Add(this.tabPageFont); this.groupBoxLinkOption.Visible = true; //this.cssDesignerDisplayControl.NumericUpDown.Enabled = true; _curType = CurType.WebPage; this.textBoxCurType.Text = StringParserService.Parse("${res:tmpltDesign.tmpltDrawPanel.cssSetupFormType.tmplt}"); this.Text = StringParserService.Parse("${res:tmpltDesign.tmpltDrawPanel.cssSetupFormText.tmplt}"); _tmpltID = doc.Id; this.textBoxTitle.Enabled = false; this.textBoxTitle.Text = ele.GetAttribute("title"); //InitEvent(); }
public ProjectCreateInformation CreateProjectCI(ProjectCreateInformation projectCI) { var projectCreateInformation = projectCI; var substitution = new string[, ] { { "ProjectName", projectCreateInformation.ProjectName } }; projectCreateInformation.ProjectName = StringParserService.Parse(name, substitution); if (string.IsNullOrEmpty(directory) || directory == ".") { return(projectCreateInformation); } string dir = StringParserService.Parse(directory, substitution); projectCreateInformation.ProjectBasePath = Path.Combine(projectCreateInformation.SolutionPath, dir); if (!Directory.Exists(projectCreateInformation.ProjectBasePath)) { Directory.CreateDirectory(projectCreateInformation.ProjectBasePath); } return(projectCreateInformation); }
/// <summary> /// 初始化字体选择框 /// </summary> /// <param name="isInit"></param> private void InitComboBoxFont(bool isInit) { if (isInit) { string path = Path.Combine(Application.StartupPath, "Config/fontlist.xml"); XmlDocument fontListDoc = new XmlDocument(); if (File.Exists(path)) { try { fontListDoc.Load(path); XmlNodeList xnl = fontListDoc.DocumentElement.ChildNodes; if (xnl != null) { foreach (XmlNode node in xnl) { fontlists.Add(node.InnerText); } } } catch { File.Delete(path); throw; } } } cb_Font.Items.Clear(); foreach (string str in fontlists) { cb_Font.Items.Add(str); } cb_Font.Items.Add(StringParserService.Parse("${res:TextpropertyPanel.fontname.editfontlist}")); }
public SnipChannelNamesTreeForm() { InitializeComponent(); CheckedNodes = new List <TreeNode>(); Separator = "|"; ChannelLinkWidth = "60px"; IsUsedSeparator = true; CheckedChannels = new List <KeyValuePair <string, string> >(); if (!Service.Util.DesignMode) { this.comboBoxSizeUnit.Items.AddRange(new string[] { StringParserService.Parse("${res:TextpropertyPanel.sizeunit.px}"), //StringParserService.Parse("${res:TextpropertyPanel.sizeunit.pt}"), //StringParserService.Parse("${res:TextpropertyPanel.sizeunit.in}"), //StringParserService.Parse("${res:TextpropertyPanel.sizeunit.cm}"), //StringParserService.Parse("${res:TextpropertyPanel.sizeunit.mm}"), //StringParserService.Parse("${res:TextpropertyPanel.sizeunit.pc}"), //StringParserService.Parse("${res:TextpropertyPanel.sizeunit.em}"), //StringParserService.Parse("${res:TextpropertyPanel.sizeunit.ex}"), StringParserService.Parse("${res:TextpropertyPanel.sizeunit.per}") }); comboBoxSizeUnit.SelectedIndex = 0; } GetChannelNames(); }
public override bool Evaluate(NodeElement conditionNode) { var target = conditionNode.GetAttribute("target"); if (string.IsNullOrEmpty(target)) { return(false); } string msbuild = Runtime.SystemAssemblyService.CurrentRuntime.GetMSBuildExtensionsPath(); Dictionary <string, string> variables = new Dictionary <string, string> (StringComparer.OrdinalIgnoreCase) { { "MSBuildExtensionsPath64", msbuild }, { "MSBuildExtensionsPath32", msbuild }, { "MSBuildExtensionsPath", msbuild } }; string path = StringParserService.Parse(target, variables); if (Path.DirectorySeparatorChar != '\\') { path = path.Replace('\\', Path.DirectorySeparatorChar); } return(File.Exists(path)); }
public override bool AddToProject(SolutionItem parent, Project project, string language, string directory, string name) { // Replace template variables string cname = Path.GetFileNameWithoutExtension(name); string[,] tags = { { "Name", cname }, }; string content = addinTemplate.OuterXml; content = StringParserService.Parse(content, tags); // Create the manifest XmlDocument doc = new XmlDocument(); doc.LoadXml(content); string file = Path.Combine(directory, "manifest.addin.xml"); doc.Save(file); project.AddFile(file, BuildAction.EmbeddedResource); AddinData.EnableAddinAuthoringSupport((DotNetProject)project); return(true); }
public CSSGeneralLayoutControl() { InitializeComponent(); if (!Service.Util.DesignMode) { this.comboBoxWidthSizeUnit.Items.AddRange(new string[] { StringParserService.Parse("${res:TextpropertyPanel.sizeunit.px}"), StringParserService.Parse("${res:TextpropertyPanel.sizeunit.pt}"), StringParserService.Parse("${res:TextpropertyPanel.sizeunit.in}"), StringParserService.Parse("${res:TextpropertyPanel.sizeunit.cm}"), StringParserService.Parse("${res:TextpropertyPanel.sizeunit.mm}"), StringParserService.Parse("${res:TextpropertyPanel.sizeunit.pc}"), StringParserService.Parse("${res:TextpropertyPanel.sizeunit.em}"), StringParserService.Parse("${res:TextpropertyPanel.sizeunit.ex}"), StringParserService.Parse("${res:TextpropertyPanel.sizeunit.per}") }); this.comboBoxHeightSizeUnit.Items.AddRange(new string[] { StringParserService.Parse("${res:TextpropertyPanel.sizeunit.px}"), StringParserService.Parse("${res:TextpropertyPanel.sizeunit.pt}"), StringParserService.Parse("${res:TextpropertyPanel.sizeunit.in}"), StringParserService.Parse("${res:TextpropertyPanel.sizeunit.cm}"), StringParserService.Parse("${res:TextpropertyPanel.sizeunit.mm}"), StringParserService.Parse("${res:TextpropertyPanel.sizeunit.pc}"), StringParserService.Parse("${res:TextpropertyPanel.sizeunit.em}"), StringParserService.Parse("${res:TextpropertyPanel.sizeunit.ex}"), StringParserService.Parse("${res:TextpropertyPanel.sizeunit.per}") }); } }
private void OKBtn_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(partNumText.Text)) { DialogResult = DialogResult.Cancel; return; } PartNum = Convert.ToInt32(partNumText.Text); if (isRowRadioBtn.Checked) { if (PartNum < 2 || PartNum > _rect.Height) { MessageBox.Show(StringParserService.Parse("${res:tmpltDesign.partRect.error.partNum}")); } else { this.DialogResult = DialogResult.OK; } } else { if (PartNum < 2 || PartNum > _rect.Width) { MessageBox.Show(StringParserService.Parse("${res:tmpltDesign.partRect.error.partNum}")); } else { this.DialogResult = DialogResult.OK; } } }
private void MadeForm() { this.lblPropertyGroupChoose.Text = StringParserService.Parse("${res:productPage.choseGroup}"); this.btnAddProp.Text = StringParserService.Parse("${res:productPage.add}"); this.btnDelProp.Text = StringParserService.Parse("${res:productPage.del}"); this.btnModifyProp.Text = StringParserService.Parse("${res:productPage.modify}"); }
public override void LoadPanelContents() { SetupFromXmlFile(Path.Combine(PropertyService.DataDirectory, @"resources\panels\BehaviorTextEditorPanel.xfrm")); ((CheckBox)ControlDictionary["autoinsertCurlyBraceCheckBox"]).Checked = ((IProperties)CustomizationObject).GetProperty("AutoInsertCurlyBracket", true); ((CheckBox)ControlDictionary["hideMouseCursorCheckBox"]).Checked = ((IProperties)CustomizationObject).GetProperty("HideMouseCursor", true); ((CheckBox)ControlDictionary["caretBehindEOLCheckBox"]).Checked = ((IProperties)CustomizationObject).GetProperty("CursorBehindEOL", false); ((CheckBox)ControlDictionary["auotInsertTemplatesCheckBox"]).Checked = ((IProperties)CustomizationObject).GetProperty("AutoInsertTemplates", true); ((CheckBox)ControlDictionary["convertTabsToSpacesCheckBox"]).Checked = ((IProperties)CustomizationObject).GetProperty("TabsToSpaces", false); ControlDictionary["tabSizeTextBox"].Text = ((IProperties)CustomizationObject).GetProperty("TabIndent", 4).ToString(); ControlDictionary["indentSizeTextBox"].Text = ((IProperties)CustomizationObject).GetProperty("IndentationSize", 4).ToString(); ((ComboBox)ControlDictionary["indentStyleComboBox"]).Items.Add(StringParserService.Parse("${res:Dialog.Options.IDEOptions.TextEditor.Behaviour.IndentStyle.None}")); ((ComboBox)ControlDictionary["indentStyleComboBox"]).Items.Add(StringParserService.Parse("${res:Dialog.Options.IDEOptions.TextEditor.Behaviour.IndentStyle.Automatic}")); ((ComboBox)ControlDictionary["indentStyleComboBox"]).Items.Add(StringParserService.Parse("${res:Dialog.Options.IDEOptions.TextEditor.Behaviour.IndentStyle.Smart}")); ((ComboBox)ControlDictionary["indentStyleComboBox"]).SelectedIndex = (int)(IndentStyle)((IProperties)CustomizationObject).GetProperty("IndentStyle", IndentStyle.Smart); ((ComboBox)ControlDictionary["mouseWhellDirectionComboBox"]).Items.Add(StringParserService.Parse("${res:Dialog.Options.IDEOptions.TextEditor.Behaviour.NormalMouseDirectionRadioButton}")); ((ComboBox)ControlDictionary["mouseWhellDirectionComboBox"]).Items.Add(StringParserService.Parse("${res:Dialog.Options.IDEOptions.TextEditor.Behaviour.ReverseMouseDirectionRadioButton}")); ((ComboBox)ControlDictionary["mouseWhellDirectionComboBox"]).SelectedIndex = ((IProperties)CustomizationObject).GetProperty("MouseWheelScrollDown", true) ? 0 : 1; }
void ToolEvt(object sender, EventArgs e) { SdMenuCommand item = (SdMenuCommand)sender; StringParserService stringParserService = (StringParserService)ServiceManager.Services.GetService(typeof(StringParserService)); for (int i = 0; i < ToolLoader.Tool.Count; ++i) { if (item.Text == ToolLoader.Tool[i].ToString()) { ExternalTool tool = (ExternalTool)ToolLoader.Tool[i]; stringParserService.Properties["StartupPath"] = Application.StartupPath; string command = stringParserService.Parse(tool.Command); try { ProcessStartInfo startinfo = new ProcessStartInfo(command, ""); startinfo.WorkingDirectory = ""; Process.Start(startinfo); } catch (Exception ex) { MessageBox.Show(command + "\n" + ex.ToString(), "启动程序时出错:", MessageBoxButtons.OK, MessageBoxIcon.Error); } break; } } }
public EnvironmentNode(XmlElement el) { StringParserService stringParserService = (StringParserService)ServiceManager.Services.GetService(typeof(StringParserService)); ArrayList envColors = new ArrayList(); ArrayList envColorNames = new ArrayList(); ArrayList envColorDescriptions = new ArrayList(); if (el != null) { foreach (XmlNode node in el.ChildNodes) { if (node is XmlElement) { envColorNames.Add(node.Name); envColorDescriptions.Add("${res:Dialog.HighlightingEditor.EnvColors." + node.Name + "}"); envColors.Add(new EditorHighlightColor((XmlElement)node)); } } } EnvironmentNode.ColorNames = (string[])envColorNames.ToArray(typeof(string)); this.ColorDescs = (string[])envColorDescriptions.ToArray(typeof(string)); this.Colors = (EditorHighlightColor[])envColors.ToArray(typeof(EditorHighlightColor)); stringParserService.Parse(ref ColorDescs); Text = ResNodeName("EnvironmentColors"); OptionPanel = new EnvironmentOptionPanel(this); }
public ButtonItem[] BuildSubmenu(object owner) { IFileService fileService = (IFileService)NetFocus.DataStructure.Services.ServiceManager.Services.GetService(typeof(IFileService)); ResourceService ResourceService = (ResourceService)ServiceManager.Services.GetService(typeof(ResourceService)); StringParserService stringParserService = (StringParserService)ServiceManager.Services.GetService(typeof(StringParserService)); RecentOpenMemeto recentOpen = fileService.RecentOpenMemeto; if (recentOpen.RecentFile.Count > 0) { SdMenuCommand[] items = new SdMenuCommand[recentOpen.RecentFile.Count]; for (int i = 0; i < recentOpen.RecentFile.Count; ++i) { items[i] = new SdMenuCommand(recentOpen.RecentFile[i].ToString(), new EventHandler(LoadRecentFile)); items[i].Description = stringParserService.Parse(ResourceService.GetString("XML.MainMenu.FileMenu.LoadRecentFileDescription"), new string[, ] { { "FILE", recentOpen.RecentFile[i].ToString() } }); } return(items); } SdMenuCommand defaultMenu = new SdMenuCommand(ResourceService.GetString("XML.MainMenu.FileMenu.NoRecentFileDescription")); defaultMenu.Enabled = false; return(new ButtonItem[] { defaultMenu }); }
public void TagsInItemExtension() { var p = new TestTagProvider(); StringParserService.RegisterStringTagProvider(p); var node = new CustomItemNode <StringTagTestExtension> (); WorkspaceObject.RegisterCustomExtension(node); try { var project = Services.ProjectService.CreateDotNetProject("C#"); var modeld = project.GetStringTagModelDescription(ConfigurationSelector.Default); Assert.IsTrue(modeld.GetTags().Any(t => t.Name == "foo")); var model = project.GetStringTagModel(ConfigurationSelector.Default); Assert.AreEqual("bar", model.GetValue("foo")); project.Dispose(); } finally { StringParserService.UnregisterStringTagProvider(p); WorkspaceObject.UnregisterCustomExtension(node); } }
public override Task <bool> AddToProjectAsync(SolutionFolderItem policyParent, Project project, string language, string directory, string name) { var model = CombinedTagModel.GetTagModel(ProjectTagModel, policyParent, project, language, name, null); var fileName = StringParserService.Parse(name, model); project.ProjectProperties.SetValue(typeAtt.Value, string.IsNullOrEmpty(fileName) ? propertyInnerText : string.Concat(fileName, extension)); return(Task.FromResult(true)); }
/// <summary> /// 预览面板 /// </summary> public PreviewPad() { _instance = this; this.Text = StringParserService.Parse("${res:Pad.Preview.text}"); this.Icon = Icon.FromHandle(ResourceService.GetResourceImage("MainMenu.file.preview").GetHicon()); _browser.Dock = DockStyle.Fill; this.Controls.Add(_browser); }
private void BaseCutAndCopyForm_Load(object sender, EventArgs e) { this.label1.Text = StringParserService.Parse("${res:cutOrCopyError.error}"); this.label1.TextAlign = ContentAlignment.BottomCenter; this.label1.ForeColor = Color.Red; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = StringParserService.Parse("${res:tagError.error}"); }
public static string GetHeader(AuthorInformation authorInfo, StandardHeaderPolicy policy, TextStylePolicy textPolicy, string fileName, bool newFile) { string[] comment = Document.GetCommentTags(fileName); if (comment == null) { return(""); } if (string.IsNullOrEmpty(policy.Text) || (newFile && !policy.IncludeInNewFiles)) { return(""); } string result; string eolMarker = TextStylePolicy.GetEolMarker(textPolicy.EolMarker); if (comment.Length == 1) { string cmt = comment[0]; //make sure there's a space between the comment char and the license text if (!char.IsWhiteSpace(cmt[cmt.Length - 1])) { cmt = cmt + " "; } StringBuilder sb = new StringBuilder(policy.Text.Length); string[] lines = policy.Text.Split('\n'); foreach (string line in lines) { if (string.IsNullOrWhiteSpace(line)) { sb.Append(cmt.TrimEnd()); sb.Append(eolMarker); continue; } sb.Append(cmt); sb.Append(line); sb.Append(eolMarker); } result = sb.ToString(); } else { //multiline comment result = String.Concat(comment[0], "\n", policy.Text, "\n", comment[1], "\n"); } return(StringParserService.Parse(result, new string[, ] { { "FileName", Path.GetFileName(fileName) }, { "FileNameWithoutExtension", Path.GetFileNameWithoutExtension(fileName) }, { "Directory", Path.GetDirectoryName(fileName) }, { "FullFileName", fileName }, { "AuthorName", authorInfo.Name }, { "AuthorEmail", authorInfo.Email }, { "CopyrightHolder", authorInfo.Copyright }, })); }
// Returns a stream with the content of the file. // project and language parameters are optional public virtual Stream CreateFileContent(SolutionItem policyParent, Project project, string language, string fileName, string identifier) { Dictionary <string, string> tags = new Dictionary <string, string> (); ModifyTags(policyParent, project, language, identifier, fileName, ref tags); string content = CreateContent(project, tags, language); content = StringParserService.Parse(content, tags); string mime = DesktopService.GetMimeTypeForUri(fileName); CodeFormatter formatter = !string.IsNullOrEmpty(mime) ? CodeFormatterService.GetFormatter(mime) : null; if (formatter != null) { var formatted = formatter.FormatText(policyParent != null ? policyParent.Policies : null, content); if (formatted != null) { content = formatted; } } MemoryStream ms = new MemoryStream(); byte[] data; if (AddStandardHeader) { string header = StandardHeaderService.GetHeader(policyParent, fileName, true); data = System.Text.Encoding.UTF8.GetBytes(header); ms.Write(data, 0, data.Length); } Mono.TextEditor.Document doc = new Mono.TextEditor.Document(); doc.Text = content; TextStylePolicy textPolicy = policyParent != null?policyParent.Policies.Get <TextStylePolicy> ("text/plain") : MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy <TextStylePolicy> ("text/plain"); string eolMarker = TextStylePolicy.GetEolMarker(textPolicy.EolMarker); byte[] eolMarkerBytes = System.Text.Encoding.UTF8.GetBytes(eolMarker); var tabToSpaces = textPolicy.TabsToSpaces? new string (' ', textPolicy.TabWidth) : null; foreach (Mono.TextEditor.LineSegment line in doc.Lines) { var lineText = doc.GetTextAt(line.Offset, line.EditableLength); if (tabToSpaces != null) { lineText = lineText.Replace("\t", tabToSpaces); } data = System.Text.Encoding.UTF8.GetBytes(lineText); ms.Write(data, 0, data.Length); ms.Write(eolMarkerBytes, 0, eolMarkerBytes.Length); } ms.Position = 0; return(ms); }
public ProcessExecutionCommand CreateExecutionCommand(IWorkspaceObject entry, ConfigurationSelector configuration) { string exe, args; StringTagModel tagSource = GetTagModel(entry, configuration); ParseCommand(tagSource, out exe, out args); ProjectConfiguration config = null; if (entry is IConfigurationTarget) { config = configuration.GetConfiguration((IConfigurationTarget)entry) as ProjectConfiguration; } //if the executable name matches an executable in the project directory, use that, for back-compat //else fall back and let the execution handler handle it via PATH, working directory, etc. if (!Path.IsPathRooted(exe)) { string localPath = ((FilePath)exe).ToAbsolute(entry.BaseDirectory).FullPath; if (File.Exists(localPath)) { exe = localPath; } } ProcessExecutionCommand cmd = Runtime.ProcessService.CreateCommand(exe); cmd.Arguments = args; FilePath workingDir = this.workingdir; if (!workingDir.IsNullOrEmpty) { workingDir = StringParserService.Parse(workingDir, tagSource); } cmd.WorkingDirectory = workingDir.IsNullOrEmpty ? entry.BaseDirectory : workingDir.ToAbsolute(entry.BaseDirectory); if (environmentVariables != null) { var vars = new Dictionary <string, string> (); foreach (var v in environmentVariables) { vars [v.Key] = StringParserService.Parse(v.Value, tagSource); } if (config != null) { foreach (var v in config.EnvironmentVariables) { vars [v.Key] = StringParserService.Parse(v.Value, tagSource); } } cmd.EnvironmentVariables = vars; } return(cmd); }
public async Task <ProjectFile> AddFileToProject(SolutionFolderItem policyParent, Project project, string language, string directory, string name) { generatedFile = await SaveFile(policyParent, project, language, directory, name); if (generatedFile != null) { string buildAction = this.buildAction ?? project.GetDefaultBuildAction(generatedFile); ProjectFile projectFile = project.AddFile(generatedFile, buildAction); if (!string.IsNullOrEmpty(dependsOn)) { var model = CombinedTagModel.GetTagModel(ProjectTagModel, policyParent, project, language, name, generatedFile); string parsedDepName = StringParserService.Parse(dependsOn, model); if (projectFile.DependsOn != parsedDepName) { projectFile.DependsOn = parsedDepName; } } if (!string.IsNullOrEmpty(customTool)) { projectFile.Generator = customTool; } if (!string.IsNullOrEmpty(customToolNamespace)) { var model = CombinedTagModel.GetTagModel(ProjectTagModel, policyParent, project, language, name, generatedFile); projectFile.CustomToolNamespace = StringParserService.Parse(customToolNamespace, model); } if (!string.IsNullOrEmpty(subType)) { projectFile.ContentType = subType; } DotNetProject netProject = project as DotNetProject; if (netProject != null) { // Add required references foreach (string aref in references) { string res = netProject.AssemblyContext.GetAssemblyFullName(aref, netProject.TargetFramework); res = netProject.AssemblyContext.GetAssemblyNameForVersion(res, netProject.TargetFramework); if (!ContainsReference(netProject, res)) { netProject.References.Add(ProjectReference.CreateAssemblyReference(aref)); } } } return(projectFile); } else { return(null); } }