/// <summary>
        /// Sets build integration setting in project.
        /// </summary>
        /// <param name="project">The MSBuild project.</param>
        /// <param name="buildIntegration">The build integration setting.</param>
        internal static void SetBuildIntegrationInProject(Microsoft.Build.BuildEngine.Project project, BuildIntegration buildIntegration)
        {
            Param.AssertNotNull(project, "project");
            Param.AssertNotNull(buildIntegration, "buildIntegration");

            SetBuildIntegrationInProject(project, buildIntegration != BuildIntegration.None);
            SetTreatLevel(project, buildIntegration);

            project.Save(project.FullFileName);
        }
        private static void SetTreatLevel(Microsoft.Build.BuildEngine.Project project, BuildIntegration buildIntegration)
        {
            Param.AssertNotNull(project, "project");
            Param.AssertNotNull(buildIntegration, "enable");

            switch (buildIntegration)
            {
                case BuildIntegration.None:
                    break;
                case BuildIntegration.TreatErrorAsWarning:
                    project.SetProperty(StyleCopTreatErrorsAsWarnings, true.ToString(), string.Empty);
                    break;
                case BuildIntegration.TreatErrorAsError:
                    project.SetProperty(StyleCopTreatErrorsAsWarnings, false.ToString(), string.Empty);
                    break;
                default:
                    throw new ArgumentOutOfRangeException("buildIntegration");
            }
        }