public bool UpdateProjectRequirements(Project project, RequirementType type) { if (_projectRepository.Count(_projectRepository.IdFilter(project.Id.ToMongoIdentity())) == 0) { throw new EntityNotFoundException($"ID={project.Id}"); } //TODO: modification date would be great var rv = true; var counter = 0; foreach (var r in project.Requirements) { var updatefilter = _requirementRepository.IdFilter(r.Id.ToMongoIdentity()); var updateDefinition = Builders <MongoRequirement> .Update.Set(x => x.OrderMarker, counter ++); if (!_requirementRepository.Update(updatefilter, updateDefinition)) { rv = false; break; } } return(rv); }
public Project ReadProjectRequirements(Identity id, RequirementType type) { var project = _projectRepository.Read(id.ToMongoIdentity()); if (project == null) { throw new EntityNotFoundException($"ID={id}"); } var user = _userRepository.Read(project.AuthorId); if (user == null) { throw new EntityNotFoundException($"ID={id}"); } var requirementsFilter = Builders <MongoRequirement> .Filter .Eq(x => x.ProjectId, project.Id); var typeFilter = Builders <MongoRequirement> .Filter .Eq(x => x.Type, type.ToString()); var requirements = _requirementRepository.Find(requirementsFilter & typeFilter); return(project.ToDomainEntity(user, requirements)); }
public void Disabled_AccessibilityTests(SequenceBreakType sequenceBreak, RequirementType type) { SequenceBreakDictionary.Instance.Reset(); SequenceBreakDictionary.Instance[sequenceBreak].Enabled = false; Assert.Equal( AccessibilityLevel.None, RequirementDictionary.Instance[type].Accessibility); }
protected override void SetupNewDatabase(DbContextOptions <PreservationContext> dbContextOptions) { using (var context = new PreservationContext(dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { _reqType1 = AddRequirementTypeWith1DefWithoutField(context, "T1", "D1", _reqIconOther, 999); _reqDefForAll = _reqType1.RequirementDefinitions.First(); _reqDefVoided = new RequirementDefinition(TestPlant, "D2", 2, RequirementUsage.ForAll, 2); _reqDefVoided.IsVoided = true; _reqDefForOther = new RequirementDefinition(TestPlant, "D3", 2, RequirementUsage.ForOtherThanSuppliers, 3); _reqDefForSupplier = new RequirementDefinition(TestPlant, "D4", 2, RequirementUsage.ForSuppliersOnly, 4); _reqType1.AddRequirementDefinition(_reqDefVoided); _reqType1.AddRequirementDefinition(_reqDefForOther); _reqType1.AddRequirementDefinition(_reqDefForSupplier); context.SaveChangesAsync().Wait(); AddNumberField(context, _reqDefForAll, _numberLabel, _numberUnit, true); var f = AddNumberField(context, _reqDefForAll, "NUMBER", "mm", true); f.IsVoided = true; context.SaveChangesAsync().Wait(); var reqType2 = AddRequirementTypeWith1DefWithoutField(context, "T2", "D2", _reqIconOther, 7); reqType2.IsVoided = true; context.SaveChangesAsync().Wait(); AddRequirementTypeWith1DefWithoutField(context, "T3", "D3", _reqIconOther, 10000); AddRequirementTypeWith1DefWithoutField(context, "T4", "D4", _reqIconOther, 1); } }
/// <summary> /// Initializes a new instance of the <see cref="FeatureGateAttribute"/> class. /// Creates an attribute that can be used to gate actions. The gate can be configured to require all or any of the provided feature(s) to pass. /// </summary> /// <param name="requirementType">Specifies whether all or any of the provided features should be enabled in order to pass.</param> /// <param name="features">A set of enums representing the features that the attribute will represent.</param> public FeatureGateAttribute(RequirementType requirementType, params object[] features) { if (features == null || features.Length == 0) { throw new ArgumentNullException(nameof(features)); } var fs = new List <string>(); foreach (var feature in features) { var type = feature.GetType(); if (!type.IsEnum) { // invalid throw new ArgumentException("The provided features must be enums.", nameof(features)); } fs.Add(Enum.GetName(feature.GetType(), feature)); } Features = fs; RequirementType = requirementType; }
public float maxDotToTarget;//todo make this a drawer a la http://forum.unity3d.com/threads/angle-property-drawer.236359/ //todo -- I dont think is quite right public override bool OnTest(RequirementType type) { Vector3 other = context.target.transform.position; Vector3 toTarget = context.entity.transform.position.DirectionTo(other); return(context.entity.transform.forward.Dot(toTarget) < maxDotToTarget); }
private static SerializedProperty GetActiveRequirement(SerializedProperty requirement) { SerializedProperty requirementTypeProp = requirement.FindPropertyRelative("RequirementType"); RequirementType type = (RequirementType)requirementTypeProp.intValue; SerializedProperty reqObject; switch (type) { case RequirementType.Currency: reqObject = requirement.FindPropertyRelative("UnlockAmount"); break; case RequirementType.Building: reqObject = requirement.FindPropertyRelative("UnlockBuilding"); break; case RequirementType.Upgrade: reqObject = requirement.FindPropertyRelative("UnlockUpgrade"); break; default: throw new ArgumentOutOfRangeException(); } return(reqObject); }
protected override void SetupNewDatabase(DbContextOptions <PreservationContext> dbContextOptions) { using (var context = new PreservationContext(dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { _requirementTypeWithoutDefinition = new RequirementType(TestPlant, "T", "Title", RequirementTypeIcon.Area, 1); context.RequirementTypes.Add(_requirementTypeWithoutDefinition); context.SaveChangesAsync().Wait(); _requirementType = AddRequirementTypeWith1DefWithoutField(context, "T0", "D0", RequirementTypeIcon.Other, 999); _requirementDefWithoutField = _requirementType.RequirementDefinitions.Single(); _requirementDefWithInfo = new RequirementDefinition(TestPlant, "D1", 2, RequirementUsage.ForAll, 1); _requirementType.AddRequirementDefinition(_requirementDefWithInfo); _requirementDefWithNumber = new RequirementDefinition(TestPlant, "D2", 2, RequirementUsage.ForAll, 1); _requirementType.AddRequirementDefinition(_requirementDefWithNumber); _requirementDefWithCheckbox = new RequirementDefinition(TestPlant, "D3", 2, RequirementUsage.ForAll, 1); _requirementType.AddRequirementDefinition(_requirementDefWithCheckbox); _requirementDefWithAttachment = new RequirementDefinition(TestPlant, "D4", 2, RequirementUsage.ForAll, 1); _requirementType.AddRequirementDefinition(_requirementDefWithAttachment); context.SaveChangesAsync().Wait(); _infoField = AddInfoField(context, _requirementDefWithInfo, "LabelA"); _numberField = AddNumberField(context, _requirementDefWithNumber, "LabelB", "UnitA", true); _checkboxField = AddCheckBoxField(context, _requirementDefWithCheckbox, "LabelC"); _attachmentField = AddAttachmentField(context, _requirementDefWithAttachment, "LabelD"); } }
private static OrderResponseType Authenticate(string ssn) { using (var client = new RpServicePortTypeClient()) { // RequirementType is optional // This will ensure only mobile BankID can be used // https://www.bankid.com/bankid-i-dina-tjanster/rp-info/guidelines RequirementType conditions = new RequirementType { condition = new[] { new ConditionType() { key = "certificatePolicies", value = new[] { "1.2.3.4.25" } // Mobile BankID } } }; // Set the parameters for the authentication AuthenticateRequestType authenticateRequestType = new AuthenticateRequestType() { personalNumber = ssn, requirementAlternatives = new[] { conditions } }; // ...authenticate return(client.Authenticate(authenticateRequestType)); } }
//A check to see if all the requirements of any type (inhibitor, standard or otherwise) have been fulfilled based on their rule bool RequirementsFulfilled(List <GameSequenceEvent> reqList, RequirementType reqRule) { //Check if the non-timed event trigger requirements have been fulfilled if (reqRule == RequirementType.and) { foreach (GameSequenceEvent req in reqList) { if (!EventManager.Instance.HasHappened(req)) { return(false); } } return(true); } else { foreach (GameSequenceEvent req in reqList) { if (EventManager.Instance.HasHappened(req)) { return(true); } } return(false); } }
public void AccessibiltyTests( ModeSaveData mode, RequirementType type, AccessibilityLevel expected) { Mode.Instance.Load(mode); Assert.Equal(expected, RequirementDictionary.Instance[type].Accessibility); }
public ActionRequirement(JSONNode requirementJSON) { flag = requirementJSON["flag"]; value = requirementJSON["value"]; switch (requirementJSON["type"]) { case "equals": type = RequirementType.Equals; break; case "not-equals": type = RequirementType.NotEquals; break; case "greater-than": type = RequirementType.GreaterThan; break; case "less-than": type = RequirementType.LessThan; break; default: type = RequirementType.Equals; break; } }
private (Project, Action) CreateAction(PreservationContext context, string projectName, bool closeProject) { var plantId = _plantProvider.Plant; var mode = new Mode(plantId, "M1", false); context.Modes.Add(mode); var responsible = new Responsible(plantId, "Resp1", "Resp1-Desc"); context.Responsibles.Add(responsible); context.SaveChangesAsync().Wait(); var journey = new Journey(plantId, "J1"); var step = new Step(plantId, "S1", mode, responsible); journey.AddStep(step); context.Journeys.Add(journey); context.SaveChangesAsync().Wait(); var requirementType = new RequirementType(plantId, "RT", "RT title", RequirementTypeIcon.Other, 1); context.RequirementTypes.Add(requirementType); var requirementDefinition = new RequirementDefinition(plantId, "RD", 2, RequirementUsage.ForAll, 1); requirementType.AddRequirementDefinition(requirementDefinition); context.SaveChangesAsync().Wait(); var project = new Project(plantId, projectName, $"{projectName} Desc") { IsClosed = closeProject }; context.Projects.Add(project); var tag = new Tag( plantId, TagType.Standard, "Tag A", "Tag desc", step, new List <TagRequirement> { new TagRequirement(plantId, 2, requirementDefinition) }); project.AddTag(tag); context.SaveChangesAsync().Wait(); var action = new Action(plantId, "A", "D", null); tag.AddAction(action); var attachment = new ActionAttachment(plantId, Guid.Empty, "fil.txt"); action.AddAttachment(attachment); context.SaveChangesAsync().Wait(); return(project, action); }
public void ParseRequirementType_ReturnsCorrectString(RequirementType requirementType, string expected) { //act var result = EnumFactory.ParseRequirementType(requirementType); //assert result.Should().Be(expected); }
public override bool OnTest(OldContext context, RequirementType type) { Entity target = context.Get<Entity>("Target"); Entity caster = context.Get<Entity>("Caster"); if(target == null) { return true; } return Vector3.Angle(target.transform.position, caster.transform.forward) < maximumAngleDifference; }
public AddRequirementCommand(Guid vacancyId, Guid clientId, SkillType skillType, RequirementType requirementType, string content) { VacancyId = vacancyId; ClientId = clientId; SkillType = skillType; RequirementType = requirementType; Content = content; }
public FrmDynamicRequirements(ConditionLists lists, RequirementType type) { InitializeComponent(); mSourceLists = lists; mEdittingLists = new ConditionLists(lists.Data()); UpdateLists(); InitLocalization(type); }
public override bool hasReqType(RequirementType type) { if (type == 0) { return(false); } return(type != RequirementType.MANA && type != RequirementType.HEALING && type != RequirementType.ARMOR); }
public void AccessibilityTests(RequirementType type, AccessibilityLevel expected) { var container = ContainerConfig.Configure(); using var scope = container.BeginLifetimeScope(); var requirements = scope.Resolve <IRequirementDictionary>(); Assert.Equal(expected, requirements[type].Accessibility); }
static void Main(string[] args) { try { using (var client = new BankIDService.RpServicePortTypeClient()) { // Century must be included Console.WriteLine("Enter your ssn, 10 or 12 digits (YY)YYMMDDNNNN"); string ssn = GetSsn(); // RequirementType is optional // This will ensure only mobile BankID can be used // https://www.bankid.com/bankid-i-dina-tjanster/rp-info/guidelines RequirementType conditions = new RequirementType { condition = new[] { new ConditionType() { key = "certificatePolicies", value = new[] {"1.2.3.4.25"} // Mobile BankID } } }; // Set the parameters for the authentication AuthenticateRequestType authenticateRequestType = new AuthenticateRequestType() { personalNumber = ssn, requirementAlternatives = new[] { conditions } }; // ...authenticate OrderResponseType response = client.Authenticate(authenticateRequestType); // Wait for the client to sign in do { Console.WriteLine("{0}Start the BankID application and sign in, press [ENTER] when done{0}", Environment.NewLine); } while (Console.ReadKey(true).Key != ConsoleKey.Enter); // ...collect the response CollectResponseType result = client.Collect(response.orderRef); do { Console.WriteLine("Hi {0}, please press [ESC] to exit", result.userInfo.givenName); } while (Console.ReadKey(true).Key != ConsoleKey.Escape); } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.Read(); } }
public void Add(string propertyName, RequirementType requirementType) { if (!Errors.ContainsKey(propertyName)) { Errors.Add(propertyName, new HashSet<RequirementType>()); } Errors[propertyName].Add(requirementType); }
public Enchantment(string enchantName, Item ingredientHerb, int quantity, ItemEquipType restrictions, RequirementType satisfiesReq) { name = enchantName; ingredient = ingredientHerb; ingredientQuantity = quantity; enchantSlotRestriction = restrictions; reqTypes = satisfiesReq; GameRegistry.RegisterEnchantment(this); }
private static IRequirementContent CreateContent(RequirementType type) { switch (type) { case RequirementType.Empty: return(new RequirementEmptyContent()); case RequirementType.Any: return(new Requirement_Any()); case RequirementType.All: return(new Requirement_All()); case RequirementType.None: return(new Requirement_None()); case RequirementType.PlayerPosition: return(new Requirement_PlayerPosition()); case RequirementType.RandomStarSystem: return(new Requirement_RandomStarSystem()); case RequirementType.AggressiveOccupants: return(new RequirementEmptyContent()); case RequirementType.QuestCompleted: return(new Requirement_QuestCompleted()); case RequirementType.QuestActive: return(new Requirement_QuestActive()); case RequirementType.CharacterRelations: return(new Requirement_CharacterRelations()); case RequirementType.FactionRelations: return(new Requirement_FactionRelations()); case RequirementType.Faction: return(new Requirement_Faction()); case RequirementType.HaveQuestItem: return(new Requirement_HaveQuestItem()); case RequirementType.HaveItem: return(new Requirement_HaveItem()); case RequirementType.HaveItemById: return(new Requirement_HaveItemById()); case RequirementType.ComeBack: return(new RequirementEmptyContent()); default: throw new DatabaseException("Requirement: Invalid content type - " + type); } }
public override bool OnTest(OldContext context, RequirementType type) { var target = context.Get<Entity>("Target"); var caster = context.entity; if(target == null) { return false; } return target.transform.DistanceToSquared(caster.transform) <= range.Value; }
WhenICallTheAddRequirementTypePostApiEndpointToAddARequirementTypeItChecksIfExistsPullsItemEditsItAndDeletesIt () { HttpResponseMessage response; _addItem = Add(_addItem, out response); Assert.IsNotNull(response); ScenarioContext.Current[AddItemKey] = response; }
public override bool OnTest(OldContext context, RequirementType type) { var caster = context.entity; for (int i = 0; i < statuses.Length; i++) { if (statuses[i] == null) continue; if (caster.statusManager.HasStatus(statuses[i])) { return true; } } return false; }
/// <summary> /// Initializes a new instance of the <see cref="Required"/> class, using a custom error message. /// </summary> /// <param name="message">The message that should be displayed if the parameter is not used. /// <paramref name="requirementType"/> value.</param> /// <param name="requirementType">The level of requirement for the parameter.</param> public Required(string message, RequirementType requirementType = RequirementType.Error) { if (message == null) { throw new ArgumentNullException("message"); } this.message = new Message(ConsoleString.FromContent(message)); this.requirementType = requirementType; }
public RequirementType getAllReqs() { RequirementType ty = item.getAllReqs(); foreach (Enchantment en in enchants) { ty |= en.reqTypes; } return(ty); }
/// <summary> /// Creates an action constraint that requires the provided feature(s) to be enabled for the action to be valid /// to be selected. The constraint can be configured to require all or any of the provided feature(s) to be /// enabled. /// </summary> /// <param name="features">The features that should be enabled.</param> /// <param name="requirementType"> /// Specifies whether all or any of the provided features should be enabled. /// </param> public FeatureActionConstraint(IEnumerable <TFeature> features, RequirementType requirementType) { if (features?.Any() != true) { throw new ArgumentNullException(nameof(Features)); } Features = features; RequirementType = requirementType; }
/// <summary> /// Creates an attribute that can be used to process feature specific actions /// </summary> /// <param name="requirementType">Specifies whether all or any of the provided features should be enabled in order to pass.</param> /// <param name="features">A set of feature types representing the features that the attribute will represent</param> public FeatureFilterAttribute(RequirementType requirementType, params string[] features) { if (features == null || features.Length == 0) { throw new ArgumentNullException(nameof(features)); } Features = features; RequirementType = requirementType; }
public void Setup() { _field = new Field(TestPlant, "L", FieldType.Info, 1); _rd1 = new RequirementDefinition(TestPlant, "RD1", 1, RequirementUsage.ForAll, 1); _rd1.SetProtectedIdForTesting(_reqDefId); _rd1.AddField(_field); var rd2 = new RequirementDefinition(TestPlant, "RD2", 1, RequirementUsage.ForAll, 2); var rd3 = new RequirementDefinition(TestPlant, "RD3", 1, RequirementUsage.ForAll, 3); var requirementType = new RequirementType(TestPlant, "C1", "T1", _reqIconOther, 0); requirementType.AddRequirementDefinition(_rd1); requirementType.AddRequirementDefinition(rd2); requirementType.AddRequirementDefinition(rd3); _requirementTypes = new List <RequirementType> { requirementType, new RequirementType(TestPlant, "C2", "T2", _reqIconOther, 0), new RequirementType(TestPlant, "C3", "T3", _reqIconOther, 0) }; _rtSetMock = _requirementTypes.AsQueryable().BuildMockDbSet(); ContextHelper .ContextMock .Setup(x => x.RequirementTypes) .Returns(_rtSetMock.Object); var requirementDefinitions = new List <RequirementDefinition> { _rd1, rd2, rd3 }; _rdSetMock = requirementDefinitions.AsQueryable().BuildMockDbSet(); ContextHelper .ContextMock .Setup(x => x.RequirementDefinitions) .Returns(_rdSetMock.Object); var fields = new List <Field> { _field }; _fieldSetMock = fields.AsQueryable().BuildMockDbSet(); ContextHelper .ContextMock .Setup(x => x.Fields) .Returns(_fieldSetMock.Object); _dut = new RequirementTypeRepository(ContextHelper.ContextMock.Object); }
protected bool CheckRequirements(Context context, RequirementType reqType) { for (int i = 0; i < requirements.Count; i++) { if (!requirements[i].Test(reqType)) { return(false); } } return(true); }
public override bool OnTest(OldContext context, RequirementType type) { Entity target = context.Get <Entity>("Target"); Entity caster = context.Get <Entity>("Caster"); if (target == null) { return(true); } return(Vector3.Angle(target.transform.position, caster.transform.forward) < maximumAngleDifference); }
public bool doesStackHave(RequirementType type) { foreach (Enchantment e in enchants) { if ((e.reqTypes & type) > 0) { return(true); } } return(item.hasReqType(type)); }
/// <summary> /// Creates an attribute that can be used to gate actions. The gate can be configured to require all or any of the provided feature(s) to pass. /// </summary> /// <param name="requirementType">Specifies whether all or any of the provided features should be enabled in order to pass.</param> /// <param name="features">The names of the features that the attribute will represent.</param> public EndpointFeatureGateAttribute(RequirementType requirementType, bool proxyingAllowed, params string[] features) { if (features == null || features.Length == 0) { throw new ArgumentNullException(nameof(features)); } Features = features; ProxyingAllowed = proxyingAllowed; RequirementType = requirementType; }
public static IEnumerable<Application> GreaterThanOrEqualTo(this IEnumerable<Application> source, RequirementType type, string value) { return source.Where( a => a.Requirements.Active() .OrderByDescending(x => x.DateUpdated) .Any( r => r.RequirementType == type && Convert.ToInt32(r.Value) <= Convert.ToInt32(value))); }
public bool Test(OldContext context, RequirementType type) { if (supressed || (type & RequirementType) == 0) { return true; } bool requirementMet = OnTest(context, type); if (requirementMet) { OnPassed(context, type); } else { OnFailed(context, type); } return requirementMet; }
public static IQueryable<Application> MatchesRequirement(this IQueryable<Application> source, RequirementType type, string area) { return source.Where(a => a.Requirements.All(r => r.RequirementType != type) || a.Requirements.Any(r => r.RequirementType == type && r.Value == area)); }
public bool AppliesTo(RequirementType type) { return (type & appliesTo) != 0; }
public RequirementNode(RequirementType type, string messageName) { Type = type; MessageName = messageName; }
public void ApplyTo(RequirementType type) { appliesTo |= type; }
public ContractRequirement(RequirementType type) { Type = type; }
public RequiredService(string name, RequirementType requirementType) { this.Name = name; switch (requirementType) { case RequirementType.Normal: this.Type = "Normal"; break; case RequirementType.OnDemand: this.Type = "OnDemand"; break; case RequirementType.RuntimeOnly: this.Type = "RuntimeOnly"; break; } }
public StateRequirement(StateMessage message) { Type = RequirementType.Send; Message = message; }
public virtual void OnFailed(OldContext context, RequirementType type) { }
public static string ParseRequirementType(RequirementType requirementType) { switch (requirementType) { case RequirementType.Unknown: return "Unknown"; case RequirementType.NumberOfBedrooms: return "Number Of Bedrooms"; case RequirementType.NumberOfBathrooms: return "Number Of Bathrooms"; case RequirementType.Garden: return "Garden"; case RequirementType.Parking: return "Parking"; case RequirementType.WhiteGoods: return "White Goods"; case RequirementType.Furnished: return "Furnished"; case RequirementType.PetFriendly: return "Pet Friendly"; case RequirementType.NumberOfDoubleBedrooms: return "Number of Double Bedrooms"; case RequirementType.Floor: return "Floor"; case RequirementType.PriceFrom: return "Price From"; case RequirementType.PriceTo: return "Price To"; case RequirementType.Area: return "Area"; default: return string.Empty; } }
public void DoNotApplyTo(RequirementType type) { appliesTo &= ~type; }
public virtual bool OnTest(OldContext context, RequirementType type) { return true; }
public void EnumHelper_Parse_ReturnsCorrectEnum(string value, RequirementType requirementType) { //act var result = EnumHelper<RequirementType>.Parse(value); //assert result.Should().Be(requirementType); }