public async Task SetFeatureFlag(string userId, FeatureFlags featureFlag, bool enabled) { var user = await this.aadClient.GetUser(userId); var featureFlagName = Enum.GetName(typeof(FeatureFlags), featureFlag); var featureFlagGroup = await this.aadClient.GetGroupByName($"{AadGroupFeatureFlagPrefix}{featureFlagName}"); var memberGroups = await user.GetMemberGroupsAsync(false); if (!enabled && memberGroups.Any(g => g == featureFlagGroup.ObjectId)) { await this.aadClient.RemoveUserFromGroup(userId, featureFlagGroup.ObjectId); var ai = new TelemetryClient(); ai.TrackTrace($"{user.DisplayName} disabled Feature Flag {featureFlagName}", SeverityLevel.Warning); } if (enabled && !memberGroups.Any(g => g == featureFlagGroup.ObjectId)) { await this.aadClient.AddUserToGroup(userId, featureFlagGroup.ObjectId); var ai = new TelemetryClient(); ai.TrackTrace($"{user.DisplayName} enabled Feature Flag {featureFlagName}", SeverityLevel.Information); } }
public static void Load(IConfiguration configuration) { Dictionary <string, bool> flags = configuration.GetChildren() .ToDictionary(x => x.Key, x => x.Get <bool>()); FeatureFlags.Set(flags); }
private async Task <string> TrySaveFlags(FeatureFlagsViewModel model, string contentId) { var flags = new FeatureFlags( model.Features.ToDictionary(f => f.Name, f => f.Status), model.Flights.ToDictionary(f => f.Name, f => f.AsFlight())); var result = await _storage.TrySaveAsync(flags, contentId); switch (result) { case FeatureFlagSaveResult.Ok: // The flags have been persisted. Refresh this instance's cache immediately. await _cache.RefreshAsync(); var refreshSeconds = _config.FeatureFlagsRefreshInterval.TotalSeconds; TempData["Message"] = $"Your feature flags have been saved! It may take up to {refreshSeconds} seconds for this change to propagate everywhere."; return(null); case FeatureFlagSaveResult.Conflict: return("Your changes were not applied as the feature flags were modified by someone else. Please reload the page and try again."); default: return($"Unknown save result '{result}'."); } }
public ExtensionLoader(ScriptHostConfiguration config, TraceWriter traceWriter, ILogger startupLogger) { _config = config; _traceWriter = traceWriter; _startupLogger = startupLogger; _dynamicExtensionLoadingEnabled = FeatureFlags.IsEnabled(ScriptConstants.FeatureFlagsEnableDynamicExtensionLoading); }
public HostAzureBlobStorageProvider(IScriptHostManager scriptHostManager, IConfiguration configuration, IOptionsMonitor <JobHostInternalStorageOptions> options, ILogger <HostAzureBlobStorageProvider> logger, AzureComponentFactory componentFactory, AzureEventSourceLogForwarder logForwarder) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } _storageOptions = options ?? throw new ArgumentNullException(nameof(options)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _blobServiceClientProvider = new BlobServiceClientProvider(componentFactory, logForwarder); if (FeatureFlags.IsEnabled(ScriptConstants.FeatureFlagDisableMergedWebHostScriptHostConfiguration)) { Configuration = configuration; } else { if (scriptHostManager == null) { throw new ArgumentNullException(nameof(scriptHostManager)); } Configuration = new ConfigurationBuilder() .Add(new ActiveHostConfigurationSource(scriptHostManager)) .AddConfiguration(configuration) .Build(); } }
public async Task <ActionResult> Upload(IFormFile file) { if (!FeatureFlags.IsEnabled(FeatureFlags.ImageUpload, _hostingEnv)) { return(NotFound()); } if (!ImagesController.IsImage(file)) { return(ErrorResult("The file should be an image")); } else { string fileName = Path.GetRandomFileName(); string filePath = await SaveImageAsync( file, fileName, _hostingEnv); if (filePath == null) { return(ErrorResult("Image is null")); } return(Json(filePath)); } }
internal ServiceScope CreateChildScope(IServiceScopeFactory rootScopeFactory) { var scopedRoot = rootScopeFactory.CreateScope(); var preferInterpretation = (Container as Container).PreferInterpretation; Container scopedContext = Container.OpenScope(preferInterpretation: preferInterpretation) as Container; Rules rules = scopedContext.Rules; foreach (var unknownServiceResolver in scopedContext.Rules.UnknownServiceResolvers) { rules = rules.WithoutUnknownServiceResolver(unknownServiceResolver); } var resolver = scopedContext.With(r => rules.WithUnknownServiceResolvers(request => { return(new DelegateFactory(_ => scopedRoot.ServiceProvider.GetService(request.ServiceType), setup: _rootScopeFactorySetup)); })); var scope = new ServiceScope(resolver, scopedRoot); if (FeatureFlags.IsEnabled(ScriptConstants.FeatureFlagEnableEnhancedScopes)) { scopedContext.UseInstance <IServiceProvider>(scope.ServiceProvider); } ChildScopes.TryAdd(scope, null); scope.DisposalTask.ContinueWith(t => ChildScopes.TryRemove(scope, out object _)); return(scope); }
public FactsBase() { _storage = new Mock <IFeatureFlagStorageService>(); _telemetry = new Mock <IFeatureFlagTelemetryService>(); _options = new FeatureFlagOptions(); _target = new FeatureFlagCacheService( _storage.Object, _options, _telemetry.Object, Mock.Of <ILogger <FeatureFlagCacheService> >()); _latestFlags = FeatureFlagStateBuilder .Create() .WithFeature("Foo", FeatureStatus.Enabled) .Build(); _stalenessMetrics = new List <TimeSpan>(); _telemetry .Setup(t => t.TrackFeatureFlagStaleness(It.IsAny <TimeSpan>())) .Callback((TimeSpan staleness) => { _stalenessMetrics.Add(staleness); }); }
public void Deserialize(DataSerializer s) { Features = (FeatureFlags)s.ReadInt32(); if (Features.IsFlagSet(FeatureFlags.TreeLeft)) { TreeLeft = s.ReadSharedString(); } if (Features.IsFlagSet(FeatureFlags.TreeMiddle)) { TreeMiddle = s.ReadSharedString(); } if (Features.IsFlagSet(FeatureFlags.TreeRight)) { TreeRight = s.ReadSharedString(); } if (Features.IsFlagSet(FeatureFlags.StreetLight)) { StreetLight = s.ReadSharedString(); } if (Features.IsFlagSet(FeatureFlags.RepeatDistances)) { RepeatDistances = s.ReadVector4(); } }
public ExpansionInfo( int id, string name, ClientFlags clientFlags, FeatureFlags supportedFeatures, CharacterListFlags charListFlags, HousingFlags customHousingFlag) : this(id, name, supportedFeatures, charListFlags, customHousingFlag) =>
/// <summary> /// Deserializes this structure from binary data. /// </summary> /// <param name="reader">The <see cref="BinaryReader"/> to read the data from.</param> public void ReadFrom(BinaryReader reader) { _tag = reader.ReadUInt32(); uint offsetWithFlags = reader.ReadUInt32(); _flags = (FeatureFlags)offsetWithFlags; _offset = offsetWithFlags >> 8; }
public ExpansionInfo(int id, string name, ClientVersion requiredClient, FeatureFlags supportedFeatures, CharacterListFlags charListFlags, int customHousingFlag) { m_Name = name; m_ID = id; m_SupportedFeatures = supportedFeatures; m_CharListFlags = charListFlags; m_CustomHousingFlag = customHousingFlag; m_RequiredClient = requiredClient; }
private readonly ClientVersion m_RequiredClient;// Used as an alternative to the flags public ExpansionInfo(int id, string name, ClientFlags clientFlags, FeatureFlags supportedFeatures, CharacterListFlags charListFlags, int customHousingFlag) { this.m_Name = name; this.m_ID = id; this.m_ClientFlags = clientFlags; this.m_SupportedFeatures = supportedFeatures; this.m_CharListFlags = charListFlags; this.m_CustomHousingFlag = customHousingFlag; }
private PixelFormat GetPixelFormat() { FeatureFlags flags = 0; int numParms = 1; float[] parms = new float[numParms]; Api.GetFeature(m_hCamera, Feature.PixelFormat, ref flags, ref numParms, parms); return((PixelFormat)parms[0]); }
private ExpansionInfo( int id, string name, FeatureFlags supportedFeatures, CharacterListFlags charListFlags, int customHousingFlag) { ID = id; Name = name; SupportedFeatures = supportedFeatures; CharacterListFlags = charListFlags; CustomHousingFlag = customHousingFlag; }
public FeatureFlagReference(FeatureFlags flags, string contentId) { if (string.IsNullOrEmpty(contentId)) { throw new ArgumentException(nameof(contentId)); } Flags = flags ?? throw new ArgumentException(nameof(flags)); ContentId = contentId; }
public void FeatureFlagConfigTests(string configValue, bool expected) { var config = new Mock <IConfiguration>(); const string key = "FEATURE_THING"; config.Setup(c => c[key]).Returns(configValue); var featureFlags = new FeatureFlags(config.Object); featureFlags.ShouldShow(key).Should().Be(expected); }
public async Task <bool> IsFeatureFlagEnabled(string userId, FeatureFlags featureFlag) { var user = await this.aadClient.GetUser(userId); var featureFlagGroup = await this.aadClient.GetGroupByName($"{AadGroupFeatureFlagPrefix}{Enum.GetName(typeof(FeatureFlags), featureFlag)}"); var memberGroups = await user.GetMemberGroupsAsync(false); return(memberGroups.Any(g => g == featureFlagGroup.ObjectId)); }
public void SetStructFeature <V>(FeatureFlags feature, V value) where V : struct { Features = Features.SetFlags(feature); var flagName = feature.ToString(); var nameField = GetType().GetField(flagName); nameField?.SetValue(this, value); //TODO }
public StandardFileNameValidationService( IStorageService storageService, FeatureFlags featureFlags, IJobService jobService, ICollectionsService collectionService, AzureStorageSection azureStorageSection, IEnumerable <ICollection> collections) : base(storageService, featureFlags, jobService, collectionService, azureStorageSection, collections) { }
public EasFileNameValidationService( [KeyFilter(EnumJobType.EasSubmission)] IKeyValuePersistenceService persistenceService, FeatureFlags featureFlags, IJobService jobService, IDateTimeProvider dateTimeProvider, IBespokeHttpClient httpClient, ApiSettings apiSettings) : base(persistenceService, featureFlags, jobService, dateTimeProvider, httpClient, apiSettings) { }
public ExpansionInfo( int id, string name, ClientVersion requiredClient, FeatureFlags supportedFeatures, CharacterListFlags charListFlags, HousingFlags customHousingFlag) : this(id, name, supportedFeatures, charListFlags, customHousingFlag) { RequiredClient = requiredClient; }
public BulkProviderUploadFileNameValidationService( IStorageService storageService, FeatureFlags featureFlags, IJobService jobService, ICollectionsService collectionService, AzureStorageSection azureStorageSection, IEnumerable <ICollection> collections) : base(storageService, featureFlags, jobService, collectionService, azureStorageSection, collections) { _collections = collections; }
private static IDocumentConverter CreateConverter(FeatureFlags flag) { return(flag switch { FeatureFlags.ExpectedException => new ExpectedExceptionDocumentConverter(), FeatureFlags.AssertRenaming => new AssertRenamingDocumentConverter(), FeatureFlags.SetUpFixture => new SetUpFixtureDocumentConverter(), FeatureFlags.TestFixture => new TestFixtureDocumentConverter(), _ => throw new InvalidOperationException("Exhaustive switch is not exhaustive.") });
public Task ReturnsViewWithSaveErrorUnknown( bool hasLastUpdated, IModifyFeatureFlagsViewModel validModel, FeatureFlags flags) { return(ReturnsViewWithSaveErrorConflict( hasLastUpdated, validModel, (FeatureFlagSaveResult)99, "Unknown save result '99'.")); }
public Task ReturnsViewWithSaveErrorConflict( bool hasLastUpdated, IModifyFeatureFlagsViewModel validModel, FeatureFlags flags) { return(ReturnsViewWithSaveErrorConflict( hasLastUpdated, validModel, FeatureFlagSaveResult.Conflict, "Your changes were not applied as the feature flags were modified by someone else. Please reload the page and try again.")); }
public void SetPrefabFeature <P>(FeatureFlags feature, P prefab = null) where P : PrefabInfo { Features = Features.SetFlags(feature); var flagName = feature.ToString(); var nameField = GetType().GetField(flagName); var prefabField = GetType().GetField(flagName + "Prefab"); nameField?.SetValue(this, prefab?.name); prefabField?.SetValue(this, prefab); }
private static void VerifyAndEnableShadowCopy(WebHostSettings webHostSettings) { if (!FeatureFlags.IsEnabled(ScriptConstants.FeatureFlagDisableShadowCopy)) { string currentShadowCopyDirectories = AppDomain.CurrentDomain.SetupInformation.ShadowCopyDirectories; string shadowCopyPath = GetShadowCopyPath(currentShadowCopyDirectories, webHostSettings.ScriptPath); #pragma warning disable CS0618 AppDomain.CurrentDomain.SetShadowCopyPath(shadowCopyPath); #pragma warning restore CS0618 } }
public static bool DoFlagsMatch(FeatureFlags first, FeatureFlags second) { try { AssertFlags(first, second); return(true); } catch { return(false); } }
public void UnsetFeature(FeatureFlags feature) { Features = Features.ClearFlags(feature); var flagName = feature.ToString(); var nameField = GetType().GetField(flagName); var prefabField = GetType().GetField(flagName + "Prefab"); nameField?.SetValue(this, null); prefabField?.SetValue(this, null); }
public UnhandledExceptions( FeatureFlags featureFlags , DumpType dumpType ) { _featureFlags = featureFlags; _dumpType = dumpType; if ( ( _featureFlags & FeatureFlags.Logging ) == FeatureFlags.Logging ) { throw new ArgumentException("Logging feature is enabled with no log provided", "featureFlags"); } if ( ( _featureFlags & FeatureFlags.Dump ) == FeatureFlags.Dump && _dumpType == DumpType.None ) { throw new ArgumentException("Dump feature is enabled with DumpType.None provided", "dumpType"); } }
public SupportedFeaturesPacket(PacketReader reader) : base(0xB9, "Enable Features") { if (reader.Buffer.Length == 3) Flags = (FeatureFlags)reader.ReadUInt16(); else if (reader.Buffer.Length == 5) Flags = (FeatureFlags)reader.ReadUInt32(); else { Flags = (FeatureFlags)reader.ReadUInt16(); Tracer.Error("Bad feature flag size in SupportedFeaturesPacket; expected 16 or 32 bit features, received {0} bits.", (reader.Buffer.Length - 1) * 8); } }
public UnhandledExceptions( FeatureFlags featureFlags , ILog log ) { _featureFlags = featureFlags; _log = log; if ( ( _featureFlags & FeatureFlags.Logging ) == FeatureFlags.Logging && _log == null ) { throw new ArgumentNullException("log", "Logging feature is enabled with no log provided"); } if ( ( _featureFlags & FeatureFlags.Dump ) == FeatureFlags.Dump ) { throw new ArgumentException("Dump feature is enabled with no DumpType provided", "featureFlags"); } }
public UnhandledExceptions( FeatureFlags featureFlags , DumpType dumpType , ILog log ) { _featureFlags = featureFlags; _dumpType = dumpType; _log = log; if ( ( _featureFlags & FeatureFlags.Logging ) == FeatureFlags.Logging && _log == null ) { throw new ArgumentNullException("log", "Logging feature is enabled with null log provided"); } if ( ( _featureFlags & FeatureFlags.Dump ) == FeatureFlags.Dump && _dumpType == DumpType.None ) { throw new ArgumentException("Dump feature is enabled with DumpType.None provided", "dumpType"); } }
private static extern bool cogl_features_available(FeatureFlags features);
public static bool AreFeaturesAvailable(FeatureFlags features) { return cogl_features_available (features); }
public ExpansionInfo(int id, string name, ClientFlags clientFlags, FeatureFlags supportedFeatures, CharacterListFlags charListFlags, int customHousingFlag) { this.m_Name = name; this.m_ID = id; this.m_ClientFlags = clientFlags; this.m_SupportedFeatures = supportedFeatures; this.m_CharListFlags = charListFlags; this.m_CustomHousingFlag = customHousingFlag; }
public static void SetFlags(FeatureFlags flags) { m_flags |= flags; }
private ExpansionInfo( int id, string name, FeatureFlags supportedFeatures, CharacterListFlags charListFlags, HousingFlags customHousingFlag) { ID = id; Name = name; SupportedFeatures = supportedFeatures; CharacterListFlags = charListFlags; CustomHousingFlag = customHousingFlag; }
public ExpansionInfo( int id, string name, ClientFlags clientFlags, FeatureFlags supportedFeatures, CharacterListFlags charListFlags, HousingFlags customHousingFlag) : this(id, name, supportedFeatures, charListFlags, customHousingFlag) { ClientFlags = clientFlags; }
public ExpansionInfo( int id, string name, ClientVersion requiredClient, FeatureFlags supportedFeatures, CharacterListFlags charListFlags, int customHousingFlag ) { m_Name = name; m_ID = id; m_SupportedFeatures = supportedFeatures; m_CharListFlags = charListFlags; m_CustomHousingFlag = customHousingFlag; m_RequiredClient = requiredClient; }
public void SetFlags(FeatureFlags flags) { m_Flags |= flags; }
public SupportedFeaturesPacket(PacketReader reader) : base(0xB9, "Enable Features") { m_flags = (FeatureFlags)reader.ReadInt16(); }