Example #1
0
 public RuntimeSession(RulesEngine rulesEngine, Cache <Type, ActivationTypeProxy> objectCache)
 {
     _rulesEngine = rulesEngine;
     _objectCache = objectCache;
     _memoryCache = new ConcurrentCache <int, ContextMemory>();
     _facts       = new FactCache();
     _agenda      = new AgendaImpl();
 }
Example #2
0
        public FactHandle Activate(RulesEngine rulesEngine, ActivationContext baseContext, FactCache factCache,
                                   object obj)
        {
            var fact = obj as T;

            if (fact == null)
            {
                throw new ArgumentException("The argument could not be cast to " + typeof(T).Name, "obj");
            }

            ActivationContext <T> context = baseContext.CreateContext(fact);

            rulesEngine.Activate(context);

            return(factCache.Add(context));
        }