Beispiel #1
0
        public IFactResult TryUpdateAll(IEnumerable <object> facts, BatchOptions options)
        {
            if (facts == null)
            {
                throw new ArgumentNullException(nameof(facts));
            }

            var failed      = new List <object>();
            var toPropagate = new List <Fact>();

            foreach (var fact in facts)
            {
                var factWrapper = _workingMemory.GetFact(fact);
                if (factWrapper != null && factWrapper.Source == null)
                {
                    UpdateFact(factWrapper, fact);
                    toPropagate.Add(factWrapper);
                }
                else
                {
                    failed.Add(fact);
                }
            }

            var result = new FactResult(failed);

            if (result.FailedCount == 0 || options == BatchOptions.SkipFailed)
            {
                foreach (var fact in toPropagate)
                {
                    _workingMemory.UpdateFact(fact);
                }

                _network.PropagateUpdate(_executionContext, toPropagate);

                PropagateLinked();
            }
            return(result);
        }