Beispiel #1
0
        static void SetTargetCore(DependencyPropertyChangedEventArgs e, DependencyObject d, bool setContext)
        {
            if (controller == null)
            {
                return;
            }

            if (e.NewValue != e.OldValue && e.NewValue != null)
            {
                var target = e.NewValue;

#if SILVERLIGHT
                var containerKey = e.NewValue as string;

                if (containerKey != null)
                {
                    target = serviceLocator.GetInstance(null, containerKey);
                }
#endif

                var handler = new ActionMessageHandler(
                    viewModelDescriptionFactory.Create(target.GetType()),
                    target
                    );

                controller.AddHandler(d, handler, setContext);
            }
        }
        void CreateAction()
        {
            var host = factory.Create(Command.GetType());

            host.Actions.SelectMany(x => x.Filters.HandlerAware)
            .Union(host.Filters.HandlerAware)
            .Apply(x => x.MakeAwareOf(this));

            CreateActionMessage();

            action            = host.GetAction(actionMessage);
            action.Completed += delegate { OnCompleted(); };
        }
        /// <summary>
        /// Applies the conventions.
        /// </summary>
        /// <param name="viewModel">The view model.</param>
        /// <param name="view">The view.</param>
        protected virtual void ApplyConventions(object viewModel, DependencyObject view)
        {
            var modelType   = GetModelType(viewModel);
            var description = viewModelDescriptionFactory.Create(modelType);

#if !SILVERLIGHT
            var isLoaded = view.IsLoaded();
#else
            var isLoaded = view.GetValue(View.IsLoadedProperty);
#endif
            description.GetConventionsFor(view)
            .Apply(x => x.ApplyTo(view, isLoaded));

            view.SetValue(View.ConventionsAppliedProperty, true);

            Log.Info("Applied conventions to {0} and {1}.", view, viewModel);
        }
Beispiel #4
0
        void CreateAction(bool forceRecreate)
        {
            if (action != null && !forceRecreate)
            {
                return;
            }

            var host = factory.Create(Command.GetType());

            host.Actions.SelectMany(x => x.Filters.HandlerAware)
            .Union(host.Filters.HandlerAware)
            .Apply(x => x.MakeAwareOf(this));

            CreateActionMessage();

            action            = host.GetAction(actionMessage);
            action.Completed += delegate { OnCompleted(); };
        }