public static Type GetCategoryEditorType(EditorAttribute attribute, IMessageLoggingService exceptionLogger) { try { Type type = Type.GetType(attribute.EditorTypeName); if (type != (Type)null) { if (typeof(CategoryEditor).IsAssignableFrom(type)) { return(type); } } } catch (Exception ex) { if (exceptionLogger != null) { exceptionLogger.WriteLine(string.Format((IFormatProvider)CultureInfo.CurrentCulture, ExceptionStringTable.CategoryEditorTypeLoadFailed, new object[1] { (object)ExtensibilityMetadataHelper.GetExceptionMessage(ex) })); } } return((Type)null); }
public static IDictionary <Type, IList <NewItemFactory> > GetNewItemFactoriesFromAttributes(IList <NewItemTypesAttribute> attributes, IMessageLoggingService exceptionLogger) { Dictionary <Type, IList <NewItemFactory> > dictionary = new Dictionary <Type, IList <NewItemFactory> >(); using (IEnumerator <NewItemTypesAttribute> enumerator = ((IEnumerable <NewItemTypesAttribute>)attributes).GetEnumerator()) { while (((IEnumerator)enumerator).MoveNext()) { NewItemTypesAttribute current = enumerator.Current; try { NewItemFactory newItemFactory = (NewItemFactory)Activator.CreateInstance(current.get_FactoryType()); if (newItemFactory != null) { foreach (Type key in current.get_Types()) { IList <NewItemFactory> list; if (!dictionary.TryGetValue(key, out list)) { list = (IList <NewItemFactory>) new List <NewItemFactory>(); dictionary.Add(key, list); } ((ICollection <NewItemFactory>)list).Add(newItemFactory); } } } catch (Exception ex) { if (exceptionLogger != null) { exceptionLogger.WriteLine(string.Format((IFormatProvider)CultureInfo.CurrentCulture, ExceptionStringTable.CollectionItemFactoryInstantiateFailed, new object[1] { (object)ExtensibilityMetadataHelper.GetExceptionMessage(ex) })); } } } } return((IDictionary <Type, IList <NewItemFactory> >)dictionary); }
public static PropertyValueEditor GetValueEditor(IEnumerable attributes, IMessageLoggingService exceptionLogger) { PropertyValueEditor propertyValueEditor = (PropertyValueEditor)null; if (attributes != null) { foreach (Attribute attribute in attributes) { EditorAttribute editorAttribute = attribute as EditorAttribute; if (editorAttribute != null) { try { Type type = Type.GetType(editorAttribute.EditorTypeName); if (type != (Type)null) { if (typeof(PropertyValueEditor).IsAssignableFrom(type)) { propertyValueEditor = (PropertyValueEditor)Activator.CreateInstance(type); break; } } } catch (Exception ex) { if (exceptionLogger != null) { exceptionLogger.WriteLine(string.Format((IFormatProvider)CultureInfo.CurrentCulture, ExceptionStringTable.ValueEditorLoadFailed, new object[1] { (object)ExtensibilityMetadataHelper.GetExceptionMessage(ex) })); } } } } } return(propertyValueEditor); }
private void AddItem() { if (this.PropertyValue == null) { return; } int currentPosition = this.ChildrenView.CurrentPosition; int num = currentPosition != -1 ? currentPosition + 1 : this.PropertyValue.get_Collection().get_Count(); NewItemFactoryTypeModel factoryTypeModel = this.quickTypes.CurrentItem as NewItemFactoryTypeModel; object obj = null; if (factoryTypeModel != null) { try { obj = factoryTypeModel.CreateInstance(); } catch (Exception ex) { this.model.MessageLoggingService.WriteLine(string.Format((IFormatProvider)CultureInfo.CurrentCulture, ExceptionStringTable.CollectionDialogEditorCollectionItemFactoryInstantiateFailed, new object[2] { (object)((object)factoryTypeModel.ItemFactory).GetType().Name, (object)ExtensibilityMetadataHelper.GetExceptionMessage(ex) })); } } else { obj = this.model.CreateType((Type)null); } if (obj == null) { return; } this.indexToSelect = num; this.PropertyValue.get_Collection().Insert(obj, num); }