/// <summary> /// Gets the display name for the given language. /// </summary> /// <param name="language"></param> /// <returns></returns> public static string LanguageNameFromEnum(TemplateContentLanguage language) { switch (language) { case TemplateContentLanguage.Assembly: return("Assembly"); case TemplateContentLanguage.BatchFile: return("Batch File"); case TemplateContentLanguage.C: return("C"); case TemplateContentLanguage.Cpp: return("C++"); case TemplateContentLanguage.CSharp: return("C#"); case TemplateContentLanguage.Css: return("CSS"); case TemplateContentLanguage.Html: return("HTML"); case TemplateContentLanguage.IniFile: return("Ini File"); case TemplateContentLanguage.Java: return("Java"); case TemplateContentLanguage.JScript: return("JScript"); case TemplateContentLanguage.Lua: return("Lua"); case TemplateContentLanguage.Msil: return("MSIL"); case TemplateContentLanguage.Pascal: return("Pascal"); case TemplateContentLanguage.Perl: return("Perl"); case TemplateContentLanguage.PHP: return("PHP"); case TemplateContentLanguage.PlainText: return("Plain Text"); case TemplateContentLanguage.PowerShell: return("PowerShell"); case TemplateContentLanguage.Python: return("Python"); case TemplateContentLanguage.Rtf: return("RTF"); case TemplateContentLanguage.Sql: return("SQL"); case TemplateContentLanguage.VbDotNet: return("VB.Net"); case TemplateContentLanguage.VbScript: return("VBScript"); case TemplateContentLanguage.Xaml: return("XAML"); case TemplateContentLanguage.Xml: return("XML"); default: throw new NotImplementedException("Syntax language not handled yet: " + language); } }
public void Reset(IProjectFile<string> file, TemplateContentLanguage language) { if (file.HasContents == false) throw new ArgumentException("file must have contents"); this.file = file; editor.Text = file.GetContents(); editor.Document.Language = SyntaxEditorHelper.GetDynamicLanguage(language); errorTreeList.LicenseKey = "F962CEC7-CD8F-4911-A9E9-CAB39962FC1F"; Reparse(); }
public void Reset(IProjectFile <string> file, TemplateContentLanguage language) { if (file.HasContents == false) { throw new ArgumentException("file must have contents"); } this.file = file; editor.Text = file.GetContents(); editor.Document.Language = SyntaxEditorHelper.GetDynamicLanguage(language); errorTreeList.LicenseKey = "F962CEC7-CD8F-4911-A9E9-CAB39962FC1F"; Reparse(); }
/// <summary> /// Gets a DynamicSyntaxLanguage instance given a Languages enum. /// </summary> /// <param name="language"></param> /// <returns></returns> public static DynamicSyntaxLanguage GetDynamicLanguage(TemplateContentLanguage language) { string outputSyntaxFilePath = GetLanguageFileName(language); //if (!File.Exists(outputSyntaxFilePath)) //{ // throw new Exception("Language syntax file could not be loaded: " + outputSyntaxFilePath); //} string filename = Path.GetFileName(outputSyntaxFilePath); //Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(string.Format("Slyce.Common.SyntaxFiles.{0}", filename)); return(DynamicSyntaxLanguage.LoadFromXml(outputSyntaxFilePath, 0)); //return DynamicSyntaxLanguage.LoadFromXml(stream, 0); }
private void SetSyntaxLanguage() { TemplateContentLanguage language = TemplateContentLanguage.CSharp; string normalFilePath = Slyce.Common.SyntaxEditorHelper.GetLanguageFileName(language); normalFilePath = Path.Combine(Path.GetTempPath(), normalFilePath); if (!File.Exists(normalFilePath)) { MessageBox.Show("Xml language syntax file could not be loaded: " + normalFilePath); return; } syntaxEditor1.Document.LoadLanguageFromXml(normalFilePath, 0); }
public ucAnalysisErrorEditor(IProjectFile <string> file, TemplateContentLanguage language) { InitializeComponent(); Reset(file, language); }
/// <summary> /// Loads two languages and creates a state transition from XML to C# within ASP-style directives. /// </summary> public static void SetupEditorTemplateAndScriptLanguages(SyntaxEditor editor, TemplateContentLanguage textLanguage, ScriptLanguageTypes scriptLanguage, string delimiterStart, string delimiterEnd) { DynamicSyntaxLanguage language = GetDynamicLanguage(textLanguage); DynamicSyntaxLanguage cSharpLanguage = GetDynamicLanguage(GetScriptingLanguage(scriptLanguage)); language.AutomaticOutliningBehavior = AutomaticOutliningBehavior.PostSemanticParse; cSharpLanguage.AutomaticOutliningBehavior = AutomaticOutliningBehavior.PostSemanticParse; language.Tag = "TemplateLanguage"; cSharpLanguage.Tag = "ScriptLanguage"; // Mark that updating is starting language.IsUpdating = true; cSharpLanguage.IsUpdating = true; // Add StateTransitions to current language as well nested languages eg: HTML -> JavaScript, VBScript etc. for (int i = 0; i <= language.ChildLanguages.Count; i++) { DynamicSyntaxLanguage lan; if (i == language.ChildLanguages.Count) { lan = language; } else { lan = (DynamicSyntaxLanguage)language.ChildLanguages[i]; } // Add a highlighting style lan.HighlightingStyles.Add(new HighlightingStyle("ASPDirectiveDelimiterStyle", null, Color.Black, ASP_DIRECTIVE_COLOUR)); lan.AutomaticOutliningBehavior = AutomaticOutliningBehavior.SemanticParseDataChange; // Create a new lexical state DynamicLexicalState lexicalState = new DynamicLexicalState(0, "ASPDirectiveState"); lexicalState.DefaultTokenKey = "ASPDirectiveDefaultToken"; lexicalState.DefaultHighlightingStyle = lan.HighlightingStyles["DefaultStyle"]; lexicalState.LexicalStateTransitionLexicalState = cSharpLanguage.LexicalStates["DefaultState"]; lan.LexicalStates.Add(lexicalState); // Add the new lexical state at the beginning of the child states... // Remember that with an NFA regular expression, the first match is taken... // So since a < scope pattern is already in place, we must insert the new one before it lan.LexicalStates["DefaultState"].ChildLexicalStates.Insert(0, lexicalState); #region Extra Transition points - Eg: comments if (lan.LexicalStates.IndexOf("XMLCommentState") >= 0) // C# { lan.LexicalStates["XMLCommentState"].ChildLexicalStates.Insert(0, lexicalState); // Added this to ensure that transitions can occur in XML Comments } if (lan.LexicalStates.IndexOf("CommentState") >= 0) // C# { lan.LexicalStates["CommentState"].ChildLexicalStates.Insert(0, lexicalState); // Added this to ensure that transitions can occur in XML Comments } if (lan.LexicalStates.IndexOf("StringState") >= 0) // SQL { // Note: Had to modify the RegexPatternGroup for StringState in ActiproSoftware.SQL.xml to: <RegexPatternGroup TokenKey="StringDefaultToken" PatternValue="[^<^']+" /> lan.LexicalStates["StringState"].ChildLexicalStates.Insert(0, lexicalState); // Added this to ensure that transitions can occur in XML Comments } if (lan.LexicalStates.IndexOf("SquareStringState") >= 0) // SQL { lan.LexicalStates["SquareStringState"].ChildLexicalStates.Insert(0, lexicalState); // Added this to ensure that transitions can occur in XML Comments } if (lan.LexicalStates.IndexOf("MultiLineCommentState") >= 0) // SQL { lan.LexicalStates["MultiLineCommentState"].ChildLexicalStates.Insert(0, lexicalState); // Added this to ensure that transitions can occur in XML Comments } if (lan.LexicalStates.IndexOf("StartTagState") >= 0) // HTML { lan.LexicalStates["StartTagState"].ChildLexicalStates.Insert(0, lexicalState); // Added this to ensure that transitions can occur in XML Comments } if (lan.LexicalStates.IndexOf("StartTagAttributeStringValueState") >= 0) // HTML { lan.LexicalStates["StartTagAttributeStringValueState"].ChildLexicalStates.Insert(0, lexicalState); // Added this to ensure that transitions can occur in XML Comments } if (lan.LexicalStates.IndexOf("StartTagAttributeState") >= 0) // HTML { lan.LexicalStates["StartTagAttributeState"].ChildLexicalStates.Insert(0, lexicalState); // Added this to ensure that transitions can occur in XML Comments } if (lan.LexicalStates.IndexOf("StartTagAttributeValueState") >= 0) // HTML { lan.LexicalStates["StartTagAttributeValueState"].ChildLexicalStates.Insert(0, lexicalState); // Added this to ensure that transitions can occur in XML Comments } // Create a lexical scope with a lexical state transition DynamicLexicalScope lexicalScope = new DynamicLexicalScope(); lexicalState.LexicalScopes.Add(lexicalScope); lexicalScope.StartLexicalPatternGroup = new LexicalPatternGroup(LexicalPatternType.Explicit, "ASPDirectiveStartToken", lan.HighlightingStyles["ASPDirectiveDelimiterStyle"], delimiterStart); lexicalScope.StartLexicalPatternGroup.LookBehindPattern = @"\\{2}|([^\\]|^)"; // @"\\{2}|[^\\]"; lexicalScope.EndLexicalPatternGroup = new LexicalPatternGroup(LexicalPatternType.Explicit, "ASPDirectiveEndToken", lan.HighlightingStyles["ASPDirectiveDelimiterStyle"], delimiterEnd); lexicalScope.AncestorEndScopeCheckEnabled = false; } #endregion // Mark that updating is complete (since linking is complete, the flag setting // will filter from the XML language into the C# language) language.IsUpdating = false; editor.Document.Language = language; }
public static string GetLanguageFileName(TemplateContentLanguage language) { string tempDir = Path.Combine(Path.GetTempPath(), "SlyceSyntaxFiles"); string filepath; switch (language) { case TemplateContentLanguage.Assembly: filepath = Path.Combine(tempDir, "ActiproSoftware.Assembly.xml"); break; case TemplateContentLanguage.BatchFile: filepath = Path.Combine(tempDir, "ActiproSoftware.BatchFile.xml"); break; case TemplateContentLanguage.C: filepath = Path.Combine(tempDir, "ActiproSoftware.C.xml"); break; case TemplateContentLanguage.Cpp: filepath = Path.Combine(tempDir, "ActiproSoftware.Cpp.xml"); break; case TemplateContentLanguage.CSharp: filepath = Path.Combine(tempDir, "ActiproSoftware.CSharp.xml"); break; case TemplateContentLanguage.Css: filepath = Path.Combine(tempDir, "ActiproSoftware.CSS.xml"); break; case TemplateContentLanguage.Html: filepath = Path.Combine(tempDir, "ActiproSoftware.HTML.xml"); break; case TemplateContentLanguage.IniFile: filepath = Path.Combine(tempDir, "ActiproSoftware.INIFile.xml"); break; case TemplateContentLanguage.Java: filepath = Path.Combine(tempDir, "ActiproSoftware.Java.xml"); break; case TemplateContentLanguage.JScript: filepath = Path.Combine(tempDir, "ActiproSoftware.JScript.xml"); break; case TemplateContentLanguage.Lua: filepath = Path.Combine(tempDir, "ActiproSoftware.Lua.xml"); break; case TemplateContentLanguage.Msil: filepath = Path.Combine(tempDir, "ActiproSoftware.MSIL.xml"); break; case TemplateContentLanguage.Pascal: filepath = Path.Combine(tempDir, "ActiproSoftware.Pascal.xml"); break; case TemplateContentLanguage.Perl: filepath = Path.Combine(tempDir, "ActiproSoftware.Perl.xml"); break; case TemplateContentLanguage.PHP: filepath = Path.Combine(tempDir, "ActiproSoftware.PHP.xml"); break; case TemplateContentLanguage.PlainText: filepath = Path.Combine(tempDir, "ActiproSoftware.PlainText.xml"); break; case TemplateContentLanguage.PowerShell: filepath = Path.Combine(tempDir, "ActiproSoftware.PowerShell.xml"); break; case TemplateContentLanguage.Python: filepath = Path.Combine(tempDir, "ActiproSoftware.Python.xml"); break; case TemplateContentLanguage.Rtf: filepath = Path.Combine(tempDir, "ActiproSoftware.RTF.xml"); break; case TemplateContentLanguage.Sql: filepath = Path.Combine(tempDir, "ActiproSoftware.SQL.xml"); break; case TemplateContentLanguage.VbDotNet: filepath = Path.Combine(tempDir, "ActiproSoftware.VBDotNet.xml"); break; case TemplateContentLanguage.VbScript: filepath = Path.Combine(tempDir, "ActiproSoftware.VBScript.xml"); break; case TemplateContentLanguage.Xaml: filepath = Path.Combine(tempDir, "ActiproSoftware.XAML.xml"); break; case TemplateContentLanguage.Xml: filepath = Path.Combine(tempDir, "ActiproSoftware.XML.xml"); break; default: throw new Exception("Language filename not defined yet: " + language); } if (!File.Exists(filepath)) { WriteSyntaxFilesToDisk(); } if (!File.Exists(filepath)) { throw new FileNotFoundException("Syntax file not found: " + filepath); } return(filepath); }
private void SetSyntax(TemplateContentLanguage textLanguage, bool force, params SyntaxEditor[] editors) { foreach (var editor in editors) { if (CurrentLanguages[editor] != textLanguage || force) { if (ArchAngel.Interfaces.SharedData.CurrentProject == null) SyntaxEditorHelper.SetupEditorTemplateAndScriptLanguages(editor, textLanguage, SyntaxEditorHelper.ScriptLanguageTypes.CSharp, "<%", "%>"); else SyntaxEditorHelper.SetupEditorTemplateAndScriptLanguages(editor, textLanguage, SyntaxEditorHelper.ScriptLanguageTypes.CSharp, ArchAngel.Interfaces.SharedData.CurrentProject.TemplateProject.DelimiterStart, ArchAngel.Interfaces.SharedData.CurrentProject.TemplateProject.DelimiterEnd); UseSplitLanguage = true;// !UseSplitLanguage; SwitchFormatting(); CurrentLanguages[editor] = textLanguage; } } }
public ucAnalysisErrorEditor(IProjectFile<string> file, TemplateContentLanguage language) { InitializeComponent(); Reset(file, language); }
private void SetSyntax(TemplateContentLanguage textLanguage, params SyntaxEditor[] editors) { SetSyntax(textLanguage, false, editors); }
/// <summary> /// Loads two languages and creates a state transition from XML to C# within ASP-style directives. /// </summary> public static void SetupEditorTemplateAndScriptLanguages(SyntaxEditor editor, TemplateContentLanguage textLanguage, ScriptLanguageTypes scriptLanguage, string delimiterStart, string delimiterEnd) { DynamicSyntaxLanguage language = GetDynamicLanguage(textLanguage); DynamicSyntaxLanguage cSharpLanguage = GetDynamicLanguage(GetScriptingLanguage(scriptLanguage)); language.AutomaticOutliningBehavior = AutomaticOutliningBehavior.PostSemanticParse; cSharpLanguage.AutomaticOutliningBehavior = AutomaticOutliningBehavior.PostSemanticParse; language.Tag = "TemplateLanguage"; cSharpLanguage.Tag = "ScriptLanguage"; // Mark that updating is starting language.IsUpdating = true; cSharpLanguage.IsUpdating = true; // Add StateTransitions to current language as well nested languages eg: HTML -> JavaScript, VBScript etc. for (int i = 0; i <= language.ChildLanguages.Count; i++) { DynamicSyntaxLanguage lan; if (i == language.ChildLanguages.Count) { lan = language; } else { lan = (DynamicSyntaxLanguage)language.ChildLanguages[i]; } // Add a highlighting style lan.HighlightingStyles.Add(new HighlightingStyle("ASPDirectiveDelimiterStyle", null, Color.Black, ASP_DIRECTIVE_COLOUR)); lan.AutomaticOutliningBehavior = AutomaticOutliningBehavior.SemanticParseDataChange; // Create a new lexical state DynamicLexicalState lexicalState = new DynamicLexicalState(0, "ASPDirectiveState"); lexicalState.DefaultTokenKey = "ASPDirectiveDefaultToken"; lexicalState.DefaultHighlightingStyle = lan.HighlightingStyles["DefaultStyle"]; lexicalState.LexicalStateTransitionLexicalState = cSharpLanguage.LexicalStates["DefaultState"]; lan.LexicalStates.Add(lexicalState); // Add the new lexical state at the beginning of the child states... // Remember that with an NFA regular expression, the first match is taken... // So since a < scope pattern is already in place, we must insert the new one before it lan.LexicalStates["DefaultState"].ChildLexicalStates.Insert(0, lexicalState); #region Extra Transition points - Eg: comments if (lan.LexicalStates.IndexOf("XMLCommentState") >= 0) // C# { lan.LexicalStates["XMLCommentState"].ChildLexicalStates.Insert(0, lexicalState); // Added this to ensure that transitions can occur in XML Comments } if (lan.LexicalStates.IndexOf("CommentState") >= 0) // C# { lan.LexicalStates["CommentState"].ChildLexicalStates.Insert(0, lexicalState); // Added this to ensure that transitions can occur in XML Comments } if (lan.LexicalStates.IndexOf("StringState") >= 0) // SQL { // Note: Had to modify the RegexPatternGroup for StringState in ActiproSoftware.SQL.xml to: <RegexPatternGroup TokenKey="StringDefaultToken" PatternValue="[^<^']+" /> lan.LexicalStates["StringState"].ChildLexicalStates.Insert(0, lexicalState); // Added this to ensure that transitions can occur in XML Comments } if (lan.LexicalStates.IndexOf("SquareStringState") >= 0) // SQL { lan.LexicalStates["SquareStringState"].ChildLexicalStates.Insert(0, lexicalState); // Added this to ensure that transitions can occur in XML Comments } if (lan.LexicalStates.IndexOf("MultiLineCommentState") >= 0) // SQL { lan.LexicalStates["MultiLineCommentState"].ChildLexicalStates.Insert(0, lexicalState); // Added this to ensure that transitions can occur in XML Comments } if (lan.LexicalStates.IndexOf("StartTagState") >= 0) // HTML { lan.LexicalStates["StartTagState"].ChildLexicalStates.Insert(0, lexicalState); // Added this to ensure that transitions can occur in XML Comments } if (lan.LexicalStates.IndexOf("StartTagAttributeStringValueState") >= 0) // HTML { lan.LexicalStates["StartTagAttributeStringValueState"].ChildLexicalStates.Insert(0, lexicalState); // Added this to ensure that transitions can occur in XML Comments } if (lan.LexicalStates.IndexOf("StartTagAttributeState") >= 0) // HTML { lan.LexicalStates["StartTagAttributeState"].ChildLexicalStates.Insert(0, lexicalState); // Added this to ensure that transitions can occur in XML Comments } if (lan.LexicalStates.IndexOf("StartTagAttributeValueState") >= 0) // HTML { lan.LexicalStates["StartTagAttributeValueState"].ChildLexicalStates.Insert(0, lexicalState); // Added this to ensure that transitions can occur in XML Comments } // Create a lexical scope with a lexical state transition DynamicLexicalScope lexicalScope = new DynamicLexicalScope(); lexicalState.LexicalScopes.Add(lexicalScope); lexicalScope.StartLexicalPatternGroup = new LexicalPatternGroup(LexicalPatternType.Explicit, "ASPDirectiveStartToken", lan.HighlightingStyles["ASPDirectiveDelimiterStyle"], delimiterStart); lexicalScope.StartLexicalPatternGroup.LookBehindPattern = @"\\{2}|([^\\]|^)";// @"\\{2}|[^\\]"; lexicalScope.EndLexicalPatternGroup = new LexicalPatternGroup(LexicalPatternType.Explicit, "ASPDirectiveEndToken", lan.HighlightingStyles["ASPDirectiveDelimiterStyle"], delimiterEnd); lexicalScope.AncestorEndScopeCheckEnabled = false; } #endregion // Mark that updating is complete (since linking is complete, the flag setting // will filter from the XML language into the C# language) language.IsUpdating = false; editor.Document.Language = language; }
/// <summary> /// Gets the display name for the given language. /// </summary> /// <param name="language"></param> /// <returns></returns> public static string LanguageNameFromEnum(TemplateContentLanguage language) { switch (language) { case TemplateContentLanguage.Assembly: return "Assembly"; case TemplateContentLanguage.BatchFile: return "Batch File"; case TemplateContentLanguage.C: return "C"; case TemplateContentLanguage.Cpp: return "C++"; case TemplateContentLanguage.CSharp: return "C#"; case TemplateContentLanguage.Css: return "CSS"; case TemplateContentLanguage.Html: return "HTML"; case TemplateContentLanguage.IniFile: return "Ini File"; case TemplateContentLanguage.Java: return "Java"; case TemplateContentLanguage.JScript: return "JScript"; case TemplateContentLanguage.Lua: return "Lua"; case TemplateContentLanguage.Msil: return "MSIL"; case TemplateContentLanguage.Pascal: return "Pascal"; case TemplateContentLanguage.Perl: return "Perl"; case TemplateContentLanguage.PHP: return "PHP"; case TemplateContentLanguage.PlainText: return "Plain Text"; case TemplateContentLanguage.PowerShell: return "PowerShell"; case TemplateContentLanguage.Python: return "Python"; case TemplateContentLanguage.Rtf: return "RTF"; case TemplateContentLanguage.Sql: return "SQL"; case TemplateContentLanguage.VbDotNet: return "VB.Net"; case TemplateContentLanguage.VbScript: return "VBScript"; case TemplateContentLanguage.Xaml: return "XAML"; case TemplateContentLanguage.Xml: return "XML"; default: throw new NotImplementedException("Syntax language not handled yet: " + language); } }
public static string GetLanguageFileName(TemplateContentLanguage language) { string tempDir = Path.Combine(Path.GetTempPath(), "SlyceSyntaxFiles"); string filepath; switch (language) { case TemplateContentLanguage.Assembly: filepath = Path.Combine(tempDir, "ActiproSoftware.Assembly.xml"); break; case TemplateContentLanguage.BatchFile: filepath = Path.Combine(tempDir, "ActiproSoftware.BatchFile.xml"); break; case TemplateContentLanguage.C: filepath = Path.Combine(tempDir, "ActiproSoftware.C.xml"); break; case TemplateContentLanguage.Cpp: filepath = Path.Combine(tempDir, "ActiproSoftware.Cpp.xml"); break; case TemplateContentLanguage.CSharp: filepath = Path.Combine(tempDir, "ActiproSoftware.CSharp.xml"); break; case TemplateContentLanguage.Css: filepath = Path.Combine(tempDir, "ActiproSoftware.CSS.xml"); break; case TemplateContentLanguage.Html: filepath = Path.Combine(tempDir, "ActiproSoftware.HTML.xml"); break; case TemplateContentLanguage.IniFile: filepath = Path.Combine(tempDir, "ActiproSoftware.INIFile.xml"); break; case TemplateContentLanguage.Java: filepath = Path.Combine(tempDir, "ActiproSoftware.Java.xml"); break; case TemplateContentLanguage.JScript: filepath = Path.Combine(tempDir, "ActiproSoftware.JScript.xml"); break; case TemplateContentLanguage.Lua: filepath = Path.Combine(tempDir, "ActiproSoftware.Lua.xml"); break; case TemplateContentLanguage.Msil: filepath = Path.Combine(tempDir, "ActiproSoftware.MSIL.xml"); break; case TemplateContentLanguage.Pascal: filepath = Path.Combine(tempDir, "ActiproSoftware.Pascal.xml"); break; case TemplateContentLanguage.Perl: filepath = Path.Combine(tempDir, "ActiproSoftware.Perl.xml"); break; case TemplateContentLanguage.PHP: filepath = Path.Combine(tempDir, "ActiproSoftware.PHP.xml"); break; case TemplateContentLanguage.PlainText: filepath = Path.Combine(tempDir, "ActiproSoftware.PlainText.xml"); break; case TemplateContentLanguage.PowerShell: filepath = Path.Combine(tempDir, "ActiproSoftware.PowerShell.xml"); break; case TemplateContentLanguage.Python: filepath = Path.Combine(tempDir, "ActiproSoftware.Python.xml"); break; case TemplateContentLanguage.Rtf: filepath = Path.Combine(tempDir, "ActiproSoftware.RTF.xml"); break; case TemplateContentLanguage.Sql: filepath = Path.Combine(tempDir, "ActiproSoftware.SQL.xml"); break; case TemplateContentLanguage.VbDotNet: filepath = Path.Combine(tempDir, "ActiproSoftware.VBDotNet.xml"); break; case TemplateContentLanguage.VbScript: filepath = Path.Combine(tempDir, "ActiproSoftware.VBScript.xml"); break; case TemplateContentLanguage.Xaml: filepath = Path.Combine(tempDir, "ActiproSoftware.XAML.xml"); break; case TemplateContentLanguage.Xml: filepath = Path.Combine(tempDir, "ActiproSoftware.XML.xml"); break; default: throw new Exception("Language filename not defined yet: " + language); } if (!File.Exists(filepath)) { WriteSyntaxFilesToDisk(); } if (!File.Exists(filepath)) { throw new FileNotFoundException("Syntax file not found: " + filepath); } return filepath; }
/// <summary> /// Gets a DynamicSyntaxLanguage instance given a Languages enum. /// </summary> /// <param name="language"></param> /// <returns></returns> public static DynamicSyntaxLanguage GetDynamicLanguage(TemplateContentLanguage language) { string outputSyntaxFilePath = GetLanguageFileName(language); //if (!File.Exists(outputSyntaxFilePath)) //{ // throw new Exception("Language syntax file could not be loaded: " + outputSyntaxFilePath); //} string filename = Path.GetFileName(outputSyntaxFilePath); //Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(string.Format("Slyce.Common.SyntaxFiles.{0}", filename)); return DynamicSyntaxLanguage.LoadFromXml(outputSyntaxFilePath, 0); //return DynamicSyntaxLanguage.LoadFromXml(stream, 0); }