Beispiel #1
0
 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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 private void Rebuild()
 {
     this.RemoveEventHandlers();
     if (this.PropertyValue != null)
     {
         this.childrenView = CollectionViewSource.GetDefaultView(this.PropertyValue.get_Collection());
         this.childrenView.CurrentChanged    += new EventHandler(this.OnChildrenViewCurrentChanged);
         this.childrenView.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnCollectionChanged);
         this.childrenView.MoveCurrentTo(null);
         this.UpdateSelectedItem();
         using (IEnumerator <KeyValuePair <Type, IList <NewItemFactory> > > enumerator1 = ((IEnumerable <KeyValuePair <Type, IList <NewItemFactory> > >)ExtensibilityMetadataHelper.GetNewItemFactoriesFromAttributes(this.model.GetNewItemTypesAttributes(), this.model.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.quickTypeCollection.Add(new NewItemFactoryTypeModel(current1.Key, current2, this.model.MessageLoggingService));
                     }
                 }
             }
         }
         this.quickTypes.CurrentChanged += new EventHandler(this.OnQuickTypesCurrentChanged);
     }
     else
     {
         this.childrenView = (ICollectionView)null;
     }
     this.OnPropertyChanged("ChildrenView");
 }
 private void Rebuild()
 {
     this.RemoveEventHandlers();
     if (this.PropertyValue != null)
     {
         this.childrenView = CollectionViewSource.GetDefaultView((object)this.PropertyValue.Collection);
         this.childrenView.CurrentChanged    += new EventHandler(this.OnChildrenViewCurrentChanged);
         this.childrenView.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnCollectionChanged);
         this.childrenView.MoveCurrentTo((object)null);
         this.UpdateSelectedItem();
         foreach (KeyValuePair <Type, IList <NewItemFactory> > keyValuePair in (IEnumerable <KeyValuePair <Type, IList <NewItemFactory> > >)ExtensibilityMetadataHelper.GetNewItemFactoriesFromAttributes(this.model.GetNewItemTypesAttributes(), this.model.MessageLoggingService))
         {
             foreach (NewItemFactory factory in (IEnumerable <NewItemFactory>)keyValuePair.Value)
             {
                 this.quickTypeCollection.Add(new NewItemFactoryTypeModel(keyValuePair.Key, factory, this.model.MessageLoggingService));
             }
         }
         this.quickTypes.CurrentChanged += new EventHandler(this.OnQuickTypesCurrentChanged);
     }
     else
     {
         this.childrenView = (ICollectionView)null;
     }
     this.OnPropertyChanged("ChildrenView");
 }