internal RuleOperation(RuleOperationContext context, RuleAction action) { Requires.NotNull(context, nameof(context)); this.Action = action; this.Context = context; }
public ShowRule(ShowRule O) { this.DoWhatNow = O.DoWhatNow; this.First = O.First; this.Second = O.Second; this.UserSuppliedText = O.UserSuppliedText; }
private SimpleRule(RuleDescriptor ruleDescriptor, RuleOperationContext ruleOperationContext, RuleAction ruleAction) { Requires.NotNull(ruleDescriptor, nameof(ruleDescriptor)); Requires.NotNull(ruleOperationContext, nameof(ruleOperationContext)); this.RuleDescriptor = ruleDescriptor; this.RuleOperationContext = new RuleOperation(ruleOperationContext, ruleAction); }
internal SimpleRule(RuleDescriptor ruleDescriptor, List<Func<FormattingContext, bool>> contextFilters, RuleAction action) { Requires.NotNull(ruleDescriptor, nameof(ruleDescriptor)); Requires.NotNull(contextFilters, nameof(contextFilters)); this.RuleDescriptor = ruleDescriptor; this.RuleOperationContext = new RuleOperation(new RuleOperationContext(contextFilters), action); }
/// <summary> /// Adds an action which will be execute before an object is moved when the condition is met /// </summary> /// <param name="condition">A predicate function which takes a /// thing and a proposed move as arguments and returns a boolean value. /// The rule will fire (will be violated) if the condition returns true</param> /// <param name="action">An action which will be invoked when the condition is met</param> public void AddAction(Func <ISpatial2D, IEnumerable <Point2D>, bool> condition, Action <UniversalGrid <T>, ISpatial2D> action, int?id = null) { Write(() => { var idv = id.HasValue ? id.Value : (_actions.Any() ? _actions.Max(r => r.Value.Id) + 1 : 1); _actions[idv] = new RuleAction <UniversalGrid <T> >(idv, action, condition); }); }
private void setDefaults() { rule = Rule.WI_ReplaceInstitution; ruleType = RuleType.WISA_Import; ruleAction = RuleAction.Modify; header = "Vervang Instellingsnummer"; description = "Vergang het WISA instellingsnummer bij het importeren. Dit kan handig zijn als je accounts wil toevoegen in een niet officiele instelling."; }
public void AddRuleAction(RuleAction ruleAction) { if (ruleAction == null) { throw new ArgumentException("Rule action must not be null."); } Actions.Add(ruleAction); }
private void SetDefaults() { rule = Rule.WI_MarkAsVirtual; ruleType = RuleType.WISA_Import; ruleAction = RuleAction.WorkDate; header = "Markeer de school als virtueel"; description = "Virtuele scholen kunnen een aangepaste werkdatum gebruiken. Dit helpt om inschrijvingen voor het volgende schooljaar in orde te brengen."; }
public ShowRule() { DoWhatNow = RuleAction.kIgnoreEp; First = -1; Second = -1; UserSuppliedText = string.Empty; RenumberAfter = true; }
private void SetDefaults() { rule = Rule.AD_DontImportUser; ruleType = RuleType.AD_Import; ruleAction = RuleAction.Discard; header = "Account niet Importeren"; description = "Dit account niet importeren uit Active Directory."; }
public static RuleProperties RuleProperties( string name, RuleFilter filter = default, RuleAction action = default) => new RuleProperties(name, filter) { Action = action };
public static Task <IEnumerable <ValidationError> > ValidateAsync(RuleAction action) { Guard.NotNull(action, nameof(action)); var visitor = new RuleActionValidator(); return(action.Accept(visitor)); }
private void setDefaults() { rule = Rule.SS_NoSubGroups; ruleType = RuleType.SS_Import; ruleAction = RuleAction.Discard; header = "Negeer Subgroepen"; description = "Zorgt er voor dat de subgroepen van deze groep niet geimporteerd zal worden."; }
private void SetDefaults() { rule = Rule.SS_DiscardGroup; ruleType = RuleType.SS_Import; ruleAction = RuleAction.Discard; header = "Negeer Groep"; description = "Zorgt er voor dat deze groep niet geimporteerd zal worden."; }
private void SetDefaults() { rule = Rule.WI_DontImportUser; ruleType = RuleType.WISA_Import; ruleAction = RuleAction.Discard; header = "Account niet Importeren"; description = "Dit account niet importeren uit Wisa."; }
private void SetDefaults() { rule = Rule.WI_DontImportClass; ruleType = RuleType.WISA_Import; ruleAction = RuleAction.Discard; header = "Klas niet Importeren"; description = "Sla deze klas over bij het importeren uit Wisa."; }
protected override void SetItems(IReadOnlyList <byte[]> data) { RuleId = new Guid(data[0]); Tag = BitConverter.ToUInt64(data[1], 0); KeyId = new Guid(data[2]); Condition = Encoding.UTF8.GetString(data[3]); Action = (RuleAction)BitConverter.ToInt32(data[4], 0); OwnerId = new Guid(data[5]); }
protected void Then <T>(Fact <T> fact, Func <FactContext <T>, Task> action) where T : class { var factDeclaration = _declarations.Get <T>(fact.Name); var ruleAction = new RuleAction <T>(factDeclaration, action); _actions.Add(ruleAction); }
private bool IsGeneratingReply() { Rule rule = this.workItem.Rule; int actionIndex = this.workItem.ActionIndex; RuleAction ruleAction = rule.Actions[actionIndex]; RuleAction.Type actionType = ruleAction.ActionType; return(actionType == RuleAction.Type.OP_REPLY || actionType == RuleAction.Type.OP_OOF_REPLY || actionType == RuleAction.Type.OP_DELETE); }
internal /*for testing purposes*/ static bool IsBaselineWeakend(RuleAction baselineAction, RuleAction targetAction) { Debug.Assert(baselineAction != RuleAction.Default, "'Default' is invalid value for rule. RuleSet schema should prevent this"); Debug.Assert(targetAction != RuleAction.Default, "'Default' is invalid value for rule. RuleSet schema should prevent this"); int baselineStrictness = Array.IndexOf(ruleActionStrictnessOrder, baselineAction); int targetStrictness = Array.IndexOf(ruleActionStrictnessOrder, targetAction); return(baselineStrictness > targetStrictness); }
public static RuleDescription GetRuleDescription(AmqpRuleDescription amqpDescription) { Filter filter = MessageConverter.GetFilter(amqpDescription.Filter); RuleAction ruleAction = MessageConverter.GetRuleAction(amqpDescription.Action); return(new RuleDescription(filter) { Action = ruleAction }); }
public ShowRule([CanBeNull] XElement xmlSettings) { SetToDefaults(); if (xmlSettings != null) { DoWhatNow = xmlSettings.ExtractEnum("DoWhatNow", RuleAction.kIgnoreEp); First = xmlSettings.ExtractInt("First", -1); Second = xmlSettings.ExtractInt("Second", -1); UserSuppliedText = xmlSettings.ExtractString("Text"); } }
public ShowRule(XElement?xmlSettings) : this() { if (xmlSettings != null) { DoWhatNow = xmlSettings.ExtractEnum("DoWhatNow", RuleAction.kIgnoreEp); First = xmlSettings.ExtractInt("First", -1); Second = xmlSettings.ExtractInt("Second", -1); UserSuppliedText = xmlSettings.ExtractString("Text"); RenumberAfter = xmlSettings.ExtractBool("RenumberAfter", true); } }
internal AlertRuleData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary <string, string> tags, AzureLocation location, string namePropertiesName, string description, string provisioningState, bool isEnabled, RuleCondition condition, RuleAction action, IList <RuleAction> actions, DateTimeOffset?lastUpdatedOn) : base(id, name, resourceType, systemData, tags, location) { NamePropertiesName = namePropertiesName; Description = description; ProvisioningState = provisioningState; IsEnabled = isEnabled; Condition = condition; Action = action; Actions = actions; LastUpdatedOn = lastUpdatedOn; }
private void AreEqual(RuleAction exp, RuleAction act) { if (exp is RuleEmailAction) { var expEmailRuleAction = exp as RuleEmailAction; var actEmailRuleAction = act as RuleEmailAction; AreEqual(expEmailRuleAction.CustomEmails, actEmailRuleAction.CustomEmails); Assert.Equal(expEmailRuleAction.SendToServiceOwners, actEmailRuleAction.SendToServiceOwners); } }
internal void ApplyRuleChange(RuleAction action) { if (action.Action == RuleActionType.Add) { ProgramRules.Add(action.Rule); } else { ProgramRules.Remove(action.Rule); } }
public void Buy(BuyOptions options) { lock (syncRoot) { PauseTasks(); try { IRule rule = signalsService.Rules.Entries.FirstOrDefault(r => r.Name == options.Metadata.SignalRule); RuleAction ruleAction = rule?.Action ?? RuleAction.Default; IPairConfig pairConfig = GetPairConfig(options.Pair); bool arbitragePair = pairConfig.ArbitrageEnabled && pairConfig.ArbitrageSignalRules.Contains(options.Metadata.SignalRule); if (arbitragePair) { Arbitrage arbitrage = Exchange.GetArbitrage(options.Pair, Config.Market, pairConfig.ArbitrageMarkets, pairConfig.ArbitrageType); if (arbitrage.IsAssigned) { Arbitrage(new ArbitrageOptions(options.Pair, arbitrage, options.Metadata)); } } else { ITradingPair swappedPair = Account.GetTradingPairs().OrderBy(p => p.CurrentMargin).FirstOrDefault(tradingPair => { IPairConfig tradingPairConfig = GetPairConfig(tradingPair.Pair); return(tradingPairConfig.SellEnabled && tradingPairConfig.SwapEnabled && tradingPairConfig.SwapSignalRules != null && tradingPairConfig.SwapSignalRules.Contains(options.Metadata.SignalRule) && tradingPairConfig.SwapTimeout < (DateTimeOffset.Now - tradingPair.OrderDates.DefaultIfEmpty().Max()).TotalSeconds); }); if (swappedPair != null) { Swap(new SwapOptions(swappedPair.Pair, options.Pair, options.Metadata)); } else if (ruleAction == RuleAction.Default) { if (CanBuy(options, out string message)) { tradingTimedTask.InitiateBuy(options); } else { loggingService.Debug(message); } } } } finally { ContinueTasks(); } } }
public void RemoveRuleAction(RuleAction ruleAction) { if (ruleAction == null) { throw new ArgumentException("Rule action must not be null."); } if (!Actions.Contains(ruleAction)) { throw new ArgumentException("Rule action must already be present in the collection."); } Actions.Remove(ruleAction); }
private RuleSet CreateVsRuleSet(int rules, string ruleSetFileName, RuleAction defaultAction = RuleAction.Warning) { RuleSet ruleSet = TestRuleSetHelper.CreateTestRuleSet(rules); ruleSet.Rules.ToList().ForEach(r => r.Action = defaultAction); ruleSet.FilePath = Path.Combine(this.VsRuleSetsDirectory, ruleSetFileName); ruleSet.WriteToFile(ruleSet.FilePath); this.temporaryFiles.AddFile(ruleSet.FilePath, false); return(ruleSet); }
private RuleSet CreateUserSharedRuleSet(string ruleSetFileName, RuleAction defaultAction = RuleAction.Warning, int rules = DefaultNumberOfRules) { RuleSet ruleSet = TestRuleSetHelper.CreateTestRuleSet(rules); ruleSet.Rules.ToList().ForEach(r => r.Action = defaultAction); ruleSet.FilePath = Path.Combine(this.SolutionSharedRuleSetFolder, ruleSetFileName); ruleSet.WriteToFile(ruleSet.FilePath); this.temporaryFiles.AddFile(ruleSet.FilePath, false); return(ruleSet); }
public static IRuleAction CompileAction(ActionElement element, IEnumerable <Declaration> declarations, IEnumerable <Declaration> dependencies) { var optimizer = new ExpressionMultiParameterOptimizer <Action <IContext, object[]> >(); var optimizedExpression = optimizer.CompactParameters(element.Expression, 1); var @delegate = optimizedExpression.Compile(); var fastDelegate = Create(@delegate, element.Expression.Parameters.Count - 1); var tupleFactMap = IndexMap.CreateMap(element.Imports, declarations); var dependencyIndexMap = IndexMap.CreateMap(element.Imports, dependencies); var action = new RuleAction(element.Expression, fastDelegate, tupleFactMap, dependencyIndexMap, element.ActionTrigger); return(action); }
public ActionResult Edit([Bind(Include = "Id,ActionName,ErrorMessage,RuleActionID,AssociatedActionTypeID")] RuleAction ruleaction, string UrlReferrer) { if (ModelState.IsValid) { db.Entry(ruleaction).State = EntityState.Modified; db.SaveChanges(); //,Hash = "Action" return(RedirectToAction("Edit", "BusinessRule", new { id = ruleaction.RuleActionID })); } ViewBag.RuleActionID = new SelectList(dbRuleAction.BusinessRules, "ID", "DisplayValue", ruleaction.RuleActionID); ViewBag.AssociatedActionTypeID = new SelectList(dbAssociatedActionType.ActionTypes, "ID", "DisplayValue", ruleaction.AssociatedActionTypeID); return(View(ruleaction)); }
public static RuleAction FromDomainModel(this RuleAction obj, AddRuleActionDomain domain, UserDomain user) { if (obj == null) { obj = new RuleAction(); } obj.ActionId = domain.ActionId; obj.DeviceId = domain.DeviceId; obj.TenantId = user.TenantId; return(obj); }
public static RuleDescription GetRuleDescription(AmqpRuleDescriptionCodec amqpDescription) { Filter filter = GetFilter(amqpDescription.Filter); RuleAction action = GetRuleAction(amqpDescription.Action); RuleDescription description = new RuleDescription(filter) { Action = action, Name = amqpDescription.RuleName }; return(description); }
private static RuleAction GetInverseAction(RuleAction action) { if (action == RuleAction.Delete) { return RuleAction.Space; } else if (action == RuleAction.Space) { return RuleAction.Delete; } else { return action; } }
public ShowRule(XmlReader reader) { this.SetToDefaults(); reader.Read(); while (reader.Name != "Rule") return; reader.Read(); while (reader.Name != "Rule") { if (reader.Name == "DoWhatNow") this.DoWhatNow = (RuleAction) reader.ReadElementContentAsInt(); else if (reader.Name == "First") this.First = reader.ReadElementContentAsInt(); else if (reader.Name == "Second") this.Second = reader.ReadElementContentAsInt(); else if (reader.Name == "Text") this.UserSuppliedText = reader.ReadElementContentAsString(); else reader.ReadOuterXml(); } }
private RuleSet CreateProjectRuleSetWithInclude(int rules, string solutionRuleSetToInclude, IncludeType solutionIncludeType, RuleAction defaultAction) { return this.CreateProjectRuleSetWithIncludes(rules, solutionRuleSetToInclude, solutionIncludeType, defaultAction); }
private RuleSet CreateUserSharedRuleSet(string ruleSetFileName, RuleAction defaultAction = RuleAction.Warning, int rules = DefaultNumberOfRules) { RuleSet ruleSet = TestRuleSetHelper.CreateTestRuleSet(rules); ruleSet.Rules.ToList().ForEach(r => r.Action = defaultAction); ruleSet.FilePath = Path.Combine(this.SolutionSharedRuleSetFolder, ruleSetFileName); ruleSet.WriteToFile(ruleSet.FilePath); this.temporaryFiles.AddFile(ruleSet.FilePath, false); return ruleSet; }
private RuleSet CreateVsRuleSet(int rules, string ruleSetFileName, RuleAction defaultAction = RuleAction.Warning) { RuleSet ruleSet = TestRuleSetHelper.CreateTestRuleSet(rules); ruleSet.Rules.ToList().ForEach(r => r.Action = defaultAction); ruleSet.FilePath = Path.Combine(this.VsRuleSetsDirectory, ruleSetFileName); ruleSet.WriteToFile(ruleSet.FilePath); this.temporaryFiles.AddFile(ruleSet.FilePath, false); return ruleSet; }
public Rule(string pattern, string scopeName) { Pattern = new Regex(pattern); ScopeName = scopeName; action = RuleAction.JustEmit; }
public void SetAction(RuleAction action, string actionScopeName) { this.action = action; this.actionScopeName = actionScopeName; }
private RuleSet CreateProjectRuleSetWithIncludes(int rules, string solutionRuleSetToInclude, IncludeType solutionIncludeType, RuleAction defaultAction = RuleAction.Warning, params string[] otherIncludes) { string projectRuleSetFilePath = Path.Combine(this.ProjectRuleSetFolder, Guid.NewGuid() + ".ruleset"); string solutionInclude = solutionIncludeType == IncludeType.AsIs ? solutionRuleSetToInclude : PathHelper.CalculateRelativePath(projectRuleSetFilePath, solutionRuleSetToInclude); string[] includes = new[] { solutionInclude }; if ((otherIncludes?.Length ?? 0) > 0) { includes = includes.Concat(otherIncludes).ToArray(); } RuleSet ruleSet = TestRuleSetHelper.CreateTestRuleSet(rules, includes); ruleSet.Rules.ToList().ForEach(r => r.Action = defaultAction); ruleSet.FilePath = projectRuleSetFilePath; ruleSet.WriteToFile(ruleSet.FilePath); this.temporaryFiles.AddFile(ruleSet.FilePath, false); return ruleSet; }
internal /*for testing purposes*/ static bool IsBaselineWeakend(RuleAction baselineAction, RuleAction targetAction) { Debug.Assert(baselineAction != RuleAction.Default, "'Default' is invalid value for rule. RuleSet schema should prevent this"); Debug.Assert(targetAction != RuleAction.Default, "'Default' is invalid value for rule. RuleSet schema should prevent this"); int baselineStrictness = Array.IndexOf(ruleActionStrictnessOrder, baselineAction); int targetStrictness = Array.IndexOf(ruleActionStrictnessOrder, targetAction); return baselineStrictness > targetStrictness; }
public void SetToDefaults() { this.DoWhatNow = RuleAction.kIgnoreEp; this.First = this.Second = -1; this.UserSuppliedText = ""; }
public void SetAction(RuleAction action) { SetAction(action, ScopeName); }