endNamespace() public abstract method

Generates a statement to end a namespace
public abstract endNamespace ( string namespaceName ) : string
namespaceName string /// The name of the namespace ///
return string
コード例 #1
0
ファイル: Eval.cs プロジェクト: xiaoxiongnpu/SwarmNLP
        /// <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));
        }
コード例 #2
0
ファイル: Eval.cs プロジェクト: swax/SwarmNLP
        /// <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);
        }