Example #1
0
 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);
     }
 }
Example #2
0
        // This method gets called when the CurrentItem on _quickTypeView changes
        private void OnCurrentQuickTypeChanged(object sender, EventArgs e)
        {
            if (_ignoreInternalChanges)
            {
                return;
            }

            NewItemFactoryTypeModel selectedTypeModel = _quickTypeView.CurrentItem as NewItemFactoryTypeModel;

            if (selectedTypeModel == null)
            {
                return;
            }

            Fx.Assert(this.PropertyEntry != null, "PropertyEntry should not be null");
            if (this.PropertyEntry == null)
            {
                return;
            }

            bool previousValue = IgnoreInternalChanges();

            try
            {
                this.PropertyEntry.PropertyValue.Value = selectedTypeModel.CreateInstance();
            }
            finally
            {
                NoticeInternalChanges(previousValue);
            }
        }