void ICodeGenerator.GenerateCodeFromCompileUnit(CodeCompileUnit e, TextWriter w, CodeGeneratorOptions o)
{
bool setLocal = false;
if (_output != null && w != _output.InnerWriter)
{
throw new InvalidOperationException(SR.CodeGenOutputWriter);
}
if (_output == null)
{
setLocal = true;
_options = o ?? new CodeGeneratorOptions();
_output = new ExposedTabStringIndentedTextWriter(w, _options.IndentString);
}
try
{
if (e is CodeSnippetCompileUnit)
{
GenerateSnippetCompileUnit((CodeSnippetCompileUnit)e);
}
else
{
GenerateCompileUnit(e);
}
}
finally
{
if (setLocal)
{
_output = null;
_options = null;
}
}
}