public abstract useStatement ( string assemblyName ) : string | ||
assemblyName | string | /// The name of the assembly to be treated as local /// |
Результат | string |
/// <summary> /// Compiles a type (or class) from the provided source with the parameters specified. /// </summary> /// <param name="compiler"> /// The compiler to use for compiling the source to MSIL. /// </param> /// <param name="typeSource"> /// The actual source of the type. /// </param> /// <param name="typeName"> /// The name of the type. /// </param> /// <param name="options"> /// The parameters to be set for the compiler. /// </param> /// <param name="language"> /// A specification of the syntax of the language of the code /// </param> /// <returns> /// The resulting type and any warnings produced by the compiler, wrapped in a TypeResults object. /// </returns> /// <exception cref="CompilationException"/> public static TypeResults CreateType(ICodeCompiler compiler, string typeSource, string typeName, CompilerParameters options, Language language) { string namespaceName = options.OutputAssembly; if (namespaceName == null) { namespaceName = "Evaluated"; } StringBuilder sourceBuilder = new StringBuilder(); foreach (string referenced in options.ReferencedAssemblies) { sourceBuilder.Append(language.useStatement(referenced.Replace(".dll", ""))); } sourceBuilder.Append(language.beginNamespace(namespaceName)); sourceBuilder.Append(typeSource); sourceBuilder.Append(language.endNamespace(namespaceName)); AssemblyResults compiled = CreateAssembly(compiler, sourceBuilder.ToString(), options, language); return(compiled.GetType(namespaceName + "." + typeName, true)); }
/// <summary> /// Compiles a type (or class) from the provided source with the parameters specified. /// </summary> /// <param name="compiler"> /// The compiler to use for compiling the source to MSIL. /// </param> /// <param name="typeSource"> /// The actual source of the type. /// </param> /// <param name="typeName"> /// The name of the type. /// </param> /// <param name="options"> /// The parameters to be set for the compiler. /// </param> /// <param name="language"> /// A specification of the syntax of the language of the code /// </param> /// <returns> /// The resulting type and any warnings produced by the compiler, wrapped in a TypeResults object. /// </returns> /// <exception cref="CompilationException"/> public static TypeResults CreateType(ICodeCompiler compiler, string typeSource, string typeName, CompilerParameters options, Language language) { string namespaceName = options.OutputAssembly; if(namespaceName == null) namespaceName = "Evaluated"; StringBuilder sourceBuilder = new StringBuilder(); foreach(string referenced in options.ReferencedAssemblies) { sourceBuilder.Append(language.useStatement(referenced.Replace(".dll", ""))); } sourceBuilder.Append(language.beginNamespace(namespaceName)); sourceBuilder.Append(typeSource); sourceBuilder.Append(language.endNamespace(namespaceName)); AssemblyResults compiled = CreateAssembly(compiler, sourceBuilder.ToString(), options, language); return compiled.GetType(namespaceName + "." + typeName, true); }