public override IPrecompiledScript PrecompileResource(string resourceName, Assembly assembly)
        {
            VerifyNotDisposed();

            if (resourceName == null)
            {
                throw new ArgumentNullException(
                          nameof(resourceName),
                          string.Format(CoreStrings.Common_ArgumentIsNull, nameof(resourceName))
                          );
            }

            if (assembly == null)
            {
                throw new ArgumentNullException(
                          nameof(assembly),
                          string.Format(CoreStrings.Common_ArgumentIsNull, nameof(assembly))
                          );
            }

            if (string.IsNullOrWhiteSpace(resourceName))
            {
                throw new ArgumentException(
                          string.Format(CoreStrings.Common_ArgumentIsEmpty, nameof(resourceName)),
                          nameof(resourceName)
                          );
            }

            if (!ValidationHelpers.CheckDocumentNameFormat(resourceName))
            {
                throw new ArgumentException(
                          string.Format(CoreStrings.Usage_InvalidResourceNameFormat, resourceName),
                          nameof(resourceName)
                          );
            }

            OriginalCompiledScript compiledScript;
            string uniqueDocumentName = GetUniqueDocumentName(resourceName, false);

            lock (_executionSynchronizer)
            {
                try
                {
                    var source = new ResourceScriptSource(uniqueDocumentName, resourceName, assembly);
                    compiledScript = _jsEngine.Compile(source);
                }
                catch (OriginalSyntaxException e)
                {
                    throw WrapSyntaxException(e);
                }
                catch (NullReferenceException)
                {
                    throw;
                }
            }

            return(new JurassicPrecompiledScript(compiledScript));
        }
        public override void ExecuteResource(string resourceName, Assembly assembly)
        {
            VerifyNotDisposed();

            if (resourceName == null)
            {
                throw new ArgumentNullException(
                          nameof(resourceName),
                          string.Format(CoreStrings.Common_ArgumentIsNull, nameof(resourceName))
                          );
            }

            if (assembly == null)
            {
                throw new ArgumentNullException(
                          nameof(assembly),
                          string.Format(CoreStrings.Common_ArgumentIsNull, nameof(assembly))
                          );
            }

            if (string.IsNullOrWhiteSpace(resourceName))
            {
                throw new ArgumentException(
                          string.Format(CoreStrings.Common_ArgumentIsEmpty, nameof(resourceName)),
                          nameof(resourceName)
                          );
            }

            if (!ValidationHelpers.CheckDocumentNameFormat(resourceName))
            {
                throw new ArgumentException(
                          string.Format(CoreStrings.Usage_InvalidResourceNameFormat, resourceName),
                          nameof(resourceName)
                          );
            }

            string uniqueDocumentName = _documentNameManager.GetUniqueName(resourceName);

            lock (_executionSynchronizer)
            {
                try
                {
                    var source = new ResourceScriptSource(uniqueDocumentName, resourceName, assembly);
                    _jsEngine.Execute(source);
                }
                catch (OriginalJavaScriptException e)
                {
                    throw WrapJavaScriptException(e);
                }
                catch (NullReferenceException)
                {
                    throw;
                }
            }
        }
        public override void ExecuteResource(string resourceName, Type type)
        {
            VerifyNotDisposed();

            if (resourceName == null)
            {
                throw new ArgumentNullException(
                          "resourceName", string.Format(CoreStrings.Common_ArgumentIsNull, "resourceName"));
            }

            if (type == null)
            {
                throw new ArgumentNullException(
                          "type", string.Format(CoreStrings.Common_ArgumentIsNull, "type"));
            }

            if (string.IsNullOrWhiteSpace(resourceName))
            {
                throw new ArgumentException(
                          string.Format(CoreStrings.Common_ArgumentIsEmpty, "resourceName"), "resourceName");
            }

            Assembly assembly           = type.GetTypeInfo().Assembly;
            string   nameSpace          = type.Namespace;
            string   resourceFullName   = nameSpace != null ? nameSpace + "." + resourceName : resourceName;
            string   uniqueDocumentName = GetUniqueDocumentName(resourceFullName, false);

            lock (_executionSynchronizer)
            {
                try
                {
                    var source = new ResourceScriptSource(uniqueDocumentName, resourceFullName, assembly);
                    _jsEngine.Execute(source);
                }
                catch (OriginalJsException e)
                {
                    throw ConvertJavascriptExceptionToJsRuntimeException(e);
                }
            }
        }
        public override void ExecuteResource(string resourceName, Type type)
        {
            VerifyNotDisposed();

            if (resourceName == null)
            {
                throw new ArgumentNullException(
                          nameof(resourceName),
                          string.Format(CoreStrings.Common_ArgumentIsNull, nameof(resourceName))
                          );
            }

            if (type == null)
            {
                throw new ArgumentNullException(
                          nameof(type),
                          string.Format(CoreStrings.Common_ArgumentIsNull, nameof(type))
                          );
            }

            if (string.IsNullOrWhiteSpace(resourceName))
            {
                throw new ArgumentException(
                          string.Format(CoreStrings.Common_ArgumentIsEmpty, nameof(resourceName)),
                          nameof(resourceName)
                          );
            }

            if (!ValidationHelpers.CheckDocumentNameFormat(resourceName))
            {
                throw new ArgumentException(
                          string.Format(CoreStrings.Usage_InvalidResourceNameFormat, resourceName),
                          nameof(resourceName)
                          );
            }

#if NET40
            Assembly assembly = type.Assembly;
#else
            Assembly assembly = type.GetTypeInfo().Assembly;
#endif
            string nameSpace          = type.Namespace;
            string resourceFullName   = nameSpace != null ? nameSpace + "." + resourceName : resourceName;
            string uniqueDocumentName = GetUniqueDocumentName(resourceFullName, false);

            lock (_executionSynchronizer)
            {
                try
                {
                    var source = new ResourceScriptSource(uniqueDocumentName, resourceFullName, assembly);
                    _jsEngine.Execute(source);
                }
                catch (OriginalJavaScriptException e)
                {
                    throw WrapJavaScriptException(e);
                }
                catch (NullReferenceException)
                {
                    throw;
                }
            }
        }
        public override IPrecompiledScript PrecompileResource(string resourceName, Type type)
        {
            VerifyNotDisposed();

            if (resourceName == null)
            {
                throw new ArgumentNullException(
                          nameof(resourceName),
                          string.Format(CoreStrings.Common_ArgumentIsNull, nameof(resourceName))
                          );
            }

            if (type == null)
            {
                throw new ArgumentNullException(
                          nameof(type),
                          string.Format(CoreStrings.Common_ArgumentIsNull, nameof(type))
                          );
            }

            if (string.IsNullOrWhiteSpace(resourceName))
            {
                throw new ArgumentException(
                          string.Format(CoreStrings.Common_ArgumentIsEmpty, nameof(resourceName)),
                          nameof(resourceName)
                          );
            }

            if (!ValidationHelpers.CheckDocumentNameFormat(resourceName))
            {
                throw new ArgumentException(
                          string.Format(CoreStrings.Usage_InvalidResourceNameFormat, resourceName),
                          nameof(resourceName)
                          );
            }

#if NET40
            Assembly assembly = type.Assembly;
#else
            Assembly assembly = type.GetTypeInfo().Assembly;
#endif
            string nameSpace        = type.Namespace;
            string resourceFullName = nameSpace != null ? nameSpace + "." + resourceName : resourceName;

            OriginalCompiledScript compiledScript;
            string uniqueDocumentName = _documentNameManager.GetUniqueName(resourceFullName);

            lock (_executionSynchronizer)
            {
                try
                {
                    var source = new ResourceScriptSource(uniqueDocumentName, resourceFullName, assembly);
                    compiledScript = OriginalCompiledScript.Compile(source);
                }
                catch (OriginalSyntaxException e)
                {
                    throw WrapSyntaxException(e);
                }
                catch (NullReferenceException)
                {
                    throw;
                }
            }

            return(new JurassicPrecompiledScript(compiledScript));
        }