Exemplo 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);
            }
        }
        private static void FillUnmanagedContextOptions(ref Sass_Options ctx_options, SassContextBase context)
        {
            SassOptions options = context.Options;

            foreach (string importExtension in options.AdditionalImportExtensions)
            {
                Sass_Api.sass_option_push_import_extension(ctx_options, importExtension);
            }

            Sass_Api.sass_option_set_include_path(ctx_options, options.IncludePath);
            Sass_Api.sass_option_set_indent(ctx_options, options.Indent);
            Sass_Api.sass_option_set_input_path(ctx_options, context.InputPath);
            Sass_Api.sass_option_set_is_indented_syntax_src(ctx_options, context.IsIndentedSyntaxSource);
            Sass_Api.sass_option_set_linefeed(ctx_options, options.LineFeed);
            Sass_Api.sass_option_set_omit_source_map_url(ctx_options, options.OmitSourceMapUrl);
            Sass_Api.sass_option_set_output_path(ctx_options, context.OutputPath);
            Sass_Api.sass_option_set_output_style(ctx_options, (Sass_Output_Style)options.OutputStyle);
            Sass_Api.sass_option_set_precision(ctx_options, options.Precision);
            Sass_Api.sass_option_set_source_comments(ctx_options, options.SourceComments);
            Sass_Api.sass_option_set_source_map_contents(ctx_options, options.SourceMapContents);
            Sass_Api.sass_option_set_source_map_embed(ctx_options, options.SourceMapEmbed);
            Sass_Api.sass_option_set_source_map_file(ctx_options, context.SourceMapFile);
            Sass_Api.sass_option_set_source_map_file_urls(ctx_options, options.SourceMapFileUrls);
            Sass_Api.sass_option_set_source_map_root(ctx_options, options.SourceMapRoot);
        }
Exemplo n.º 3
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 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);
            }
        }
Exemplo n.º 5
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern ScssOutputStyle sass_option_get_output_style(Sass_Options options);
Exemplo n.º 6
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern bool sass_option_get_source_map_contents(Sass_Options options);
Exemplo n.º 7
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern void sass_data_context_set_options(Sass_Data_Context data_ctx, Sass_Options opt);
Exemplo n.º 8
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern int sass_option_get_precision(Sass_Options options);
Exemplo n.º 9
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern void sass_option_set_c_functions(Sass_Options options, Sass_Function_List c_functions);
Exemplo n.º 10
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern void sass_option_push_include_path(Sass_Options options, StringUtf8 path);
Exemplo n.º 11
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern void sass_option_set_source_map_root(Sass_Options options, StringUtf8 source_map_root);
Exemplo n.º 12
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern void sass_option_set_precision(Sass_Options options, int precision);
Exemplo n.º 13
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern void sass_option_set_linefeed(Sass_Options options, StringUtf8 linefeed);
Exemplo n.º 14
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern StringUtf8 sass_option_get_source_map_file(Sass_Options options);
Exemplo n.º 15
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern void sass_option_set_is_indented_syntax_src(Sass_Options options,
                                                                                                                                       bool is_indented_syntax_src);
Exemplo n.º 16
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern void sass_option_set_omit_source_map_url(Sass_Options options, bool omit_source_map_url);
Exemplo n.º 17
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern void sass_option_set_source_comments(Sass_Options options, bool source_comments);
Exemplo n.º 18
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern StringUtf8 sass_option_get_include_path(Sass_Options options);
Exemplo n.º 19
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern void sass_option_set_c_headers(Sass_Options options, Sass_Importer_List c_headers);
Exemplo n.º 20
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern void sass_option_set_output_path(Sass_Options options, StringUtf8 output_path);
Exemplo n.º 21
0
 [DllImport(LibSassDll, CallingConvention = CallingConvention.Cdecl)] public static extern Sass_Importer_List sass_option_get_c_importers(Sass_Options options);