/// <summary> /// Gets the text of the type. /// </summary> /// <param name="type"></param> /// <returns></returns> public static string ToString(GeneratedCompileUnit unit, Language language) { if (unit == null) { throw new ArgumentNullException("unit"); } // return... return(ToStringInternal(unit, language)); }
/// <summary> /// Saves the file. /// </summary> /// <param name="writer"></param> /// <param name="unit"></param> /// <param name="language"></param> public static void Save(TextWriter writer, GeneratedCompileUnit unit, Language language) { if (writer == null) { throw new ArgumentNullException("writer"); } if (unit == null) { throw new ArgumentNullException("unit"); } // write it... writer.Write(ToString(unit, language)); }
/// <summary> /// Saves the file. /// </summary> /// <param name="writer"></param> /// <param name="unit"></param> /// <param name="language"></param> public static void Save(string filePath, GeneratedCompileUnit unit, Language language) { if (filePath == null) { throw new ArgumentNullException("filePath"); } if (filePath.Length == 0) { throw new ArgumentOutOfRangeException("'filePath' is zero-length."); } // write it... using (StreamWriter writer = new StreamWriter(filePath)) { // saves the file... Save(writer, unit, language); } }
/// <summary> /// Compiles the given unit. /// </summary> /// <param name="unit"></param> /// <returns></returns> public static Assembly Compile(GeneratedCompileUnit wrapper, CompilerParameters options, Language language) { //if (wrapper == null) // throw new ArgumentNullException("wrapper"); //if(options == null) // throw new ArgumentNullException("options"); //// compile it... //CompilerResults results = null; //switch(language) //{ // case Language.CSharp: // results = new CSharpCodeProvider().CompileAssemblyFromDom(options, unit); // break; // default: // throw new NotSupportedException(string.Format("Cannot handle '{0}' ({1}).", language, language.GetType())); //} //if(results == null) // throw new InvalidOperationException("results is null."); //// errors? //if(results.Errors.Count > 0) //{ // // save it... // string filePath = Runtime.Current.GetTempFilePath(GetCodeFileExtension(language)); // if(filePath == null) // throw new InvalidOperationException("'filePath' is null."); // if(filePath.Length == 0) // throw new InvalidOperationException("'filePath' is zero-length."); // Save(filePath, unit, language); // // throw... // throw new CompilationException("Failed to compile code unit.", results, filePath, null); //} //// return... //return results.CompiledAssembly; throw new NotImplementedException(); }
/// <summary> /// Compiles the given unit. /// </summary> /// <param name="unit"></param> /// <returns></returns> public static Assembly Compile(GeneratedCompileUnit unit, Language language) { return(Compile(unit, GetDefaultCompilerOptions(language), language)); }