public void RegisterCommands(DTE dte, IMenuCommandService menuCommandService)
        {
            // Initialize "Inject Dependency" menu item.
            var injectDependencyCallback = new EventHandler((sender, e) =>
            {
                var injectDependencyCaption = "Inject Dependency";

                if (dte.ActiveDocument == null)
                {
                    DialogHelpers.Error("Open a code file first.", injectDependencyCaption);

                    return;
                }

                using (var injectDependencyDialog = new InjectDependencyDialog(_fieldNameGenerators))
                {
                    if (injectDependencyDialog.ShowDialog() == DialogResult.OK)
                    {
                        if (string.IsNullOrEmpty(injectDependencyDialog.DependencyName))
                        {
                            DialogHelpers.Warning("Dependency name cannot be empty.", injectDependencyCaption);

                            return;
                        }

                        if (string.IsNullOrEmpty(injectDependencyDialog.PrivateFieldName))
                        {
                            DialogHelpers.Warning("Private field name cannot be empty.", injectDependencyCaption);

                            return;
                        }

                        var result = _dependencyInjector.Inject(dte.ActiveDocument, injectDependencyDialog.DependencyName, injectDependencyDialog.PrivateFieldName);

                        if (!result.Success)
                        {
                            switch (result.ErrorCode)
                            {
                            case DependencyInjectorErrorCodes.ClassNotFound:
                                DialogHelpers.Warning("Could not inject depencency because the class was not found in this file.", injectDependencyCaption);
                                break;

                            default:
                                DialogHelpers.Warning("Could not inject dependency.", injectDependencyCaption);
                                break;
                            }
                        }
                    }
                }
            });

            menuCommandService.AddCommand(
                new MenuCommand(
                    injectDependencyCallback,
                    new CommandID(PackageGuids.LombiqOrchardVisualStudioExtensionCommandSetGuid, (int)CommandIds.InjectDependencyCommandId)));
        }
        private void MenuItemCallback(object sender, EventArgs e)
        {
            var injectDependencyCaption = "Inject Dependency";

            if (_dte.ActiveDocument == null)
            {
                DialogHelpers.Error("Open a code file first.", injectDependencyCaption);

                return;
            }

            using (var injectDependencyDialog = new InjectDependencyDialog(
                       _fieldNameGenerators,
                       _dependencyNameProviders,
                       _dependencyInjector.GetExpectedClassName(_dte.ActiveDocument)))
            {
                if (injectDependencyDialog.ShowDialog() == DialogResult.OK)
                {
                    var dependencyInjectionData = injectDependencyDialog.GetDependencyInjectionData();

                    if (string.IsNullOrEmpty(dependencyInjectionData.FieldName) ||
                        string.IsNullOrEmpty(dependencyInjectionData.FieldType) ||
                        string.IsNullOrEmpty(dependencyInjectionData.ConstructorParameterName) ||
                        string.IsNullOrEmpty(dependencyInjectionData.ConstructorParameterType))
                    {
                        DialogHelpers.Warning("Field and constructor parameter names and types must be filled.", injectDependencyCaption);

                        return;
                    }

                    var result = _dependencyInjector.Inject(
                        _dte.ActiveDocument,
                        injectDependencyDialog.GetDependencyInjectionData());

                    if (!result.Success)
                    {
                        switch (result.ErrorCode)
                        {
                        case DependencyInjectorErrorCodes.ClassNotFound:
                            DialogHelpers.Warning(
                                "Could not inject dependency because the class was not found in this file.",
                                injectDependencyCaption);
                            break;

                        default:
                            DialogHelpers.Warning("Could not inject dependency.", injectDependencyCaption);
                            break;
                        }
                    }
                }
            }
        }
        private void InjectDependencyCallback(object sender, EventArgs e)
        {
            var injectDependencyCaption = "Inject Dependency";

            if (_dte.ActiveDocument == null)
            {
                DialogHelpers.Error("Open a code file first.", injectDependencyCaption);

                return;
            }

            using (var injectDependencyDialog = new InjectDependencyDialog())
            {
                if (injectDependencyDialog.ShowDialog() == DialogResult.OK)
                {
                    if (string.IsNullOrEmpty(injectDependencyDialog.DependencyName))
                    {
                        DialogHelpers.Warning("Dependency name cannot be empty.", injectDependencyCaption);

                        return;
                    }

                    if (string.IsNullOrEmpty(injectDependencyDialog.PrivateFieldName))
                    {
                        DialogHelpers.Warning("Private field name cannot be empty.", injectDependencyCaption);

                        return;
                    }

                    var result = _dependencyInjector.Inject(_dte.ActiveDocument, injectDependencyDialog.DependencyName, injectDependencyDialog.PrivateFieldName);

                    if (!result.Success)
                    {
                        switch (result.ErrorCode)
                        {
                        case DependencyInjectorErrorCodes.ClassNotFound:
                            DialogHelpers.Warning("Could not inject depencency because the class was not found in this file.", injectDependencyCaption);
                            break;

                        case DependencyInjectorErrorCodes.ConstructorNotFound:
                            DialogHelpers.Warning("Could not inject depencency because the constructor was not found.", injectDependencyCaption);
                            break;

                        default:
                            DialogHelpers.Warning("Could not inject dependency.", injectDependencyCaption);
                            break;
                        }
                    }
                }
            }
        }