internal NonInteractiveScope( TemplateWizardContext context, Action<TemplateWizardContext, bool> transition )
        {
            Contract.Requires( context != null );
            Contract.Requires( transition != null );

            this.context = context;
            restore = context.IsInteractive;
            this.transition = transition;
            this.transition( this.context, false );
        }
Example #2
0
        public void RunStarted( object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams )
        {
            dte = (DTE) automationObject;
            dte.StatusBar.Clear();
            context = new TemplateWizardContext( (IOleServiceProvider) automationObject, replacementsDictionary );
            context.AddService( typeof( IProjectItemNameValidator ), ( s, t ) => new ProjectItemNameValidator( Project ) );

            var shell = context.GetRequiredService<IVsUIShell>();

            try
            {
                // try running the wizard. most errors should be handled by the wizard, but a few (such as XAML parsing errors),
                // might not get handled. ensure they are always handled here
                if ( TryRunWizard( shell ) )
                    return;
            }
            catch ( Exception ex )
            {
                var aggregateEx = ex as AggregateException;

                if ( aggregateEx != null )
                    ex = aggregateEx.GetBaseException();

                // this might happen if there is something wrong in the XAML. all other errors should be handled by the view model
                shell.ShowError( ExceptionMessage.TemplateWizardErrorCaption, ex.Message );
            }

            dte.StatusBar.Clear();
            OnCanceled();
        }
Example #3
0
        /// <summary>
        /// Releases the managed and, optionally, the unmanaged resources used by the <see cref="TemplateWizard"/> class.
        /// </summary>
        /// <param name="disposing">Indicates whether the object is being disposed.</param>
        protected virtual void Dispose( bool disposing )
        {
            if ( disposed )
                return;

            disposed = true;

            if ( !disposing )
                return;

            dte = null;

            if ( context == null )
                return;

            context.Dispose();
            context = null;
        }