public override Cci.CompilationUnitSnippet GetCompilationUnitSnippetFor(string fullPathToSource, string buildAction) { if (fullPathToSource == null || !File.Exists(fullPathToSource)) { Debug.Assert(false); return(null); } StreamReader sr = new StreamReader(fullPathToSource); Cci.DocumentText docText = new Cci.DocumentText(new Cci.StringSourceText(sr.ReadToEnd(), true)); sr.Close(); Cci.Document doc; Cci.IParserFactory parserFactory; if (string.Compare(buildAction, "Compile", true, System.Globalization.CultureInfo.InvariantCulture) == 0) { #if Xaml if (string.Compare(Path.GetExtension(fullPathToSource), ".xaml", true, System.Globalization.CultureInfo.InvariantCulture) == 0) { doc = Microsoft.XamlCompiler.Compiler.CreateXamlDocument(fullPathToSource, 1, docText); parserFactory = new XamlParserFactory(); } else { #endif doc = Compiler.CreateSpecSharpDocument(fullPathToSource, 1, docText); parserFactory = new ParserFactory(); #if Xaml } #endif } else if (string.Compare(buildAction, "EmbeddedResource", true, System.Globalization.CultureInfo.InvariantCulture) == 0) { if (string.Compare(Path.GetExtension(fullPathToSource), ".resx", true, System.Globalization.CultureInfo.InvariantCulture) == 0 || string.Compare(Path.GetExtension(fullPathToSource), ".txt", true, System.Globalization.CultureInfo.InvariantCulture) == 0) { RegistrationInfo regInfo = new RegistrationInfo(); string resgenPath = regInfo.GetResgenPath(); if (resgenPath == null) { return(null); } parserFactory = new Cci.ResgenFactory(resgenPath); doc = Compiler.CreateSpecSharpDocument(fullPathToSource, 1, docText); } else { return(null); } } else { return(null); } if (doc == null) { return(null); } return(new Cci.CompilationUnitSnippet(new Cci.Identifier(fullPathToSource), parserFactory, new Cci.SourceContext(doc))); }
public override Cci.CompilationUnitSnippet GetCompilationUnitSnippetFor(string fullPathToSource, string buildAction){ if (fullPathToSource == null || !File.Exists(fullPathToSource)){Debug.Assert(false); return null;} StreamReader sr = new StreamReader(fullPathToSource); Cci.DocumentText docText = new Cci.DocumentText(new Cci.StringSourceText(sr.ReadToEnd(), true)); sr.Close(); Cci.Document doc; Cci.IParserFactory parserFactory; if (string.Compare(buildAction, "Compile", true, System.Globalization.CultureInfo.InvariantCulture) == 0){ #if Xaml if (string.Compare(Path.GetExtension(fullPathToSource), ".xaml", true, System.Globalization.CultureInfo.InvariantCulture) == 0){ doc = Microsoft.XamlCompiler.Compiler.CreateXamlDocument(fullPathToSource, 1, docText); parserFactory = new XamlParserFactory(); }else{ #endif doc = Compiler.CreateSpecSharpDocument(fullPathToSource, 1, docText); parserFactory = new ParserFactory(); #if Xaml } #endif }else if (string.Compare(buildAction, "EmbeddedResource", true, System.Globalization.CultureInfo.InvariantCulture) == 0){ if (string.Compare(Path.GetExtension(fullPathToSource), ".resx", true, System.Globalization.CultureInfo.InvariantCulture) == 0 || string.Compare(Path.GetExtension(fullPathToSource), ".txt", true, System.Globalization.CultureInfo.InvariantCulture) == 0){ RegistrationInfo regInfo = new RegistrationInfo(); string resgenPath = regInfo.GetResgenPath(); if (resgenPath == null) return null; parserFactory = new Cci.ResgenFactory(resgenPath); doc = Compiler.CreateSpecSharpDocument(fullPathToSource, 1, docText); }else return null; }else{ return null; } if (doc == null) return null; return new Cci.CompilationUnitSnippet(new Cci.Identifier(fullPathToSource), parserFactory, new Cci.SourceContext(doc)); }