Esempio n. 1
0
        /// <summary>
        /// Initializes a Sass compiler
        /// </summary>
        private static void Initialize()
        {
            if (_initialized)
            {
                return;
            }

            lock (_initializationSynchronizer)
            {
                if (_initialized)
                {
                    return;
                }

                try
                {
                    _version         = SassCompilerProxy.GetVersion();
                    _languageVersion = SassCompilerProxy.GetLanguageVersion();
                }
                catch (DllNotFoundException e)
                {
                    throw WrapDllNotFoundException(e);
                }
#if NETSTANDARD1_3
                catch (TypeLoadException e)
#else
                catch (EntryPointNotFoundException e)
#endif
                {
                    string message = e.Message;
                    if (message.ContainsQuotedValue(DllName.Universal) &&
                        (message.ContainsQuotedValue("libsass_version") || message.ContainsQuotedValue("libsass_language_version")))
                    {
                        _version         = "0.0.0";
                        _languageVersion = "0.0";
                    }
                    else
                    {
                        throw SassErrorHelpers.WrapCompilerLoadException(e, true);
                    }
                }
                catch (Exception e)
                {
                    throw SassErrorHelpers.WrapCompilerLoadException(e, true);
                }

                _initialized = true;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Static constructor
        /// </summary>
        /// <exception cref="SassCompilerLoadException">Failed to load a Sass-compiler.</exception>
        static SassCompiler()
        {
#if !NETSTANDARD
            if (Utils.IsWindows())
            {
                AssemblyResolver.Initialize();
            }
#endif
            try
            {
                _version         = SassCompilerProxy.GetVersion();
                _languageVersion = SassCompilerProxy.GetLanguageVersion();
            }
            catch (DllNotFoundException e)
            {
                throw new SassCompilerLoadException(Strings.Runtime_SassCompilerNotLoaded, e);
            }
        }