Esempio n. 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);
            }
        }
Esempio n. 3
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern void sass_file_context_set_options(Sass_File_Context file_ctx, Sass_Options opt);
Esempio n. 4
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern Sass_Context sass_file_context_get_context(Sass_File_Context file_ctx);
Esempio n. 5
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern void sass_delete_file_context(Sass_File_Context ctx);
Esempio n. 6
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern Sass_Compiler sass_make_file_compiler(Sass_File_Context file_ctx);
Esempio n. 7
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern int sass_compile_file_context(Sass_File_Context ctx);