public void RaiseWithinUnitOfWork(IFact fact, IUnitOfWork unitOfWork)
 {
     var handlerType = typeof(IHandleDuringUnitOfWork<>).MakeGenericType(fact.GetType());
     var handlersType = typeof(IEnumerable<>).MakeGenericType(handlerType);
     using (var scope = _lifetimeScope.BeginLifetimeScope())
     {
         var handlers = (IEnumerable)scope.Resolve(handlersType, new Parameter[] { new TypedParameter(typeof(IUnitOfWork), unitOfWork) });
         foreach (var handler in handlers)
             ((dynamic)handler).Handle((dynamic)fact);
     }
 }
Esempio n. 2
0
        public void Raise(IFact fact)
        {
            RaiseForBaseHandlers(fact);

            var handlerType = typeof (IHandle<>).MakeGenericType(fact.GetType());
            var handlersType = typeof (IEnumerable<>).MakeGenericType(handlerType);
            using (var scope = _lifetimeScope.BeginLifetimeScope())
            {
                var handlers = (IEnumerable) scope.Resolve(handlersType);

                foreach (var handler in handlers)
                    ((dynamic) handler).Handle((dynamic) fact);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a new fact from a user response to a fact question
        /// </summary>
        /// <param name="a_fact">Ifact object with a valid question</param>
        /// <returns></returns>
        protected IFact CreateFact(IFact a_fact)
        {
            IFact newFact;

            if (a_fact.GetType().Equals(typeof(IntFact)))
            {
                int value = AskIntValue(a_fact.Question);
                newFact = new IntFact(a_fact.Name, value, 0, null);
            }
            else
            {
                bool value = AskBoolValue(a_fact.Question);
                newFact = new BoolFact(a_fact.Name, value, 0, null);
            }
            return(newFact);
        }
Esempio n. 4
0
        internal static IFact Fact(IFact f, Motor m)
        {
            IFact newFact;

            if (f.GetType().Equals(typeof(IntFact)))
            {
                int value = m.AskIntVAlue(f.Question);
                newFact = new IntFact(f.Name, value, null, 0);
            }
            else
            {
                bool value = m.AskBoolValue(f.Question);
                newFact = new BoolFact(f.Name, value, null, 0);
            }

            return(newFact);
        }
        internal static IFact Fact(IFact f, Motor m)
        {
            IFact newFact;

            if (f.GetType().Equals(typeof(IntFact)))
            {
                // Es un hecho de valor entero
                int value = m.AskIntValue(f.Question());
                newFact = new IntFact(f.Name(), value, null, 0);
            }
            else
            {
                // Es un hecho de valor booleano
                bool value = m.AskIntValue(f.Question());
                newFact = new IntFact(f.Name(), value, null, 0);
            }
            return(newFact);
        }
Esempio n. 6
0
    internal static IFact Fact(IFact f, Motor m)
    {
        IFact newFact;

        if (f.GetType().Equals(typeof(IntFact)))
        {
            // C'est un fait à valeur entière
            int value = m.AskIntValue(f.Question());
            newFact = new IntFact(f.Name(), value, null, 0);
        }
        else
        {
            // C'est un fait à valeur booléenne
            bool value = m.AskBoolValue(f.Question());
            newFact = new BoolFact(f.Name(), value, null, 0);
        }
        return(newFact);
    }