Example #1
0
        /// <summary>
        /// Requests a SourceUnit from the provided path and compiles it to a ScriptModule.
        ///
        /// If the host provides a SourceUnit which is equal to an already loaded SourceUnit the
        /// previously loaded module is returned.
        ///
        /// Returns null if a module could not be found.
        /// </summary>
        /// <exception cref="ArgumentNullException"><paramref name="path"/></exception>
        /// <exception cref="ArgumentException">no language registered</exception>
        /// <exception cref="MissingTypeException"><paramref name="languageId"/></exception>
        /// <exception cref="InvalidImplementationException">The language provider's implementation failed to instantiate.</exception>
        public ScriptModule UseModule(string path, string languageId)
        {
            Contract.RequiresNotNull(path, "path");
            ScriptEngine engine = GetLanguageProvider(languageId).GetEngine();

            SourceUnit su = _host.TryGetSourceFileUnit(engine, path, null);

            if (su == null)
            {
                return(null);
            }

            return(CompileAndPublishModule(Path.GetFileNameWithoutExtension(path), su));
        }
Example #2
0
 public SourceUnit TryGetSourceFileUnit(IScriptEngine engine, string path, Encoding encoding)
 {
     return(_host.TryGetSourceFileUnit(engine, path, encoding));
 }