private void Initialize()
        {
            ControllerTree tree = (ControllerTree)Kernel["mvc.controllerTree"];

            if (_assembly != null)
            {
                Type[] types = _assembly.GetExportedTypes();

                foreach (Type type in types)
                {
                    // Web page / UserControl
                    if (type.IsSubclassOf(typeof(WebFormView)) || type.IsSubclassOf(typeof(WebUserControlView)))
                    {
                        // Retrieve the properties controllers
                        PropertyInfo[] properties = type.GetProperties(BINDING_FLAGS_SET);
                        for (int i = 0; i < properties.Length; i++)
                        {
                            if (properties[i].PropertyType.IsSubclassOf(typeof(Controller)))
                            {
                                tree.AddController(type, properties[i], properties[i].PropertyType);
                            }
                        }
                    }
                }
            }
        }
        public Controller CreateController(UrlInfo urlInfo)
        {
            IWindsorContainer container = ContainerAccessorUtil.ObtainContainer();

            ControllerTree tree = null;

            try
            {
                tree = (ControllerTree)container["rails.controllertree"];
            }
            catch (ComponentNotFoundException)
            {
                throw new RailsException("ControllerTree not found. Check whether RailsFacility is properly configured/registered");
            }

            String key = (String)tree.GetController(urlInfo.Area, urlInfo.Controller);

            if (key == null || key.Length == 0)
            {
                throw new ControllerNotFoundException(urlInfo);
            }

            if (container.Kernel.HasComponent(key))
            {
                return((Controller)container[key]);
            }

            return(null);
        }
Ejemplo n.º 3
0
        public void Init(IKernel kernel, IConfiguration facilityConfig)
        {
            kernel.AddComponent("rails.controllertree", typeof(ControllerTree));

            _tree = (ControllerTree)kernel["rails.controllertree"];

            kernel.ComponentModelCreated += new ComponentModelDelegate(OnComponentModelCreated);

            AddBuitInControllers(kernel);
        }
Ejemplo n.º 4
0
 public BeckhoffOnlineControllerTreeImporter(ITagImporter tagImporter)
 {
     _twinCatClient      = new TwinCatClientWrapper();
     _tagController      = new BeckhoffTagController();
     _tagListener        = new BeckhoffPollingTagListener();
     _alarmsImporter     = new BeckhoffOnlineAlarmsImporter();
     _findControllerTags = new ControllerTagFinder(tagImporter, new Log4NetLogger());
     _createController   = new ControllerFactory();
     _logger             = new Log4NetLogger();
     _controllerTree     = new ControllerTree();
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Unsubscribes the specified <paramref name="handler"/> from the controller with the specified <paramref name="controllerId"/>.
        /// The handler won't get executed on a change of the controller.
        /// </summary>
        /// <param name="controllerId">The id of the controller to not anymore observe.</param>
        /// <param name="handler">The handler to unsubscribe.</param>
        public void UnsubsribeFromControllerChanges(int controllerId, Action <IController> handler)
        {
            IController controller = ControllerTree.GetController(controllerId);

            foreach (Tag controllerTag in controller.GetAllAssociatedTags())
            {
                controllerTag.ValueChanged -= NotifySubscribers;
                SlowTagListener.RemoveTag(controllerTag);
            }

            lock (_lockSubscribers)
            {
                _subscribers.RemoveAll(t => Equals(t.Item2, handler));
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Subscribes the specified <paramref name="handler"/> on the controller with the specified <paramref name="controllerId"/>.
        /// The handler gets executed whenever the controller changed a value.
        /// </summary>
        /// <param name="controllerId">The id of the controller to observe.</param>
        /// <param name="handler">The handler to get executed on a controller change.</param>
        public void SubscribeForControllerChanges(int controllerId, Action <IController> handler)
        {
            IController controller = ControllerTree.GetController(controllerId);

            lock (_lockSubscribers)
            {
                _subscribers.Add(new Tuple <int, Action <IController> >(controllerId, handler));
            }
            foreach (Tag controllerTag in controller.GetAllAssociatedTags())
            {
                SlowTagListener.AddTag(controllerTag);
                controllerTag.ValueChanged += NotifySubscribers;
            }
            SlowTagListener.RefreshAll();
        }
Ejemplo n.º 7
0
        private void NotifySubscribers(Tag tag, TagValueChangedEventArgs args)
        {
            List <Tuple <int, Action <IController> > > subscribers;

            lock (_lockSubscribers)
            {
                subscribers = new List <Tuple <int, Action <IController> > >(_subscribers);
            }

            foreach (Tuple <int, Action <IController> > subscriber in subscribers)
            {
                IController controller = ControllerTree.TryGetController(subscriber.Item1);
                if (controller != null)
                {
                    subscriber.Item2(controller);
                }
            }
        }
Ejemplo n.º 8
0
 public BeckhoffOnlineControllerTreeImporter(
     ITwinCatClient twinCatClient,
     ITagController tagController,
     ITagListener tagListener,
     IFindControllerTags findControllerTags,
     ICreateController createController,
     IAlarmsImporter alarmsImporter,
     ILogger logger)
 {
     _twinCatClient      = twinCatClient;
     _tagController      = tagController;
     _tagListener        = tagListener;
     _alarmsImporter     = alarmsImporter;
     _findControllerTags = findControllerTags;
     _createController   = createController;
     _logger             = logger;
     _controllerTree     = new ControllerTree();
 }
Ejemplo n.º 9
0
        private static ControllerTree SetupControllerTree()
        {
            var tree = new ControllerTree();
            var tag  = new Tag();

            tag.Childs.Add(new Tag(NamingConventions.CommonInterface, "MAIN")
            {
                Value = new CtrlCommonInterface()
                {
                    Info = new CtrlInfo()
                    {
                        CtrlId = 1
                    }
                }
            });
            var controller = new Controller(new SimulatedTagController(null), new ControllerTagWrapper(tag));

            tree.Initialize(controller);
            return(tree);
        }
Ejemplo n.º 10
0
        private void WebFormView_Init(object sender, EventArgs e)
        {
            IWindsorContainer container = ContainerWebAccessorUtil.ObtainContainer();

            // Get the State
            IStatePersister statePersister = (IStatePersister)container[typeof(IStatePersister)];

            _state = statePersister.Load();
            // Acquire current view
            _state.CurrentView = ConfigUtil.Settings.GetView(this.Request.Path);
            _state.Save();

            ControllerTree tree = (ControllerTree)container["mvc.controllerTree"];
            PropertyControllerCollection propertiesController = tree.GetControllers(this.GetType().BaseType);

            if (propertiesController != null)
            {
                for (int i = 0; i < propertiesController.Count; i++)
                {
                    IController controller = container[propertiesController[i].ControllerType] as IController;
                    propertiesController[i].PropertyInfo.SetValue(this, controller, null);
                }
            }
        }
		public AbstractControllerFactory()
		{
			_tree = new ControllerTree();

			AddBuiltInControllers();
		}
Ejemplo n.º 12
0
 public BlogControllerCreatorSubscriber(BlogDao blogDao, ControllerTree controllerTree)
 {
     _blogDao        = blogDao;
     _controllerTree = controllerTree;
 }
 public SimulatedControllerTreeImporter(ITagController tagController)
 {
     _tagController  = tagController;
     _controllerTree = new ControllerTree();
 }