コード例 #1
0
        public void AddRules(IList <RuleItem> listRules)
        {
            if (_ruleContent == null)
            {
                _ruleContent = new RuleContent();
            }

            if (listRules != null && listRules.Count != 0)
            {
                _ruleContent.Add(listRules);
            }
        }
コード例 #2
0
        public RuleContent Load(RuleContext context)
        {
            #region Validations

            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (context.Engine == null)
            {
                throw new ArgumentNullException(nameof(context) + ".Engine");
            }

            if (context.Rule == null)
            {
                throw new ArgumentNullException(nameof(context) + ".Rule");
            }

            #endregion


            /*
             *
             */
            string extension = ".txt";

            RuleEngineContentAttribute eca = context.Engine.GetType().GetCustomAttribute <RuleEngineContentAttribute>();

            if (eca != null && eca.Extension != null)
            {
                extension = eca.Extension;
            }


            /*
             *
             */
            string fileName;

            if (context.RuleVariant == null)
            {
                fileName = context.Rule.Name + extension;
            }
            else
            {
                fileName = context.Rule.Name + "-" + context.RuleVariant + extension;
            }


            /*
             *
             */
            string path = Path.Combine(_baseDir, fileName);

            if (File.Exists(path) == false)
            {
                return(null);
            }


            /*
             *
             */
            RuleContent rc = new RuleContent();
            rc.Bytes        = File.ReadAllBytes(path);
            rc.LastModified = File.GetLastWriteTime(path);
            rc.Version      = "TODO:md5sum";

            return(rc);
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SharedContentConfigurator"/> class.
 /// </summary>
 public SharedContentConfigurator()
 {
     _ruleContent   = new RuleContent();
     _sharedContent = new SharedContent();
     _configContent = new ConfiguratorContent();
 }