Пример #1
0
        public ViewServiceCreateResult CreateViews(
            Viewable eventStreamViewable,
            IList <ViewFactory> viewFactories,
            AgentInstanceViewFactoryChainContext viewFactoryChainContext,
            bool hasPreviousNode)
        {
            // Attempt to find existing views under the stream that match specs.
            // The viewSpecList may have been changed by this method.
            Pair <Viewable, IList <View> > resultPair;

            if (hasPreviousNode)
            {
                resultPair = new Pair <Viewable, IList <View> >(eventStreamViewable, Collections.GetEmptyList <View>());
            }
            else
            {
                resultPair = ViewServiceHelper.MatchExistingViews(eventStreamViewable, viewFactories, viewFactoryChainContext.AgentInstanceContext);
            }

            var parentViewable = resultPair.First;

            if (viewFactories.IsEmpty())
            {
                if (Log.IsDebugEnabled)
                {
                    Log.Debug(".createView No new views created, dumping stream ... " + eventStreamViewable);
                    ViewSupport.DumpChildViews("EventStream ", eventStreamViewable);
                }

                return(new ViewServiceCreateResult(parentViewable, parentViewable, Collections.GetEmptyList <View>()));   // we know its a view here since the factory list is empty
            }

            // Instantiate remaining chain of views from the remaining factories which didn't match to existing views.
            var views = ViewServiceHelper.InstantiateChain(parentViewable, viewFactories, viewFactoryChainContext);

            // Initialize any views that need initializing after the chain is complete
            foreach (var view in views)
            {
                if (view is InitializableView)
                {
                    var initView = (InitializableView)view;
                    initView.Initialize();
                }
            }

            if (Log.IsDebugEnabled)
            {
                Log.Debug(".createView New views created for stream, all views ... " + eventStreamViewable);
                ViewSupport.DumpChildViews("EventStream ", eventStreamViewable);
            }

            return(new ViewServiceCreateResult(views[views.Count - 1], views[0], views));
        }
Пример #2
0
        public void Remove(EventStream eventStream, Viewable viewToRemove)
        {
            // If the viewToRemove to remove has child viewToRemove, don't disconnect - the child ViewToRemove(s) need this
            if (viewToRemove.HasViews)
            {
                return;
            }

            if (Log.IsDebugEnabled)
            {
                Log.Debug(".remove Views before the remove of view " + viewToRemove + ", for event stream " + eventStream);
                ViewSupport.DumpChildViews("EventStream ", eventStream);
            }

            // Remove views in chain leaving only non-empty parent views to the child view to be removed
            ViewServiceHelper.RemoveChainLeafView(eventStream, viewToRemove);

            if (Log.IsDebugEnabled)
            {
                Log.Debug(".remove Views after the remove, for event stream " + eventStream);
                ViewSupport.DumpChildViews("EventStream ", eventStream);
            }
        }