Ejemplo n.º 1
0
        /// <summary>
        /// this method can be called many times (when parent strategy is not unique)
        /// </summary>
        /// <param name="rc"></param>
        public virtual void Initialize(IRuleContainer rc)
        {
            idCache   = -1;
            descCache = null;

            container = rc;

            //as a rule can be initialized more than once (for example when its strategy is a repeat)
            //we need to clear instruments and indicators list each time
            //instruments.Clear();

            indicators.Clear();
            addIndicators();
        }
Ejemplo n.º 2
0
        public FileServiceConfig(MimeTypeHelper.GetMimeTypeDelegate getMimeTypeDelegate, double maxUploadSize, FileSizeUnit fileSizeUnit, string rootDirectory, IRuleContainer rules, params string[] allowedExtensions)
        {
            GetMimeType   = getMimeTypeDelegate;
            MaxUploadSize = maxUploadSize;
            FileSizeUnit  = fileSizeUnit;
            RootDirectory = rootDirectory;
            Rules         = rules;

            try
            {
                Rules.AddRule <FileSizeLimitRule>();
                Rules.AddRule <FileExtensionValidationRule>();
            }
            catch (Exception)
            {
            }

            AllowedExtensions = allowedExtensions;
        }
Ejemplo n.º 3
0
 public RuleContainerGuardArg(IRuleContainer obj) : base(obj)
 {
 }
Ejemplo n.º 4
0
        public virtual IPlumber <T1, T2, TId> Create <T1, T2, TId>(ISynchSourcesConfig <T1, T2, TId> source, IRuleContainer <TId> rules)
            where TId : IEquatable <TId>
        {
            var preprocessor             = CreatePreprocessor(source, rules);
            var synchronizationResolvers = rules.GetTypedResolvers(source).ToList();
            var plumber = new ItemMatchPipelinePlumber <T1, T2, TId>(source, synchronizationResolvers, preprocessor);

            if (Appender != null)
            {
                plumber.Appender = Appender;
            }

            return(plumber);
        }
Ejemplo n.º 5
0
        // Could also put this in another factory method.
        protected virtual Func <IEnumerable <T1>, IEnumerable <T2>, IEnumerable <ItemMatch <T1, T2> > > CreatePreprocessor <T1, T2, TId>(ISynchSourcesConfig <T1, T2, TId> source, IRuleContainer <TId> rules)
            where TId : IEquatable <TId>
        {
            var matcher = new ItemMatcher <T1, T2, TId, ItemMatch <T1, T2> >(source);
            Func <IEnumerable <T1>, IEnumerable <T2>, IEnumerable <ItemMatch <T1, T2> > > preprocessor = matcher.Match;

            return(preprocessor);
        }
Ejemplo n.º 6
0
 public SqlQueryBuilder(IRuleContainer container = null)
 {
     _query     = new TSqlQuery();
     _container = container ?? DefaultRuleContainer.Instance;
 }
 public void Add(IRuleContainer ruleContainer)
 {
     containers.Add(ruleContainer);
 }
Ejemplo n.º 8
0
 public QueryTypeGuard(IRuleContainer container) : base(new GuardContextImpl(container))
 {
 }
Ejemplo n.º 9
0
        private void FillRules(Predicate<RuleEngineRule> filter, bool validate, IRuleContainer container, IEnumerable<RuleBookRule> rules, RuleBookRule[] allRules)
        {
            foreach (var rule in rules)
            {
                var treeNode = CreateRatingRule(container, rule);

                if (container is RuleEngineRule)
                    treeNode.Parent = (RuleEngineRule)container;
                treeNode.IsOverride = rule.IsOverride;
                treeNode.HasErrors = treeNode.Expression.HasErrors();
                treeNode.IsNew = rule.IsNew;
                treeNode.IsChange = rule.IsChange;
                // Check the rule for any errors
                if (validate && Validator != null)
                {
                    treeNode.ValidationErrors = Validator.ValidateRule(treeNode).ToArray();
                    if (!treeNode.HasErrors)
                        treeNode.HasErrors = treeNode.ValidationErrors.Length > 0;
                }

                RuleBookRule rule1 = rule;
                FillRules(filter, validate, treeNode, allRules.Where(p => p.ParentChangeId == rule1.ChangeId || rule1.BaseRules.Contains(p.ParentChangeId)).ToArray(), allRules);
                if (filter != null && filter(treeNode))
                {
                    container.Children.Add(treeNode);
                }
                else if (filter == null)
                {
                    container.Children.Add(treeNode);
                }
            }

            var children = container.Children.ToArray();
            // Find the exceptions
            var overrides = children.Where(p => p.RuleBookId > 0).ToArray().Select(p => p.Name);
            // Find the common ones to remove
            var remove = children.Where(p => overrides.Contains(p.Name) && p.RuleBookId == 0);
            // Remove any children with the same name
            foreach (var child in remove)
                container.Children.Remove(child);
        }
Ejemplo n.º 10
0
 //�Private�Methods�(4)
 private RuleEngineRule CreateRatingRule(IRuleContainer container, RuleBookRule rule)
 {
     return new RuleEngineRule()
     {
         Id = rule.Id.ToString(),
         RuleBookId = rule.RuleBookId,
         ChangeId = rule.ChangeId.ToString(),
         Name = rule.Name,
         Parent = rule.ParentChangeId == null ? null : container as RuleEngineRule,
         EffectiveDate = rule.EffectiveDate,
         ParentChangeId = rule.ParentChangeId,
         RuleExpression = rule.RuleExpression,
         LoopContext = rule.Context,
         Tag = rule.Tag,
         Active = rule.Active
     };
 }