/// <summary> /// Attaches the compiler to all definitions. /// </summary> /// <param name="compiler">The csmpiler.</param> public void Attach(IConditionCompiler compiler) { foreach (var def in this.AllDefinitions) { def.Attach(compiler); } }
/// <summary> /// Deserializes all definitions and events from the specified directory. /// </summary> /// <param name="compiler">The condition compiler to use.</param> /// <param name="path">The path to the directory.</param> /// <returns>A tuple of definitions and events from the directory.</returns> public static DefinitionCollection DeserializeFromDirectory(IConditionCompiler compiler, string path) { List <BaseDefinition> defs = new List <BaseDefinition>(); foreach (string file in Directory.EnumerateFiles(path, "*.json", SearchOption.AllDirectories)) { string json = File.ReadAllText(file); DefinitionFile?deserializedFile = JsonSerializer.Deserialize <DefinitionFile>(json, JsonOptions); if (deserializedFile != null) { foreach (BaseDefinition eve in deserializedFile.AllDefinitions) { if (eve is ITopLevelDefinition toplevel) { toplevel.SourceFile = file; } defs.Add(eve); } } } var definitions = new DefinitionCollection(defs); definitions.Attach(compiler); return(definitions); }
public static void reset() { objectConditionCompiler = null; existConditionCompiler = null; temporalConditionCompiler = null; testConditionCompiler = null; compilerProvider = null; }
public static void reset() { objectConditionCompiler = null; existConditionCompiler = null; temporalConditionCompiler = null; testConditionCompiler = null; compilerProvider = null; }
public static CompilerProvider getInstance(IRuleCompiler ruleCompiler) { if (compilerProvider == null) { objectConditionCompiler = new ObjectConditionCompiler(ruleCompiler); existConditionCompiler = new ExistConditionCompiler(objectConditionCompiler); temporalConditionCompiler = new TemporalConditionCompiler(ruleCompiler); testConditionCompiler = new TestConditionCompiler(ruleCompiler); compilerProvider = new CompilerProvider(); } return(compilerProvider); }
public static CompilerProvider getInstance(IRuleCompiler ruleCompiler) { if (compilerProvider == null) { objectConditionCompiler = new ObjectConditionCompiler(ruleCompiler); existConditionCompiler = new ExistConditionCompiler(objectConditionCompiler); temporalConditionCompiler = new TemporalConditionCompiler(ruleCompiler); testConditionCompiler = new TestConditionCompiler(ruleCompiler); compilerProvider = new CompilerProvider(); } return compilerProvider; }
public SyncService(IServiceProvider serviceProvider) { _logger = serviceProvider.GetService <ILogger <SyncService> >(); _mapper = serviceProvider.GetService <IMapper>(); _notification = serviceProvider.GetService <INotificationManager>(); _condition = serviceProvider.GetService <IConditionCompiler>(); _audit = serviceProvider.GetService <IAuditManager>(); _context = serviceProvider.GetService <ApiContext>(); var config = serviceProvider.GetService <IConfiguration>(); _alertInterval = config.GetValue <int>("Api:Alert:IntervalMin"); _alertMessage = config.GetValue <string>("Api:Alert:Message"); _url = config.GetValue <string>("NiceHash:Url"); _request = config.GetValue <string>("NiceHash:Request"); _locations = config.GetSection("NiceHash:Locations").Get <int[]>(); }
/// <summary> /// Initializes a new instance of the <see cref="HistoryGenerator"/> class. /// </summary> /// <param name="compiler">THe condition compiler to use.</param> /// <param name="definitionDirectory">A directory full of definition json files.</param> /// <param name="additionalDefinitionDirectories">Optional additional directories to get definition json files from.</param> public HistoryGenerator(IConditionCompiler compiler, string definitionDirectory, params string[] additionalDefinitionDirectories) : this(DefinitionSerializer.DeserializeFromDirectory(compiler, definitionDirectory) .Combine(additionalDefinitionDirectories.Select(d => DefinitionSerializer.DeserializeFromDirectory(compiler, d)).ToArray())) { }
public ExistConditionCompiler(IConditionCompiler conditionCompiler) { this.conditionCompiler = conditionCompiler; ruleCompiler = (DefaultRuleCompiler)conditionCompiler.RuleCompiler; }
/// <summary> /// Attaches the compiler to this definition. /// </summary> /// <param name="compiler">The compiler.</param> /// <param name="upsteamDefinition">The upstream definition.</param> public virtual void Attach(IConditionCompiler compiler, BaseDefinition?upsteamDefinition = null) { this.Compiler = compiler; this.UpsteamDefinition = upsteamDefinition; }
public ExistConditionCompiler(IConditionCompiler conditionCompiler) { this.conditionCompiler = conditionCompiler; ruleCompiler = (DefaultRuleCompiler) conditionCompiler.RuleCompiler; }