internal static void ValidateAddedSharepointBinding(IEnumerable <string> addedBindings, IEnumerable <string> removedBindings, MultiValuedProperty <BindingMetadata> psObjectBindings, string subWorkloadName) { if (addedBindings.Any <string>()) { addedBindings = NewCompliancePolicyBase.ValidateWideScopeBinding(addedBindings, "All", "All", new BindingCannotCombineAllWithIndividualBindingsException(subWorkloadName)); if (NewCompliancePolicyBase.IsBindingEnabled(addedBindings, "All")) { psObjectBindings.Clear(); return; } List <string> bindings = (from b in psObjectBindings select b.ImmutableIdentity).ToList <string>(); if (NewCompliancePolicyBase.IsBindingEnabled(bindings, "All") && !NewCompliancePolicyBase.IsBindingEnabled(removedBindings, "All")) { throw new BindingCannotCombineAllWithIndividualBindingsException(subWorkloadName); } } }
internal static MultiValuedProperty <string> ValidateWideScopeBinding(IEnumerable <string> bindings, string wideScopeBindingName, string wideScopeBindingValue, Exception validationException) { if (NewCompliancePolicyBase.IsBindingEnabled(bindings, wideScopeBindingValue) && bindings.Count <string>() > 1) { throw validationException; } if (string.Compare(wideScopeBindingName, wideScopeBindingValue, StringComparison.InvariantCultureIgnoreCase) != 0) { List <string> list = new List <string>(bindings.Count <string>()); list.AddRange(bindings.Select(delegate(string binding) { if (string.Compare(binding, wideScopeBindingName, StringComparison.InvariantCultureIgnoreCase) != 0) { return(binding); } return(wideScopeBindingValue); })); return(new MultiValuedProperty <string>(list)); } return(new MultiValuedProperty <string>(bindings)); }