/// <summary>
        /// Initializes a new instance of the <see cref="RuleViewModel" /> class.
        /// </summary>
        /// <param name="rootProject">The root project this rule belongs to.</param>
        /// <param name="rule">The rule.</param>
        /// <param name="visualStudioService">The visual studio service.</param>
        /// <param name="uiVisualizerService">The UI visualizer service.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="rootProject" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="rootProject" /> is <c>null</c>.</exception>
        public RuleViewModel(RootProject rootProject, Rule rule, IVisualStudioService visualStudioService, IUIVisualizerService uiVisualizerService)
        {
            Argument.IsNotNull(() => rootProject);
            Argument.IsNotNull(() => rule);
            Argument.IsNotNull(() => visualStudioService);
            Argument.IsNotNull(() => uiVisualizerService);

            _uiVisualizerService = uiVisualizerService;

            var project = visualStudioService.GetProjectByName(rootProject.Name);
            if (project != null)
            {
                _rootProjectItem = new ProjectItem(project);
            }

            Rule = rule;

            RuleTypes = Enum<RuleType>.ToList();
            ProjectTypes = new ObservableCollection<SelectableProjectType>();

            foreach (var projectType in ProjectTypeHelper.GetAvailableProjectTypes())
            {
                bool isSelected = rule.ProjectTypes.Contains(projectType);
                var selectableProjectType = new SelectableProjectType(projectType, isSelected);
                this.SubscribeToWeakPropertyChangedEvent(selectableProjectType, OnSelectableProjectTypePropertyChanged);
                ProjectTypes.Add(selectableProjectType);
            }

            SelectProjectItem = new Command(OnSelectProjectItemExecute, OnSelectProjectItemCanExecute);
        }
        protected override bool Save()
        {
            var rootProject = _configuration.RootProjects.FirstOrDefault(project => string.Equals(RootProject, project.Name));
            if (rootProject == null)
            {
                rootProject = new RootProject();
                rootProject.Name = RootProject;
                _configuration.RootProjects.Add(rootProject);
            }

            foreach (var itemToAdd in ItemsToAdd)
            {
                bool alreadyContainsRule = (from rule in rootProject.Rules
                                            where string.Equals(rule.Name, itemToAdd)
                                            select rule).Any();
                if (!alreadyContainsRule)
                {
                    var rule = new Rule { Name = itemToAdd, Type = RuleType };

                    foreach (var selectableProjectType in ProjectTypes)
                    {
                        if (selectableProjectType.IsSelected)
                        {
                            rule.ProjectTypes.Add(selectableProjectType.ProjectType);
                        }
                    }

                    rootProject.Rules.Add(rule);
                }
            }

            return true;
        }
        /// <summary>
        /// Method to invoke when the Add command is executed.
        /// </summary>
        private void OnAddExecute()
        {
            var rule = new Rule();
            var vm = TypeFactory.Default.CreateInstanceWithParametersAndAutoCompletion<RuleViewModel>(RootProject, rule);

            if (_uiVisualizerService.ShowDialog(vm) ?? false)
            {
                Rules.Add(rule);
                SelectedRule = rule;
            }
        }