Ejemplo n.º 1
0
        public IAgent CreateFor(Unit unit)
        {
            if (unit == null)
            {
                throw new Exception("AgentBuilder requires a unit to build for");
            }

            if (unit.Id == 0)
            {
                throw new Exception("Unit must have a valid Id");
            }

            var utilityVariables     = new UtilityVariables();
            var considerationHandler = new ConsiderationHandler(new CustomRefreshScheduler(EventSystem), utilityVariables, unit);
            var adviceHandler        = new AdviceHandler(new CustomRefreshScheduler(EventSystem), utilityVariables, unit);
            var agent = new Agent(unit, utilityVariables, considerationHandler, adviceHandler);

            return(agent);
        }
Ejemplo n.º 2
0
        private void SetupConfiguration()
        {
            foreach (IConfiguration child in FacilityConfig.Children)
            {
                AdviceHandler advice = new AdviceHandler();
                advices.Add(advice);
                foreach (IConfiguration configuration in child.Children)
                {
                    switch (configuration.Name)
                    {
                    case "pointcut":
                        advice.PointcutComponents.Add(configuration.Attributes["component-id"], false);
                        break;

                    case "aspect":
                        advice.AspectComponents.Add(configuration.Attributes["component-id"], false);
                        break;

                    default:
                        throw new InvalidOperationException("Only <pointcuts> and <aspects> sub elements are allowed");
                    }
                }
            }
        }