Пример #1
0
        /// <summary>
        /// This method returns a ScriptSource with the content provider supplied with the current engine as the language binding.
        ///
        /// This helper lets you own the content provider so that you can implement a stream over internal host data structures, such as an editor's text representation.
        /// </summary>
        public ScriptSource CreateScriptSource(TextContentProvider contentProvider, string path, SourceCodeKind kind)
        {
            ContractUtils.RequiresNotNull(contentProvider, "contentProvider");
            ContractUtils.Requires(EnumBounds.IsValid(kind), "kind");
            if (!_language.CanCreateSourceCode)
            {
                throw new NotSupportedException("Invariant engine cannot create scripts");
            }

            return(new ScriptSource(this, _language.CreateSourceUnit(contentProvider, path, kind)));
        }
        /// <summary>
        /// This method returns a ScriptSource with the content provider supplied with the current engine as the language binding.
        ///
        /// This helper lets you own the content provider so that you can implement a stream over internal host data structures, such as an editor's text representation.
        /// </summary>
        public ScriptSource CreateScriptSource(TextContentProvider contentProvider, string path, SourceCodeKind kind)
        {
            ContractUtils.RequiresNotNull(contentProvider, nameof(contentProvider));
            ContractUtils.Requires(kind.IsValid(), nameof(kind));
            if (!LanguageContext.CanCreateSourceCode)
            {
                throw new NotSupportedException("Invariant engine cannot create scripts");
            }

            return(new ScriptSource(this, LanguageContext.CreateSourceUnit(contentProvider, path, kind)));
        }