/// <summary> /// Creates a new instance of <see cref="MvcOptions"/>. /// </summary> public MvcOptions() { CacheProfiles = new Dictionary <string, CacheProfile>(StringComparer.OrdinalIgnoreCase); Conventions = new List <IApplicationModelConvention>(); Filters = new FilterCollection(); FormatterMappings = new FormatterMappings(); InputFormatters = new FormatterCollection <IInputFormatter>(); OutputFormatters = new FormatterCollection <IOutputFormatter>(); ModelBinderProviders = new List <IModelBinderProvider>(); ModelBindingMessageProvider = new DefaultModelBindingMessageProvider(); ModelMetadataDetailsProviders = new List <IMetadataDetailsProvider>(); ModelValidatorProviders = new List <IModelValidatorProvider>(); ValueProviderFactories = new List <IValueProviderFactory>(); _allowCombiningAuthorizeFilters = new CompatibilitySwitch <bool>(nameof(AllowCombiningAuthorizeFilters)); _allowBindingHeaderValuesToNonStringModelTypes = new CompatibilitySwitch <bool>(nameof(AllowBindingHeaderValuesToNonStringModelTypes)); _allowValidatingTopLevelNodes = new CompatibilitySwitch <bool>(nameof(AllowValidatingTopLevelNodes)); _inputFormatterExceptionPolicy = new CompatibilitySwitch <InputFormatterExceptionPolicy>(nameof(InputFormatterExceptionPolicy), InputFormatterExceptionPolicy.AllExceptions); _suppressBindingUndefinedValueToEnumType = new CompatibilitySwitch <bool>(nameof(SuppressBindingUndefinedValueToEnumType)); _enableEndpointRouting = new CompatibilitySwitch <bool>(nameof(EnableEndpointRouting)); _switches = new ICompatibilitySwitch[] { _allowCombiningAuthorizeFilters, _allowBindingHeaderValuesToNonStringModelTypes, _allowValidatingTopLevelNodes, _inputFormatterExceptionPolicy, _suppressBindingUndefinedValueToEnumType, _enableEndpointRouting, }; }
/// <summary> /// Creates a new instance of <see cref="MvcOptions"/>. /// </summary> public MvcOptions() { CacheProfiles = new Dictionary <string, CacheProfile>(StringComparer.OrdinalIgnoreCase); Conventions = new List <IApplicationModelConvention>(); Filters = new FilterCollection(); FormatterMappings = new FormatterMappings(); InputFormatters = new FormatterCollection <IInputFormatter>(); OutputFormatters = new FormatterCollection <IOutputFormatter>(); ModelBinderProviders = new List <IModelBinderProvider>(); ModelBindingMessageProvider = new DefaultModelBindingMessageProvider(); ModelMetadataDetailsProviders = new List <IMetadataDetailsProvider>(); ModelValidatorProviders = new List <IModelValidatorProvider>(); ValueProviderFactories = new List <IValueProviderFactory>(); _inputFormatterExceptionPolicy = new CompatibilitySwitch <InputFormatterExceptionPolicy>(nameof(InputFormatterExceptionPolicy), InputFormatterExceptionPolicy.AllExceptions); _suppressBindingUndefinedValueToEnumType = new CompatibilitySwitch <bool>(nameof(SuppressBindingUndefinedValueToEnumType)); _allowShortCircuitingValidationWhenNoValidatorsArePresent = new CompatibilitySwitch <bool>(nameof(AllowShortCircuitingValidationWhenNoValidatorsArePresent)); _switches = new ICompatibilitySwitch[] { _inputFormatterExceptionPolicy, _suppressBindingUndefinedValueToEnumType, _allowShortCircuitingValidationWhenNoValidatorsArePresent, }; }
public MvcViewOptions() { _suppressTempDataAttributePrefix = new CompatibilitySwitch <bool>(nameof(SuppressTempDataAttributePrefix)); _switches = new[] { _suppressTempDataAttributePrefix, }; }
public RazorViewEngineOptions() { _allowRecompilingViewsOnFileChange = new CompatibilitySwitch <bool>(nameof(AllowRecompilingViewsOnFileChange)); _switches = new[] { _allowRecompilingViewsOnFileChange, }; }
public void Constructor_WithName_IsValueSetIsFalse() { // Arrange & Act var @switch = new CompatibilitySwitch <bool>("TestProperty"); // Assert Assert.False(@switch.Value); Assert.False(@switch.IsValueSet); }
/// <summary> /// Creates a new instance of <see cref="MvcJsonOptions"/>. /// </summary> public MvcJsonOptions() { _allowInputFormatterExceptionMessages = new CompatibilitySwitch <bool>(nameof(AllowInputFormatterExceptionMessages)); _switches = new ICompatibilitySwitch[] { _allowInputFormatterExceptionMessages, }; }
/// <summary> /// Instantiates a new instance of the <see cref="MvcDataAnnotationsLocalizationOptions"/> class. /// </summary> public MvcDataAnnotationsLocalizationOptions() { _allowDataAnnotationsLocalizationForEnumDisplayAttributes = new CompatibilitySwitch <bool>(nameof(AllowDataAnnotationsLocalizationForEnumDisplayAttributes)); _switches = new ICompatibilitySwitch[] { _allowDataAnnotationsLocalizationForEnumDisplayAttributes }; }
public RazorPagesOptions() { _allowAreas = new CompatibilitySwitch <bool>(nameof(AllowAreas)); _switches = new ICompatibilitySwitch[] { _allowAreas, }; }
/// <summary> /// Creates a new instance of <see cref="MvcXmlOptions"/>. /// </summary> public MvcXmlOptions() { _allowRfc7807CompliantProblemDetailsFormat = new CompatibilitySwitch <bool>(nameof(AllowRfc7807CompliantProblemDetailsFormat)); _switches = new ICompatibilitySwitch[] { _allowRfc7807CompliantProblemDetailsFormat, }; }
public MvcViewOptions() { _suppressTempDataAttributePrefix = new CompatibilitySwitch <bool>(nameof(SuppressTempDataAttributePrefix)); _allowRenderingMaxLengthAttribute = new CompatibilitySwitch <bool>(nameof(AllowRenderingMaxLengthAttribute)); _switches = new[] { _suppressTempDataAttributePrefix, _allowRenderingMaxLengthAttribute }; }
/// <summary> /// Creates a new instance of <see cref="ApiBehaviorOptions"/>. /// </summary> public ApiBehaviorOptions() { _suppressUseClientErrorFactory = new CompatibilitySwitch <bool>(nameof(SuppressUseClientErrorFactory)); _suppressUseValidationProblemDetailsForInvalidModelStateResponses = new CompatibilitySwitch <bool>(nameof(SuppressUseValidationProblemDetailsForInvalidModelStateResponses)); _switches = new[] { _suppressUseClientErrorFactory, _suppressUseValidationProblemDetailsForInvalidModelStateResponses, }; }
private static void PopulateOverrideValuesPartial() { string overridesInternalCall = CompatibilitySwitch.GetAppContextOverridesInternalCall(); if (string.IsNullOrEmpty(overridesInternalCall)) { return; } bool flag1 = false; bool flag2 = false; bool flag3 = false; int num1 = -1; int num2 = -1; for (int index = 0; index <= overridesInternalCall.Length; ++index) { if (index == overridesInternalCall.Length || (int)overridesInternalCall[index] == 59) { if (flag1 & flag2 & flag3) { int startIndex1 = num1 + 1; int length1 = num2 - num1 - 1; string switchName = overridesInternalCall.Substring(startIndex1, length1); int startIndex2 = num2 + 1; int length2 = index - num2 - 1; bool result; if (bool.TryParse(overridesInternalCall.Substring(startIndex2, length2), out result)) { AppContext.SetSwitch(switchName, result); } } num1 = index; int num3; flag1 = (num3 = 0) != 0; flag3 = num3 != 0; flag2 = num3 != 0; } else if ((int)overridesInternalCall[index] == 61) { if (!flag1) { flag1 = true; num2 = index; } } else if (flag1) { flag3 = true; } else { flag2 = true; } } }
public RazorPagesOptions() { _allowAreas = new CompatibilitySwitch <bool>(nameof(AllowAreas)); _allowMappingHeadRequestsToGetHandler = new CompatibilitySwitch <bool>(nameof(AllowMappingHeadRequestsToGetHandler)); _switches = new ICompatibilitySwitch[] { _allowAreas, _allowMappingHeadRequestsToGetHandler, }; }
private static void PopulateOverrideValuesPartial() { string appContextOverridesInternalCall = CompatibilitySwitch.GetAppContextOverridesInternalCall(); if (string.IsNullOrEmpty(appContextOverridesInternalCall)) { return; } bool flag = false; bool flag2 = false; bool flag3 = false; int num = -1; int num2 = -1; for (int i = 0; i <= appContextOverridesInternalCall.Length; i++) { if (i == appContextOverridesInternalCall.Length || appContextOverridesInternalCall[i] == ';') { if (flag && flag2 && flag3) { int startIndex = num + 1; int length = num2 - num - 1; string switchName = appContextOverridesInternalCall.Substring(startIndex, length); int startIndex2 = num2 + 1; int length2 = i - num2 - 1; string value = appContextOverridesInternalCall.Substring(startIndex2, length2); bool isEnabled; if (bool.TryParse(value, out isEnabled)) { AppContext.DefineSwitchOverride(switchName, isEnabled); } } num = i; flag3 = (flag2 = (flag = false)); } else if (appContextOverridesInternalCall[i] == '=') { if (!flag) { flag = true; num2 = i; } } else if (flag) { flag3 = true; } else { flag2 = true; } } }
/// <summary> /// Creates a new instance of <see cref="ApiBehaviorOptions"/>. /// </summary> public ApiBehaviorOptions() { _suppressMapClientErrors = new CompatibilitySwitch <bool>(nameof(SuppressMapClientErrors)); _suppressUseValidationProblemDetailsForInvalidModelStateResponses = new CompatibilitySwitch <bool>(nameof(SuppressUseValidationProblemDetailsForInvalidModelStateResponses)); _allowInferringBindingSourceForCollectionTypesAsFromQuery = new CompatibilitySwitch <bool>(nameof(AllowInferringBindingSourceForCollectionTypesAsFromQuery)); _switches = new[] { _suppressMapClientErrors, _suppressUseValidationProblemDetailsForInvalidModelStateResponses, _allowInferringBindingSourceForCollectionTypesAsFromQuery }; }
public void ValueNonInterface_SettingValue_SetsIsValueSetToTrue() { // Arrange var @switch = new CompatibilitySwitch <bool>("TestProperty"); // Act @switch.Value = false; // You don't need to actually change the value, just calling the setting works // Assert Assert.False(@switch.Value); Assert.True(@switch.IsValueSet); }
public void ValueInterface_SettingValue_SetsIsValueSetToTrue() { // Arrange var @switch = new CompatibilitySwitch <bool>("TestProperty"); // Act ((ICompatibilitySwitch)@switch).Value = true; // Assert Assert.True(@switch.Value); Assert.True(@switch.IsValueSet); }
private static void TryGetSwitchOverridePartial(string switchName, ref bool overrideFound, ref bool overrideValue) { string text = null; overrideFound = false; if (!AppContextDefaultValues.s_errorReadingRegistry) { text = AppContextDefaultValues.GetSwitchValueFromRegistry(switchName); } if (text == null) { text = CompatibilitySwitch.GetValue(switchName); } bool flag; if (text != null && bool.TryParse(text, out flag)) { overrideValue = flag; overrideFound = true; } }
private static void TryGetSwitchOverridePartial(string switchName, ref bool overrideFound, ref bool overrideValue) { string str = (string)null; overrideFound = false; if (AppContextDefaultValues.s_switchesRegKey != null) { str = AppContextDefaultValues.s_switchesRegKey.GetValue(switchName, (object)null) as string; } if (str == null) { str = CompatibilitySwitch.GetValue(switchName); } bool result; if (str == null || !bool.TryParse(str, out result)) { return; } overrideValue = result; overrideFound = true; }
public TestOptions() { _testProperty = new CompatibilitySwitch <bool>(nameof(TestProperty)); _switches = new ICompatibilitySwitch[] { _testProperty }; }