/// <summary> /// Configures an <see cref="IAttributesConfigurable"/> component with the set of attributes specified. /// </summary> internal static void Configure(IAttributesConfigurable component, XmlAttribute[] attributes) { ImmutableKeyStringDictionary values = new ImmutableKeyStringDictionary(); if (attributes != null) { foreach (XmlAttribute xattr in attributes) { values.Add(xattr.Name, xattr.Value); } } component.Configure(values); }
private ArgumentPanel CreateEditingPanel(Configuration.Field field) { IValueInfoService metaDataService = (IValueInfoService)GetService(typeof(IValueInfoService)); ValueInfo argument = metaDataService.GetInfo(field.ValueName); if (argument == null) { throw new ArgumentNullException("Field"); } ArgumentPanel argumentPanel = null; ITypeResolutionService loaderService = (ITypeResolutionService)GetService(typeof(ITypeResolutionService)); Type argType = argument.Type; if (argType == null) { throw new TypeLoadException( String.Format( CultureInfo.CurrentCulture, Properties.Resources.WizardGatheringService_CannotLoadTypeStepField, argument.Name, this.Configuration.Title)); } if (argType == typeof(bool) || // The type is a simple boolean value, so let's use ArgumentPanelBool argType == typeof(Nullable <bool>)) { argumentPanel = new ArgumentPanelBool(); } else { if (!string.IsNullOrEmpty(field.PanelType)) { Type paneltype = loaderService.GetType(field.PanelType); argumentPanel = (ArgumentPanelTypeEditor)Activator.CreateInstance(paneltype); } else { argumentPanel = new ArgumentPanelTypeEditor(); } //First try to use any UITypeEditor defined for our type Type editorType = field.Editor == null ? null : loaderService.GetType(field.Editor.Type); if (editorType != null) { UITypeEditor editorInstance = (UITypeEditor)Activator.CreateInstance(editorType); if (editorInstance is IAttributesConfigurable) { ImmutableKeyStringDictionary values = new ImmutableKeyStringDictionary(); if (field.Editor.AnyAttr != null) { foreach (XmlAttribute xattr in field.Editor.AnyAttr) { values.Add(xattr.Name, xattr.Value); } } ((IAttributesConfigurable)editorInstance).Configure(values); } ((ArgumentPanelTypeEditor)argumentPanel).EditorInstance = editorInstance; } ((ArgumentPanelTypeEditor)argumentPanel).ConverterInstance = argument.Converter; } argumentPanel.FieldConfig = field; this.Arguments[argument] = argumentPanel; return(argumentPanel); }