Esempio n. 1
0
        private void OnItemContextMenuInvokeHandler(object sender, EventArgs e)
        {
            var menuCommand = sender as MenuCommand;

            if (menuCommand == null)
            {
                return;
            }

            if (_dte2.SelectedItems.Count != 1)
            {
                return;
            }

            Type systemContextType;
            var  context = DiscoverUserContextType(out systemContextType);

            if (context != null)
            {
                if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidPrecompileEntityDataModelViews)
                {
                    _optimizeContextHandler.OptimizeContext(context);
                }
                else if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidViewEntityModelDdl)
                {
                    _viewDdlHandler.ViewDdl(context);
                }
                else
                {
                    _viewContextHandler.ViewContext(menuCommand, context, systemContextType);
                }
            }
        }
Esempio n. 2
0
        private void OnItemContextMenuInvokeHandler(object sender, EventArgs e)
        {
            var menuCommand = sender as MenuCommand;

            if (menuCommand == null)
            {
                return;
            }

            if (_dte2.SelectedItems.Count != 1)
            {
                return;
            }

            try
            {
                Type systemContextType;
                var  context = DiscoverUserContextType(out systemContextType);

                if (context != null)
                {
                    if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidPrecompileEntityDataModelViews)
                    {
                        _optimizeContextHandler.OptimizeContext(context);
                    }
                    else if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidViewEntityModelDdl)
                    {
                        _viewDdlHandler.ViewDdl(context);
                    }
                    else
                    {
                        _viewContextHandler.ViewContext(menuCommand, context, systemContextType);
                    }
                }
            }
            catch (TargetInvocationException ex)
            {
                var innerException = ex.InnerException;

                var remoteStackTraceString =
                    typeof(Exception).GetField("_remoteStackTraceString", BindingFlags.Instance | BindingFlags.NonPublic)
                    ?? typeof(Exception).GetField("remote_stack_trace", BindingFlags.Instance | BindingFlags.NonPublic);
                remoteStackTraceString.SetValue(innerException, innerException.StackTrace + "$$RethrowMarker$$");

                throw innerException;
            }
        }