示例#1
0
        public void Show()
        {
            IConductor conductor = this.Parent as IConductor;

            if (conductor == null)
            {
                return;
            }

            conductor.ActivateItem(this);
        }
示例#2
0
        private IEnumerable <IResult> ActivateItem(IConductor parent, TItem item)
        {
            if (OpenResult.BeforeActivation != null)
            {
                yield return(new SequentialResult(OpenResult.BeforeActivation(item).GetEnumerator()));
            }

            yield return(new DelegateResult(() => parent.ActivateItem(item)));

            if (OpenResult.AfterActivation != null)
            {
                yield return(new SequentialResult(OpenResult.AfterActivation(item).GetEnumerator()));
            }
        }
        public void Execute(ActionExecutionContext context)
        {
            if (_locateParent == null)
            {
                _locateParent = c => (IConductor)c.Target;
            }

            IConductor parent = _locateParent(context);
            TChild     child  = _locateChild(context);

            if (_onConfigure != null)
            {
                _onConfigure(child);
            }

            parent.ActivateItem(child);
            Completed(this, new ResultCompletionEventArgs());
        }
示例#4
0
        public void Navigate <T>(params object[] parameters) where T : IScreen
        {
            if (_conductor == null)
            {
                throw new InvalidOperationException("You should initialize this service before use it");
            }

            List <global::Autofac.Core.Parameter> typedParameters = new List <global::Autofac.Core.Parameter>();

            foreach (var parameter in parameters)
            {
                var typedParameter = new TypedParameter(parameter.GetType(), parameter);
                typedParameters.Add(typedParameter);
            }

            var screen = (IScreen)_diContainer.Resolve(typeof(T), typedParameters);

            _conductor.ActivateItem(screen);
        }
示例#5
0
        /// <summary>
        /// Opens the specified screen.
        /// </summary>
        /// <param name="conductor">The conductor.</param>
        /// <param name="subjectSpecification">The subject.</param>
        /// <param name="callback">Is called with true if the screen is activated.</param>
        public static void ActivateSubject(this IConductor conductor, ISubjectSpecification subjectSpecification, Action <bool> callback)
        {
            var found = conductor.GetChildren()
                        .OfType <IHaveSubject>()
                        .FirstOrDefault(subjectSpecification.Matches);

            EventHandler <ActivationProcessedEventArgs> processed = null;

            processed = (s, e) => {
                conductor.ActivationProcessed -= processed;
                callback(e.Success);
            };

            conductor.ActivationProcessed += processed;

            if (found != null)
            {
                conductor.ActivateItem(found);
            }
            else
            {
                subjectSpecification.CreateSubjectHost(viewModelFactory, conductor.ActivateItem);
            }
        }
示例#6
0
 public void Show()
 {
     Conductor.ActivateItem(this);
 }