protected override void InitializeScopeProperties(IConfigSchema schema) { if (this.scopePropertiesInitialized) { return; } lock (this.locker) { if (!this.scopePropertiesInitialized) { if (schema.ScopeSchema != null) { List <PropertyDefinition> list = new List <PropertyDefinition>(base.AllProperties); foreach (string name in schema.ScopeSchema.Settings) { ConfigurationProperty scopeProperty = schema.ScopeSchema.GetConfigurationProperty(name, null); list.Add(new SettingsScopeFilterSchema.ScopeFilterPropertyDefinition(scopeProperty.Name, scopeProperty.Type, scopeProperty.DefaultValue, delegate(ISettingsContext ctx) { object result; if (!ExchangeConfigurationSection.TryConvertFromInvariantString(scopeProperty, ctx.GetGenericProperty(scopeProperty.Name), out result)) { result = null; } return(result); })); } base.AllProperties = new ReadOnlyCollection <PropertyDefinition>(list); base.InitializePropertyCollections(); } this.scopePropertiesInitialized = true; } } }
public static T GetDefaultConfig <T>(IConfigSchema schema, string settingName) { ConfigurationProperty configurationProperty = schema.GetConfigurationProperty(settingName, typeof(T)); object defaultConfigValue = schema.GetDefaultConfigValue(configurationProperty); return(ConfigSchemaBase.ConvertValue <T>(schema, settingName, defaultConfigValue)); }
internal override void Validate(IConfigSchema schema) { if (base.Restriction != null) { throw new ConfigurationSettingsRestrictionNotExpectedException(base.GetType().Name); } }
public static IConfigProvider CreateProvider(IConfigSchema schema, TimeSpan?errorThresholdInterval) { ConfigFlags overrideFlags = ConfigProviderBase.OverrideFlags; if ((overrideFlags & ConfigFlags.DisallowADConfig) == ConfigFlags.DisallowADConfig) { return(ConfigProvider.CreateAppProvider(schema)); } if ((overrideFlags & ConfigFlags.DisallowAppConfig) == ConfigFlags.DisallowAppConfig) { return(ConfigProvider.CreateADProvider(schema)); } ConfigProvider configProvider = new ConfigProvider(schema); ConfigDriverBase configDriver = new ADConfigDriver(schema, errorThresholdInterval); ConfigDriverBase configDriver2 = new AppConfigDriver(schema, errorThresholdInterval); if ((overrideFlags & ConfigFlags.LowADConfigPriority) == ConfigFlags.LowADConfigPriority) { configProvider.AddConfigDriver(configDriver2); configProvider.AddConfigDriver(configDriver); } else { configProvider.AddConfigDriver(configDriver); configProvider.AddConfigDriver(configDriver2); } return(configProvider); }
private QueryFilter TryParseFilter(IConfigSchema schema, QueryParser.EvaluateVariableDelegate evalDelegate, out Exception ex) { ex = null; if (this.parsedFilter == null) { if (!this.HasExplicitScopeFilter) { if (this.Scopes == null || this.Scopes.Count == 0) { this.parsedFilter = QueryFilter.True; } else { List <QueryFilter> list = new List <QueryFilter>(1); foreach (SettingsScope settingsScope in this.Scopes) { list.Add(settingsScope.ConstructScopeFilter(schema)); } this.parsedFilter = (QueryFilter.AndTogether(list.ToArray()) ?? QueryFilter.False); } } else if (string.IsNullOrWhiteSpace(this.ScopeFilter)) { this.parsedFilter = QueryFilter.True; this.scopeFilter = null; } else { try { SettingsScopeFilterSchema scopeFilterSchema = SettingsScopeFilterSchema.GetSchemaInstance(schema); QueryParser queryParser = new QueryParser(this.ScopeFilter, QueryParser.Capabilities.All, new QueryParser.LookupPropertyDelegate(scopeFilterSchema.LookupSchemaProperty), () => scopeFilterSchema.AllFilterableProperties, evalDelegate, new QueryParser.ConvertValueFromStringDelegate(MailboxProvisioningConstraint.ConvertValueFromString)); this.parsedFilter = queryParser.ParseTree; } catch (InvalidCastException ex2) { ex = ex2; } catch (ParsingException ex3) { ex = ex3; } catch (ArgumentOutOfRangeException ex4) { ex = ex4; } if (ex != null) { ex = new ConfigurationSettingsInvalidScopeFilter(ex.Message, ex); this.parsedFilter = QueryFilter.False; } else { this.scopeFilter = this.parsedFilter.GenerateInfixString(FilterLanguage.Monad); } } } return(this.parsedFilter); }
public ConfigDriverBase(IConfigSchema schema, TimeSpan?errorThresholdInterval) { this.Schema = schema; this.IsInitialized = false; this.ErrorThresholdInterval = errorThresholdInterval; this.LastKnownErrors = new List <ConfigDriverBase.DiagnosticsError>(); this.LastUpdated = DateTime.MinValue; }
internal override QueryFilter ConstructScopeFilter(IConfigSchema schema) { if (!string.IsNullOrEmpty(base.Restriction.NameMatch)) { return(new TextFilter(SettingsScopeFilterSchema.ProcessName, base.Restriction.NameMatch, MatchOptions.WildcardString, MatchFlags.IgnoreCase)); } return(QueryFilter.False); }
internal override QueryFilter ConstructScopeFilter(IConfigSchema schema) { Guid?guidMatch = base.Restriction.GuidMatch; if (guidMatch != null) { return(new ComparisonFilter(ComparisonOperator.Equal, SettingsScopeFilterSchema.MailboxGuid, guidMatch.Value)); } return(QueryFilter.False); }
internal bool Matches(IConfigSchema schema, ISettingsContext context) { if (!this.Enabled || (this.ExpirationDate != DateTime.MinValue && DateTime.UtcNow > this.ExpirationDate)) { return(false); } Exception ex; QueryFilter filter = this.TryParseFilter(schema, null, out ex); return(OpathFilterEvaluator.FilterMatches(filter, null, (PropertyDefinition pdef) => ((SettingsScopeFilterSchema.ScopeFilterPropertyDefinition)pdef).RetrieveValue(context))); }
public static IConfigProvider CreateAppProvider(IConfigSchema schema, TimeSpan?errorThresholdInterval) { ConfigFlags overrideFlags = ConfigProviderBase.OverrideFlags; if ((overrideFlags & ConfigFlags.DisallowAppConfig) == ConfigFlags.DisallowAppConfig) { return(ConfigProvider.CreateDefaultValueProvider(schema)); } ConfigProvider configProvider = new ConfigProvider(schema); configProvider.AddConfigDriver(new AppConfigDriver(schema, errorThresholdInterval)); return(configProvider); }
internal override QueryFilter ConstructScopeFilter(IConfigSchema schema) { if (!string.IsNullOrEmpty(base.Restriction.SubType)) { SettingsScopeFilterSchema schemaInstance = SettingsScopeFilterSchema.GetSchemaInstance(schema); PropertyDefinition propertyDefinition = schemaInstance.LookupSchemaProperty(base.Restriction.SubType); if (propertyDefinition != null) { return(new TextFilter(propertyDefinition, base.Restriction.NameMatch, MatchOptions.WildcardString, MatchFlags.IgnoreCase)); } } return(QueryFilter.False); }
public static SettingsScopeFilterSchema GetSchemaInstance(IConfigSchema schema) { if (schema == null) { return(ObjectSchema.GetInstance <SettingsScopeFilterSchema.UntypedSettingsScopeFilterSchema>()); } Type schemaType = typeof(SettingsScopeFilterSchema.TypedSettingsScopeFilterSchema <>).MakeGenericType(new Type[] { schema.GetType() }); SettingsScopeFilterSchema settingsScopeFilterSchema = (SettingsScopeFilterSchema)ObjectSchema.GetInstance(schemaType); settingsScopeFilterSchema.InitializeScopeProperties(schema); return(settingsScopeFilterSchema); }
internal bool TryGetConfig(IConfigSchema configSchema, ISettingsContext context, string settingName, out string settingValue) { settingValue = null; int num = -1; foreach (SettingsGroup settingsGroup in this.Settings.Values) { string text; if (settingsGroup.Priority > num && settingsGroup.TryGetValue(settingName, out text) && settingsGroup.Matches(configSchema, context)) { settingValue = text; num = settingsGroup.Priority; } } return(num != -1); }
internal override QueryFilter ConstructScopeFilter(IConfigSchema schema) { List <QueryFilter> list = new List <QueryFilter>(); if (base.Restriction.MinExchangeVersion != null) { list.Add(new ComparisonFilter(ComparisonOperator.GreaterThanOrEqual, SettingsScopeFilterSchema.OrganizationVersion, base.Restriction.MinExchangeVersion)); } if (base.Restriction.MaxExchangeVersion != null) { list.Add(new ComparisonFilter(ComparisonOperator.LessThanOrEqual, SettingsScopeFilterSchema.OrganizationVersion, base.Restriction.MaxExchangeVersion)); } if (!string.IsNullOrEmpty(base.Restriction.NameMatch)) { list.Add(new TextFilter(SettingsScopeFilterSchema.OrganizationName, base.Restriction.NameMatch, MatchOptions.WildcardString, MatchFlags.IgnoreCase)); } return(QueryFilter.AndTogether(list.ToArray()) ?? QueryFilter.False); }
public DiagnosticSettingsContext(IConfigSchema schema, ConfigDiagnosticArgument argument) : base(null) { this.serverName = argument.GetArgumentOrDefault <string>("servername", null); this.serverVersion = DiagnosticSettingsContext.GetServerVersion(argument, "serverversion"); this.processName = argument.GetArgumentOrDefault <string>("processname", null); this.databaseName = argument.GetArgumentOrDefault <string>("dbname", null); this.databaseVersion = DiagnosticSettingsContext.GetServerVersion(argument, "dbversion"); this.organizationName = argument.GetArgumentOrDefault <string>("orgname", null); this.organizationVersion = DiagnosticSettingsContext.GetExchangeObjectVersion(argument, "orgversion"); this.mailboxGuid = argument.GetArgumentOrDefault <Guid?>("mailboxguid", null); if (argument.HasArgument("genericscope")) { this.propertyName = argument.GetArgument <string>("genericscope"); this.propertyValue = argument.GetArgumentOrDefault <string>("genericscopevalue", null); if (!argument.HasArgument("force")) { this.propertyValue = schema.ParseAndValidateScopeValue(this.propertyName, this.propertyValue); } } }
internal void Validate(IConfigSchema schema, QueryParser.EvaluateVariableDelegate evalDelegate) { if (this.Priority <= -1) { throw new ConfigurationSettingsException(DirectoryStrings.ConfigurationSettingsInvalidPriority(this.Priority)); } if (!this.HasExplicitScopeFilter) { if (this.Scopes.Count <= 0) { throw new ConfigurationSettingsRestrictionExpectedException(""); } HashSet <Type> hashSet = new HashSet <Type>(); foreach (SettingsScope settingsScope in this.Scopes) { if (hashSet.Contains(settingsScope.GetType())) { throw new ConfigurationSettingsDuplicateRestrictionException(settingsScope.GetType().Name.ToString(), this.Name); } hashSet.Add(settingsScope.GetType()); settingsScope.Validate(schema); } if (hashSet.Contains(typeof(SettingsForestScope)) && hashSet.Count > 1) { this.Scopes.RemoveAll((SettingsScope x) => x is SettingsForestScope); return; } } else { Exception ex; this.TryParseFilter(schema, evalDelegate, out ex); if (ex != null) { throw ex; } } }
internal override void Validate(IConfigSchema schema) { if (base.Restriction == null) { throw new ConfigurationSettingsRestrictionExpectedException(base.GetType().Name); } if (!string.IsNullOrEmpty(base.Restriction.SubType)) { throw new ConfigurationSettingsRestrictionExtraProperty(base.GetType().Name, "SubType"); } if (!string.IsNullOrEmpty(base.Restriction.MinVersion)) { throw new ConfigurationSettingsRestrictionExtraProperty(base.GetType().Name, "MinVersion"); } if (!string.IsNullOrEmpty(base.Restriction.MaxVersion)) { throw new ConfigurationSettingsRestrictionExtraProperty(base.GetType().Name, "MaxVersion"); } if (base.Restriction.GuidMatch == null) { throw new ConfigurationSettingsRestrictionExpectedException(base.GetType().Name); } }
internal override void Validate(IConfigSchema schema) { if (base.Restriction == null) { throw new ConfigurationSettingsRestrictionExpectedException(base.GetType().Name); } if (string.IsNullOrEmpty(base.Restriction.SubType)) { throw new ConfigurationSettingsRestrictionMissingProperty(base.GetType().Name, "SubType"); } if (!string.IsNullOrEmpty(base.Restriction.MinVersion)) { throw new ConfigurationSettingsRestrictionExtraProperty(base.GetType().Name, "MinVersion"); } if (!string.IsNullOrEmpty(base.Restriction.MaxVersion)) { throw new ConfigurationSettingsRestrictionExtraProperty(base.GetType().Name, "MaxVersion"); } if (schema != null) { schema.ParseAndValidateScopeValue(base.Restriction.SubType, base.Restriction.NameMatch); } }
public static T ConvertValue <T>(IConfigSchema schema, string settingName, object rawValue) { if (!(rawValue is T)) { ConfigurationProperty property = schema.GetConfigurationProperty(settingName, typeof(T)); ExchangeConfigurationSection.RunConfigOperation(delegate { TypeConverter converter = property.Converter; rawValue = converter.ConvertTo(rawValue, typeof(T)); }, (Exception ex) => new ConfigurationSettingsPropertyBadTypeException(string.Format("{0}:{1}", settingName, (rawValue != null) ? rawValue.GetType().ToString() : "(null)"), typeof(T).ToString(), ex)); } T result; try { result = (T)((object)rawValue); } catch (InvalidCastException innerException) { throw new ConfigurationSettingsPropertyBadTypeException(string.Format("{0}:{1}", settingName, (rawValue != null) ? rawValue.GetType().ToString() : "(null)"), typeof(T).ToString(), innerException); } return(result); }
internal override void Validate(IConfigSchema schema) { if (base.Restriction == null) { throw new ConfigurationSettingsRestrictionExpectedException(base.GetType().Name); } if (!string.IsNullOrEmpty(base.Restriction.SubType)) { throw new ConfigurationSettingsRestrictionExtraProperty(base.GetType().Name, "SubType"); } bool flag = false; if (!string.IsNullOrEmpty(base.Restriction.MinVersion)) { SettingsScopeRestriction.ValidateAsServerVersion(base.Restriction.MinVersion); flag = true; } if (!string.IsNullOrEmpty(base.Restriction.MaxVersion)) { SettingsScopeRestriction.ValidateAsServerVersion(base.Restriction.MaxVersion); flag = true; } if (!string.IsNullOrEmpty(base.Restriction.NameMatch)) { SettingsScopeRestriction.ValidateNameMatch(base.Restriction.NameMatch); flag = true; } if (base.Restriction.GuidMatch != null) { flag = true; } if (!flag) { throw new ConfigurationSettingsRestrictionExpectedException(base.GetType().Name); } }
public static IConfigProvider CreateAppProvider(IConfigSchema schema) { return(ConfigProvider.CreateAppProvider(schema, new TimeSpan?(ConfigDriverBase.DefaultErrorThresholdInterval))); }
// Token: 0x06000096 RID: 150 RVA: 0x0000338B File Offset: 0x0000158B public AnchorAppConfigDriver(string applicationName, IConfigSchema schema) : base(schema, new TimeSpan?(ConfigDriverBase.DefaultErrorThresholdInterval)) { this.applicationName = applicationName; }
protected virtual void InitializeScopeProperties(IConfigSchema schema) { }
public AppConfigDriver(IConfigSchema schema, TimeSpan?errorThresholdInterval) : base(schema, errorThresholdInterval) { this.section = null; }
public ADConfigDriver(IConfigSchema schema, TimeSpan?errorThresholdInterval) : base(schema, errorThresholdInterval) { this.nameFilter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, base.Schema.Name); this.ADSettingsCache = new ADObjectCache <InternalExchangeSettings, ConfigurationSettingsException>(new Func <InternalExchangeSettings[], InternalExchangeSettings[]>(this.LoadSettings), "SOFTWARE\\Microsoft\\Exchange_Test\\v15\\ConfigurationSettings"); }
public ADConfigDriver(IConfigSchema schema) : this(schema, new TimeSpan?(ConfigDriverBase.DefaultErrorThresholdInterval)) { }
protected ConfigProviderBase(IConfigSchema schema) { this.schema = schema; this.configDrivers = new List <IConfigDriver>(5); }
private void ProcessDiagnostic(ExchangeSettings settings, ConfigDiagnosticArgument argument, IConfigSchema schema) { XElement xelement = new XElement("config"); SettingsContextBase context = new DiagnosticSettingsContext(schema, argument); Server server = null; if (this.Server != null) { server = (Server)base.GetDataObject <Server>(this.Server, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorServerNotFound(this.Server.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(this.Server.ToString()))); } if (server != null || !string.IsNullOrEmpty(this.Process)) { context = new ServerSettingsContext(server, this.Process, context); } if (this.Database != null) { Database database = (Database)base.GetDataObject <Database>(this.Database, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(this.Database.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(this.Database.ToString()))); context = new DatabaseSettingsContext(database.Guid, context); } if (this.Organization != null) { ExchangeConfigurationUnit org = (ExchangeConfigurationUnit)base.GetDataObject <ExchangeConfigurationUnit>(this.Organization, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorOrganizationNotFound(this.Organization.ToString())), new LocalizedString?(Strings.ErrorOrganizationNotUnique(this.Organization.ToString()))); context = new OrganizationSettingsContext(org, context); } if (this.User != Guid.Empty) { context = new MailboxSettingsContext(this.User, context); } if (this.GenericScopeName != null) { if (schema != null) { schema.ParseAndValidateScopeValue(this.GenericScopeName, this.GenericScopeValue); } context = new GenericSettingsContext(this.GenericScopeName, this.GenericScopeValue, context); } if (this.GenericScopes != null) { foreach (string text in this.GenericScopes) { string text2 = null; string text3 = null; if (text != null) { int num = (text != null) ? text.IndexOf('=') : -1; if (num > 0) { text2 = text.Substring(0, num); text3 = text.Substring(num + 1); } } if (string.IsNullOrWhiteSpace(text2)) { base.WriteError(new ExchangeSettingsBadFormatOfConfigPairException(text), ExchangeErrorCategory.Client, this.GenericScopes); } if (schema != null) { schema.ParseAndValidateScopeValue(text2, text3); } context = new GenericSettingsContext(text2, text3, context); } } if (this.Diagnostic) { xelement.Add(argument.RunDiagnosticOperation(() => context.GetDiagnosticInfo(this.DiagnosticArgument))); if (schema != null) { xelement.Add(argument.RunDiagnosticOperation(() => schema.GetDiagnosticInfo(this.DiagnosticArgument))); } xelement.Add(argument.RunDiagnosticOperation(delegate { XElement xelement2 = new XElement("scopes"); SettingsScopeFilterSchema schemaInstance = SettingsScopeFilterSchema.GetSchemaInstance(schema); foreach (PropertyDefinition propertyDefinition in schemaInstance.AllProperties) { xelement2.Add(new XElement(propertyDefinition.Name, new XAttribute("type", propertyDefinition.Type))); } return(xelement2); })); } if (!string.IsNullOrEmpty(this.ConfigName)) { string serializedValue = null; ConfigurationProperty pdef = null; xelement.Add(argument.RunDiagnosticOperation(delegate { using (context.Activate()) { if (!settings.TryGetConfig(schema, SettingsContextBase.EffectiveContext, this.ConfigName, out serializedValue) && schema != null && schema.TryGetConfigurationProperty(this.ConfigName, out pdef)) { object defaultConfigValue = schema.GetDefaultConfigValue(pdef); serializedValue = ((defaultConfigValue != null) ? defaultConfigValue.ToString() : null); } } return(new XElement("EffectiveValue", new object[] { new XAttribute("name", this.ConfigName ?? "null"), new XAttribute("value", serializedValue ?? "null") })); })); settings.EffectiveSetting = new KeyValuePair <string, object>(this.ConfigName, serializedValue); if (serializedValue != null && schema != null) { settings.EffectiveSetting = new KeyValuePair <string, object>(this.ConfigName, schema.ParseAndValidateConfigValue(this.ConfigName, serializedValue, null)); } if (this.Diagnostic) { xelement.Add(argument.RunDiagnosticOperation(() => settings.GetDiagnosticInfo(this.DiagnosticArgument))); } } if (this.Diagnostic) { settings.DiagnosticInfo = xelement.ToString(); } }
protected ConfigProvider(IConfigSchema schema) : base(schema) { }
public static IConfigProvider CreateDefaultValueProvider(IConfigSchema schema) { return(new ConfigProvider(schema)); }