Example #1
0
        public static void CompileFile(SassFileContext fileContext)
        {
            Sass_File_Context file_ctx         = Sass_Api.sass_make_file_context(fileContext.InputPath);
            Sass_Options      file_ctx_options = Sass_Api.sass_file_context_get_options(file_ctx);

            FillUnmanagedContextOptions(ref file_ctx_options, fileContext);

            try
            {
                // Compile Sass file by using context
                int result = Sass_Api.sass_compile_file_context(file_ctx);

                // Copy resulting fields from unmanaged object to managed
                Sass_Context base_ctx = Sass_Api.sass_file_context_get_context(file_ctx);
                if (result == 0)
                {
                    FillManagedContextOutput(fileContext, ref base_ctx);
                }
                else
                {
                    FillManagedContextError(fileContext, ref base_ctx);
                }
            }
            finally
            {
                // Free resources
                Sass_Api.sass_delete_file_context(file_ctx);
            }
        }
        public static void CompileFile(SassFileContext fileContext)
        {
            Sass_File_Context file_ctx         = Sass_Api.sass_make_file_context(fileContext.InputPath);
            Sass_Options      file_ctx_options = Sass_Api.sass_file_context_get_options(file_ctx);

            FillUnmanagedContextOptions(ref file_ctx_options, fileContext);

            try
            {
                // Compile Sass-file by using context
                int result = Sass_Api.sass_compile_file_context(file_ctx);

                // Copy resulting fields from unmanaged object to managed
                Sass_Context base_ctx = Sass_Api.sass_file_context_get_context(file_ctx);
                if (result == 0)
                {
                    FillManagedContextOutput(fileContext, ref base_ctx);
                }
                else
                {
                    FillManagedContextError(fileContext, 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_file_context(file_ctx);
            }
        }