/// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            try
            {
                base.Initialize();
                Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", ToString()));


                //create the dte automation object so rest of package can access the automation model
                Dte = (DTE2)GetService(typeof(DTE));
                if (Dte == null)
                {
                    //if dte is null then we throw a excpetion
                    //this is a fatal error
                    throw new ArgumentNullException(Resources.ErrorDTENull);
                }

                VSVersion = Dte.Version;


                Logger   = new Logger(this);
                Settings = GetDialogPage(typeof(SnippetDesignerOptions)) as SnippetDesignerOptions;

                //Create Editor Factory
                editorFactory = new EditorFactory(this);
                RegisterEditorFactory(editorFactory);


                //Set up Selection Events so that I can tell when a new window in VS has become active.
                uint cookieForSelection = 0;
                var  selMonitor         = GetService(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection;

                if (selMonitor != null)
                {
                    selMonitor.AdviseSelectionEvents(this, out cookieForSelection);
                }


                // Add our command handlers for menu (commands must exist in the .vstc file)

                // Create the command for the tool window
                var snippetExplorerCommandID = new CommandID(GuidList.SnippetDesignerCmdSet,
                                                             (int)PkgCmdIDList.cmdidSnippetExplorer);
                DefineCommandHandler(ShowSnippetExplorer, snippetExplorerCommandID);


                //DefineCommandHandler not used for these since extra properties need to be set
                // Create the command for the context menu export snippet
                var contextcmdID = new CommandID(GuidList.SnippetDesignerCmdSet,
                                                 (int)PkgCmdIDList.cmdidExportToSnippet);
                snippetExportCommand         = DefineCommandHandler(ExportToSnippet, contextcmdID);
                snippetExportCommand.Visible = false;

                // commandline command for exporting as snippet
                var exportCmdLineID = new CommandID(GuidList.SnippetDesignerCmdSet,
                                                    (int)PkgCmdIDList.cmdidExportToSnippetCommandLine);
                OleMenuCommand snippetExportCommandLine = DefineCommandHandler(ExportToSnippet, exportCmdLineID);
                snippetExportCommandLine.ParametersDescription = StringConstants.ArgumentStartMarker;
                //a space means arguments are coming


                // Create the command for CreateSnippet
                var createcmdID = new CommandID(GuidList.SnippetDesignerCmdSet,
                                                (int)PkgCmdIDList.cmdidCreateSnippet);
                OleMenuCommand createCommand = DefineCommandHandler(CreateSnippet, createcmdID);
                createCommand.ParametersDescription = StringConstants.ArgumentStartMarker;

                //initialize the snippet index
                SnippetIndex = new SnippetIndex();
                ThreadPool.QueueUserWorkItem(
                    delegate
                {
                    SnippetIndex.ReadIndexFile();
                    SnippetIndex.CreateOrUpdateIndexFile();
                }
                    );
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                throw;
            }
        }
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            try
            {
                base.Initialize();
                Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", ToString()));

                //create the dte automation object so rest of package can access the automation model
                Dte = (DTE2)GetService(typeof(DTE));
                if (Dte == null)
                {
                    //if dte is null then we throw a excpetion
                    //this is a fatal error
                    throw new ArgumentNullException(Resources.ErrorDTENull);
                }

                VSVersion = Dte.Version;

                Logger = new Logger(this);
                Settings = GetDialogPage(typeof(SnippetDesignerOptions)) as SnippetDesignerOptions;

                //Create Editor Factory
                editorFactory = new EditorFactory(this);
                RegisterEditorFactory(editorFactory);

                //Set up Selection Events so that I can tell when a new window in VS has become active.
                uint cookieForSelection = 0;
                var selMonitor = GetService(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection;

                if (selMonitor != null)
                    selMonitor.AdviseSelectionEvents(this, out cookieForSelection);

                // Add our command handlers for menu (commands must exist in the .vstc file)

                // Create the command for the tool window
                var snippetExplorerCommandID = new CommandID(GuidList.SnippetDesignerCmdSet,
                                                             (int)PkgCmdIDList.cmdidSnippetExplorer);
                DefineCommandHandler(ShowSnippetExplorer, snippetExplorerCommandID);

                //DefineCommandHandler not used for these since extra properties need to be set
                // Create the command for the context menu export snippet
                var contextcmdID = new CommandID(GuidList.SnippetDesignerCmdSet,
                                                 (int)PkgCmdIDList.cmdidExportToSnippet);
                snippetExportCommand = DefineCommandHandler(ExportToSnippet, contextcmdID);
                snippetExportCommand.Visible = false;

                // commandline command for exporting as snippet
                var exportCmdLineID = new CommandID(GuidList.SnippetDesignerCmdSet,
                                                    (int)PkgCmdIDList.cmdidExportToSnippetCommandLine);
                OleMenuCommand snippetExportCommandLine = DefineCommandHandler(ExportToSnippet, exportCmdLineID);
                snippetExportCommandLine.ParametersDescription = StringConstants.ArgumentStartMarker;
                //a space means arguments are coming

                // Create the command for CreateSnippet
                var createcmdID = new CommandID(GuidList.SnippetDesignerCmdSet,
                                                (int)PkgCmdIDList.cmdidCreateSnippet);
                OleMenuCommand createCommand = DefineCommandHandler(CreateSnippet, createcmdID);
                createCommand.ParametersDescription = StringConstants.ArgumentStartMarker;

                //initialize the snippet index
                SnippetIndex = new SnippetIndex();
                ThreadPool.QueueUserWorkItem(
                    delegate
                    {
                        SnippetIndex.ReadIndexFile();
                        SnippetIndex.CreateOrUpdateIndexFile();
                    }
                    );
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                throw;
            }
        }