Ejemplo n.º 1
0
        /// <summary>
        /// Creates a view for the specified extension point and GUI toolkit.
        /// </summary>
        /// <param name="extensionPoint">The view extension point.</param>
        /// <param name="toolkitId">The identifier of the desired GUI toolkit.</param>
        /// <returns>A new instance of a view extension for the specified extension point.</returns>
        /// <exception cref="NotSupportedException">Thrown if a view extension matching the specified GUI toolkit does not exist.</exception>
        public static IView CreateView(IExtensionPoint extensionPoint, string toolkitId)
        {
            // create an attribute representing the GUI toolkitID
            GuiToolkitAttribute toolkitAttr = new GuiToolkitAttribute(toolkitId);

            // create an extension that is tagged with the same toolkit
            return((IView)extensionPoint.CreateExtension(new AttributeExtensionFilter(toolkitAttr)));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets whether or not a view is available for the view extension point associated with specified model type and current GUI toolkit.
        /// </summary>
        /// <remarks>
        /// The view is determined based on the view extension point that is associated with the specified
        /// model type using the <see cref="AssociateViewAttribute"/> attribute.
        /// </remarks>
        /// <param name="modelType">The type of the model object.</param>
        /// <returns>True if a matching, associated view extension is available; False otherwise.</returns>
        /// <exception cref="ArgumentException">Thrown if the type <paramref name="modelType"/> does not have an associated view extension point (doesn't define <see cref="AssociateViewAttribute"/>).</exception>
        /// <exception cref="InvalidOperationException">Thrown if the main application view has not been created yet.</exception>
        public static bool IsAssociatedViewAvailable(Type modelType)
        {
            IExtensionPoint viewExtPoint = GetViewExtensionPoint(modelType);

            // check if any extensions are available that match the GUI toolkit
            GuiToolkitAttribute toolkitAttr = new GuiToolkitAttribute(Application.GuiToolkitID);

            return(viewExtPoint.ListExtensions(new AttributeExtensionFilter(toolkitAttr)).Length > 0);
        }