protected override IConfigurable PrepareDataObject() { TaskLogger.LogEnter(); ActiveSyncOrganizationSettings activeSyncOrganizationSettings = (ActiveSyncOrganizationSettings)base.PrepareDataObject(); if (base.Fields.IsModified("ParameterSetAddDeviceFilterRule") && this.AddDeviceFilterRule) { this.ValidateDeviceFilterNameParameter(); this.ValidateDeviceFilterRuleNameParameter(); ActiveSyncDeviceFilterRule newRule = new ActiveSyncDeviceFilterRule(this.DeviceFilterRuleName, this.DeviceFilterCharacteristic, this.DeviceFilterOperator, this.DeviceFilterValue); activeSyncOrganizationSettings.DeviceFiltering = this.AddDeviceFilterRuleToExisting(activeSyncOrganizationSettings.DeviceFiltering, this.DeviceFilterName, newRule, false); } else if (base.Fields.IsModified("ParameterSetAddDeviceFilterRuleForAllDevices") && this.AddDeviceFilterRuleForAllDevices) { this.ValidateDeviceFilterNameParameter(); activeSyncOrganizationSettings.DeviceFiltering = this.AddDeviceFilterRuleToExisting(activeSyncOrganizationSettings.DeviceFiltering, this.DeviceFilterName, null, true); } else if (base.Fields.IsModified("ParameterSetRemoveDeviceFilterRule") && this.RemoveDeviceFilterRule) { this.ValidateDeviceFilterNameParameter(); this.ValidateDeviceFilterRuleNameParameter(); activeSyncOrganizationSettings.DeviceFiltering = this.RemoveDeviceFilterRuleFromExisting(activeSyncOrganizationSettings.DeviceFiltering, this.DeviceFilterName, this.DeviceFilterRuleName, this.DeviceFilterCharacteristic); } else if (base.Fields.IsModified("ParameterSetRemoveDeviceFilter") && this.RemoveDeviceFilter) { this.ValidateDeviceFilterNameParameter(); activeSyncOrganizationSettings.DeviceFiltering = this.RemoveDeviceFilterFromExisting(activeSyncOrganizationSettings.DeviceFiltering, this.DeviceFilterName); } TaskLogger.LogExit(); return(activeSyncOrganizationSettings); }
// Token: 0x060005BB RID: 1467 RVA: 0x000221F0 File Offset: 0x000203F0 private static bool IsRuleValueMatch(ActiveSyncDeviceFilterRule rule, string actualValue) { switch (rule.Operator) { case DeviceFilterOperator.Equals: return(string.Equals(actualValue, rule.Value, StringComparison.OrdinalIgnoreCase)); case DeviceFilterOperator.Contains: return(AirSyncUtility.AreNotNullOrEmptyAndContains(actualValue, rule.Value)); case DeviceFilterOperator.StartsWith: return(AirSyncUtility.AreNotNullOrEmptyAndStartsWith(actualValue, rule.Value)); case DeviceFilterOperator.Regex: return(AirSyncUtility.AreNotNullOrEmptyAndRegexMatches(actualValue, rule.Value, RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariant)); default: throw new DeviceFilterInvalidException(EASServerStrings.InvalidDeviceFilterOperatorError(rule.Operator.ToString())); } }
private ActiveSyncDeviceFilterArray AddDeviceFilterRuleToExisting(ActiveSyncDeviceFilterArray existingDeviceFilterArray, string deviceFilterName, ActiveSyncDeviceFilterRule newRule, bool applyFilterForAllDevices) { ActiveSyncDeviceFilterArray activeSyncDeviceFilterArray = new ActiveSyncDeviceFilterArray(); if (existingDeviceFilterArray != null) { activeSyncDeviceFilterArray.DeviceFilters = existingDeviceFilterArray.DeviceFilters; } List <ActiveSyncDeviceFilter> list = activeSyncDeviceFilterArray.DeviceFilters; if (list == null) { list = new List <ActiveSyncDeviceFilter>(); activeSyncDeviceFilterArray.DeviceFilters = list; } ActiveSyncDeviceFilter activeSyncDeviceFilter = list.FirstOrDefault((ActiveSyncDeviceFilter existingDeviceFilter) => existingDeviceFilter.Name.Equals(deviceFilterName, StringComparison.InvariantCultureIgnoreCase)); if (activeSyncDeviceFilter == null) { activeSyncDeviceFilter = new ActiveSyncDeviceFilter(deviceFilterName, new List <ActiveSyncDeviceFilterRule>()); list.Add(activeSyncDeviceFilter); } if (applyFilterForAllDevices) { activeSyncDeviceFilter.ApplyForAllDevices = applyFilterForAllDevices; base.WriteVerbose(Strings.AddedDeviceFilterRule(deviceFilterName)); return(activeSyncDeviceFilterArray); } if (activeSyncDeviceFilter.ApplyForAllDevices) { base.WriteError(new InvalidOperationException(Strings.CantAddDeviceFilterRuleSinceApplyForAllDevicesSetToTrue(deviceFilterName)), ErrorCategory.InvalidOperation, null); } List <ActiveSyncDeviceFilterRule> rules = activeSyncDeviceFilter.Rules; if (!rules.Any((ActiveSyncDeviceFilterRule rule) => rule.Characteristic == newRule.Characteristic && rule.Name.Equals(newRule.Name, StringComparison.InvariantCultureIgnoreCase))) { rules.Add(newRule); base.WriteVerbose(Strings.AddedDeviceFilterRule(deviceFilterName)); } else { base.WriteError(new ArgumentException(Strings.DeviceFilterRuleAlreadyExists(deviceFilterName)), ErrorCategory.InvalidArgument, null); } return(activeSyncDeviceFilterArray); }