Ejemplo n.º 1
0
 /// <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);
        }
Ejemplo n.º 3
0
 public static void reset()
 {
     objectConditionCompiler   = null;
     existConditionCompiler    = null;
     temporalConditionCompiler = null;
     testConditionCompiler     = null;
     compilerProvider          = null;
 }
Ejemplo n.º 4
0
 public static void reset()
 {
     objectConditionCompiler = null;
     existConditionCompiler = null;
     temporalConditionCompiler = null;
     testConditionCompiler = null;
     compilerProvider = null;
 }
Ejemplo n.º 5
0
 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);
 }
Ejemplo n.º 6
0
 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;
 }
Ejemplo n.º 7
0
        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;
 }
Ejemplo n.º 10
0
 /// <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;
 }
Ejemplo n.º 11
0
 public ExistConditionCompiler(IConditionCompiler conditionCompiler)
 {
     this.conditionCompiler = conditionCompiler;
     ruleCompiler = (DefaultRuleCompiler) conditionCompiler.RuleCompiler;
 }