Exemple #1
0
        public static void Compile(SassDataContext dataContext)
        {
            Sass_Data_Context data_ctx         = Sass_Api.sass_make_data_context(dataContext.SourceString);
            Sass_Options      data_ctx_options = Sass_Api.sass_data_context_get_options(data_ctx);

            FillUnmanagedContextOptions(ref data_ctx_options, dataContext);

            try
            {
                // Compile Sass code by using context
                int result = Sass_Api.sass_compile_data_context(data_ctx);

                // Copy resulting fields from unmanaged object to managed
                Sass_Context base_ctx = Sass_Api.sass_data_context_get_context(data_ctx);
                if (result == 0)
                {
                    FillManagedContextOutput(dataContext, ref base_ctx);
                }
                else
                {
                    FillManagedContextError(dataContext, ref base_ctx);
                }
            }
            finally
            {
                // Free resources
                Sass_Api.sass_delete_data_context(data_ctx);
            }
        }
        public static void Compile(SassDataContext dataContext)
        {
            Sass_Data_Context data_ctx         = Sass_Api.sass_make_data_context(dataContext.SourceString);
            Sass_Options      data_ctx_options = Sass_Api.sass_data_context_get_options(data_ctx);

            FillUnmanagedContextOptions(ref data_ctx_options, dataContext);

            try
            {
                // Compile Sass-code by using context
                int result = Sass_Api.sass_compile_data_context(data_ctx);

                // Copy resulting fields from unmanaged object to managed
                Sass_Context base_ctx = Sass_Api.sass_data_context_get_context(data_ctx);
                if (result == 0)
                {
                    FillManagedContextOutput(dataContext, ref base_ctx);
                }
                else
                {
                    FillManagedContextError(dataContext, ref base_ctx);
                }
            }
            catch (TargetInvocationException e)
            {
                Exception innerException = e.InnerException;
                if (innerException != null)
                {
#if NET45 || NETSTANDARD
                    ExceptionDispatchInfo.Capture(innerException).Throw();
#elif NET40
                    innerException.PreserveStackTrace();
                    throw innerException;
#else
#error No implementation for this target
#endif
                }

                throw;
            }
            finally
            {
                // Free resources
                Sass_Api.sass_delete_data_context(data_ctx);
            }
        }