Beispiel #1
0
        public void LoadActions()
        {
            try
            {
                if (this.engineManager == null || this.engineManager.IsDisposed)
                {
                    this.engineManager = new EngineManager(this);
                }

                this.engineManager.Clear();
                this.engineManager.Add(YuiCssEngine            = new YuiCssEngine());
                this.engineManager.Add(YuiJsEngine             = new YuiJsEngine());
                this.engineManager.Add(DeanEdwardsPackerEngine = new DeanEdwardsPackerEngine());
                this.engineManager.Add(ClosureCompilerEngine   = new ClosureCompilerEngine());
                this.engineManager.Add(LessEngine         = new LessEngine());
                this.engineManager.Add(MsJsEngine         = new MsJsEngine());
                this.engineManager.Add(MsCssEngine        = new MsCssEngine());
                this.engineManager.Add(ConfigEngine       = new ConfigEngine());
                this.engineManager.Add(ViewEngine         = new ViewEngine());
                this.engineManager.Add(T4Engine           = new T4Engine());
                this.engineManager.Add(CoffeeScriptEngine = new CoffeeScriptEngine());
                this.engineManager.Add(UglifyEngine       = new UglifyEngine());
                this.engineManager.Add(JSHintEngine       = new JSHintEngine());
                this.engineManager.Add(CSSLintEngine      = new CSSLintEngine());
                this.engineManager.Add(TypeScriptEngine   = new TypeScriptEngine());
                this.engineManager.Add(SassEngine         = new SassEngine());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Beispiel #2
0
        /// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary>
        /// <param name='commandName'>The name of the command to execute.</param>
        /// <param name='executeOption'>Describes how the command should be run.</param>
        /// <param name='varIn'>Parameters passed from the caller to the command handler.</param>
        /// <param name='varOut'>Parameters passed from the command handler to the caller.</param>
        /// <param name='handled'>Informs the caller if the command was handled or not.</param>
        public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
        {
            handled = false;

            if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
            {
                if (this.App != null)
                {
                    string fileToTry = string.Empty;

                    try {
                        if (commandName == COMMANDNAMESPACE + "." + POPUP_MENU_NAME_MINIFIER)
                        {
                            try {
                                ProjectItem projectItem = this.App.SelectedItems.Item(1).ProjectItem;
                                if (EngineManager.IsHandledWithoutHint(projectItem.FileName()))
                                {
                                    this.ProjectItemsEvents_ItemAdded(projectItem);
                                }
                                else
                                {
                                    string path            = projectItem.FileName();
                                    string code            = System.IO.File.ReadAllText(path);
                                    var    settings        = Settings.Instance(path);
                                    string outputExtension = settings.OutputExtensionJS;
                                    if (this.IsLessFile(path))
                                    {
                                        code            = LessEngine.TransformToCss(path, code, projectItem);
                                        outputExtension = settings.OutputExtensionCSS;
                                    }
                                    else if (this.IsCoffeeScriptFile(path))
                                    {
                                        code            = CoffeeScriptEngine.TransformToJs(path, code, projectItem);
                                        outputExtension = settings.OutputExtensionJS;
                                    }
                                    else if (this.IsSassFile(path))
                                    {
                                        code            = SassEngine.TransformToCss(path, code, projectItem);
                                        outputExtension = settings.OutputExtensionCSS;
                                    }
                                    else if (this.IsCssFile(path))
                                    {
                                        code            = CssEngine.Minify(path, code, projectItem, Xml.MinifyType.Unspecified);
                                        outputExtension = settings.OutputExtensionCSS;
                                    }
                                    else if (this.IsJsFile(path))
                                    {
                                        code            = JsEngine.Minify(path, code, projectItem, Xml.MinifyType.Unspecified, string.Empty);
                                        outputExtension = settings.OutputExtensionJS;
                                    }
                                    using (var manager = new Manager.VSProjectItemManager(this.App, projectItem))
                                    {
                                        manager.AddFileByFileName(Utilities.GetBaseFileName(path) + outputExtension, code);
                                    }
                                }
                            } catch (Exception e) {
                                this.OutputWindowWriteText(e.ToString());
                            }
                        }
                        else if (commandName == COMMANDNAMESPACE + "." + POPUP_MENU_NAME_JSHINT)
                        {
                            try {
                                ProjectItem projectItem = this.App.SelectedItems.Item(1).ProjectItem;
                                string      path        = projectItem.FileName();
                                JSHintEngine.Run(path, projectItem);
                            } catch (Exception e) {
                                this.OutputWindowWriteText(e.ToString());
                            }
                        }
                        else if (commandName == COMMANDNAMESPACE + "." + POPUP_MENU_NAME_CSSLINT)
                        {
                            try {
                                ProjectItem projectItem = this.App.SelectedItems.Item(1).ProjectItem;
                                string      path        = projectItem.FileName();
                                CSSLintEngine.Run(path, projectItem);
                            } catch (Exception e) {
                                this.OutputWindowWriteText(e.ToString());
                            }
                        }
                        else if (commandName == COMMANDNAMESPACE + "." + POPUP_MENU_NAME_TYPESCRIPT)
                        {
                            try
                            {
                                ProjectItem projectItem = this.App.SelectedItems.Item(1).ProjectItem;
                                string      path        = projectItem.FileName();
                                TypeScriptEngine.Run(path, projectItem);
                            }
                            catch (Exception e)
                            {
                                this.OutputWindowWriteText(e.ToString());
                            }
                        }
                    } catch (Exception ex) {
                        this.OutputWindowWriteText(string.Format("Error occured.\r\nFileName:\r\n{0}\r\nException details:\r\n{1}", fileToTry, ex));
                    } // try

                    handled = true;

                    return;
                }
            }
        } // Exec