コード例 #1
0
        /// <summary>
        /// Create a visualization for the specified object.
        /// </summary>
        /// <param name="objectToVisualize"></param>
        /// <returns></returns>
        public FrameworkElement CreateVisualization(object objectToVisualize)
        {
            if (objectToVisualize == null)
            {
                throw new ArgumentNullException("objectToVisualize");
            }

            ModelVisualizationRegistration registration = GetRegistrationForExactType(objectToVisualize);

            if (registration == null)
            {
                registration = GetRegistrationForInterface(objectToVisualize);
            }

            if (registration == null)
            {
                if (!MustVisualize(objectToVisualize))
                {
                    return(objectToVisualize as FrameworkElement);
                }

                throw new InvalidOperationException(string.Format("No Visualization registered for {0}", objectToVisualize.GetType()));
            }
            return(CreateVisualization(objectToVisualize, registration));
        }
コード例 #2
0
        /// <summary>
        /// Creates the visualization for the specified object.
        /// </summary>
        /// <param name="objectToVisualize">The object to visualize.</param>
        /// <param name="registration">The registration.</param>
        /// <returns></returns>
        protected virtual FrameworkElement CreateVisualization(object objectToVisualize, ModelVisualizationRegistration registration)
        {
            var view = this.container.Resolve(registration.ViewType) as FrameworkElement;

            return(new ModelVisualizer(objectToVisualize, view));
        }