private void AddItem(NewItemFactoryTypeModel itemFactoryTypeModel) { if (itemFactoryTypeModel != null) { try { object instance = itemFactoryTypeModel.CreateInstance(); if (instance == null) { return; } this.SetPropertyAsObject(instance); } catch (Exception ex) { ((SceneNodeProperty)this.PropertyValue.get_ParentProperty()).SceneNodeObjectSet.DesignerContext.MessageLoggingService.WriteLine(string.Format((IFormatProvider)CultureInfo.CurrentCulture, ExceptionStringTable.ObjectEditorViewCollectionItemFactoryInstantiateFailed, new object[2] { (object)((object)itemFactoryTypeModel.ItemFactory).GetType().Name, (object)ExtensibilityMetadataHelper.GetExceptionMessage(ex) })); } } else { Type type = this.PromptForClrType(); if (!(type != (Type)null)) { return; } this.SetPropertyAsType(type); } }
// Helper method to find if the propertyvalueeditor is reusable for the // given properties collection. public static bool IsEditorReusable(IEnumerable <ModelProperty> properties) { if (properties == null) { return(true); } foreach (ModelProperty property in properties) { // even if one property says the editor is not reusable, then // the editor is not reusable for this whole list. if (!ExtensibilityMetadataHelper.IsEditorReusable(property.Attributes)) { return(false); } } return(true); }
// <summary> // Look for and return any custom PropertyValueEditor defined for the specified ModelProperty // </summary> // <param name="property">ModelProperty to examine</param> // <returns>A custom PropertyValueEditor for the specified ModelProperty (may be null)</returns> public static PropertyValueEditor GetCustomPropertyValueEditor(ModelProperty property) { if (property == null) { return(null); } PropertyValueEditor editor = ExtensibilityMetadataHelper.GetValueEditor(property.Attributes, MessageLogger.Instance); //if property is a generic type, check for designer defined at generic type definition if (editor == null && property.PropertyType.IsGenericType) { Type genericType = property.PropertyType.GetGenericTypeDefinition(); editor = ExtensibilityMetadataHelper.GetValueEditor(TypeDescriptor.GetAttributes(genericType), MessageLogger.Instance); } return(editor); }
// <summary> // ----s open the specified Type and looks for EditorAttributes that represent // CategoryEditors - returns the Types of those editors, if any are found, as a list // </summary> // <param name="ownerType">Type to ---- open</param> // <returns>List of CategoryEditors associated with the specified type, if any. Null otherwise.</returns> public static IEnumerable <Type> GetCategoryEditorTypes(Type ownerType) { List <Type> editorTypes = null; foreach (EditorAttribute editorAttribute in GetAttributes <EditorAttribute>(ownerType)) { // A ---- attempt at using the same extensibility code Type editorType = ExtensibilityMetadataHelper.GetCategoryEditorType(editorAttribute, MessageLogger.Instance); if (editorType == null) { continue; } if (editorTypes == null) { editorTypes = new List <Type>(); } editorTypes.Add(editorType); } return(editorTypes); }
private void Rebuild() { this.quickTypeList.Clear(); if (this.quickTypeView != null) { this.quickTypeView.CurrentChanged -= new EventHandler(this.OnQuickTypeViewCurrentChanged); } if (this.PropertyValue != null) { SceneNodeProperty sceneNodeProperty = (SceneNodeProperty)this.PropertyValue.get_ParentProperty(); using (IEnumerator <KeyValuePair <Type, IList <NewItemFactory> > > enumerator1 = ((IEnumerable <KeyValuePair <Type, IList <NewItemFactory> > >)ExtensibilityMetadataHelper.GetNewItemFactoriesFromAttributes(sceneNodeProperty.GetAttributes <NewItemTypesAttribute>(true), sceneNodeProperty.SceneNodeObjectSet.DesignerContext.MessageLoggingService)).GetEnumerator()) { while (((IEnumerator)enumerator1).MoveNext()) { KeyValuePair <Type, IList <NewItemFactory> > current1 = enumerator1.Current; using (IEnumerator <NewItemFactory> enumerator2 = ((IEnumerable <NewItemFactory>)current1.Value).GetEnumerator()) { while (((IEnumerator)enumerator2).MoveNext()) { NewItemFactory current2 = enumerator2.Current; this.quickTypeList.Add((object)new NewItemFactoryTypeModel(current1.Key, current2, sceneNodeProperty.SceneNodeObjectSet.DesignerContext.MessageLoggingService)); } } } } this.quickTypeView.CurrentChanged += new EventHandler(this.OnQuickTypeViewCurrentChanged); } this.OnPropertyChanged("PropertyValueTypeName"); this.OnPropertyChanged("QuickTypeList"); }
private void Rebuild() { this.quickTypeList.Clear(); if (this.quickTypeView != null) { this.quickTypeView.CurrentChanged -= new EventHandler(this.OnQuickTypeViewCurrentChanged); } if (this.PropertyValue != null) { SceneNodeProperty sceneNodeProperty = (SceneNodeProperty)this.PropertyValue.ParentProperty; foreach (KeyValuePair <Type, IList <NewItemFactory> > keyValuePair in (IEnumerable <KeyValuePair <Type, IList <NewItemFactory> > >)ExtensibilityMetadataHelper.GetNewItemFactoriesFromAttributes(sceneNodeProperty.GetAttributes <NewItemTypesAttribute>(true), sceneNodeProperty.SceneNodeObjectSet.DesignerContext.MessageLoggingService)) { foreach (NewItemFactory factory in (IEnumerable <NewItemFactory>)keyValuePair.Value) { this.quickTypeList.Add((object)new NewItemFactoryTypeModel(keyValuePair.Key, factory, sceneNodeProperty.SceneNodeObjectSet.DesignerContext.MessageLoggingService)); } } this.quickTypeView.CurrentChanged += new EventHandler(this.OnQuickTypeViewCurrentChanged); } this.OnPropertyChanged("PropertyValueTypeName"); this.OnPropertyChanged("QuickTypeList"); }