private static BasicToggleType CreateToggleType(FeatureElement feature, IUserListReader userListReader) { BasicToggleType toggleType; // The toggle is disabled by default, so if HasValue is false, then toggle is disabled. bool enabled = feature.Enabled.HasValue && feature.Enabled.Value; if (!string.IsNullOrEmpty(feature.UserListPath)) { var userList = userListReader.GetUserNamesFromList(feature.UserListPath); toggleType = new UserListToggleType { Name = feature.Name, Enabled = enabled, UserNamesList = userList }; } else if (!string.IsNullOrEmpty(feature.RandomFactor)) { // Convert string to float float factorValue = float.Parse(feature.RandomFactor, CultureInfo.InvariantCulture.NumberFormat); toggleType = new RandomToggleType { Name = feature.Name, Enabled = enabled, RandomFactor = factorValue }; } else { toggleType = new BasicToggleType { Name = feature.Name, Enabled = enabled }; } return(toggleType); }
private static BasicToggleType CreateToggleType(FeatureElement feature, IUserListReader userListReader) { BasicToggleType toggleType; // The toggle is disabled by default, so if HasValue is false, then toggle is disabled. bool enabled = feature.Enabled.HasValue && feature.Enabled.Value; if (!string.IsNullOrEmpty(feature.UserListPath)) { var userList = userListReader.GetUserNamesFromList(feature.UserListPath); toggleType = new UserListToggleType { Name = feature.Name, Enabled = enabled, UserNamesList = userList }; } else if (!string.IsNullOrEmpty(feature.RandomFactor)) { // Convert string to float float factorValue = float.Parse(feature.RandomFactor, CultureInfo.InvariantCulture.NumberFormat); toggleType = new RandomToggleType { Name = feature.Name, Enabled = enabled, RandomFactor = factorValue }; } else { toggleType = new BasicToggleType { Name = feature.Name, Enabled = enabled }; } return toggleType; }