Example #1
0
        public void GetTypeConverterAndTypeEditor(ref TypeConverter typeConverter, System.Type editorBaseType, ref object typeEditor)
        {
            TypeConverter currentConverter = typeConverter;
            object        currentEditor    = typeEditor;

            if (currentConverter == null)
            {
                currentConverter = this.GetBaseTypeConverter();
            }
            if (currentEditor == null)
            {
                currentEditor = this.GetBaseTypeEditor(editorBaseType);
            }
            if (((this.refreshState & 0x2000) == 0) && (this.PropertyType == typeof(Com2Variant)))
            {
                System.Type propertyType  = this.PropertyType;
                object      propertyValue = this.GetValue(this.TargetObject);
                if (propertyValue != null)
                {
                    propertyValue.GetType();
                }
                ComNativeDescriptor.ResolveVariantTypeConverterAndTypeEditor(propertyValue, ref currentConverter, editorBaseType, ref currentEditor);
            }
            if (currentConverter is Com2PropDescMainConverter)
            {
                currentConverter = ((Com2PropDescMainConverter)currentConverter).InnerConverter;
            }
            GetTypeConverterAndTypeEditorEvent e = new GetTypeConverterAndTypeEditorEvent(currentConverter, currentEditor);

            this.OnGetTypeConverterAndTypeEditor(e);
            currentConverter = e.TypeConverter;
            currentEditor    = e.TypeEditor;
            if (currentConverter == null)
            {
                currentConverter = this.GetBaseTypeConverter();
            }
            if (currentEditor == null)
            {
                currentEditor = this.GetBaseTypeEditor(editorBaseType);
            }
            System.Type type = currentConverter.GetType();
            if ((type != typeof(TypeConverter)) && (type != typeof(Com2PropDescMainConverter)))
            {
                currentConverter = new Com2PropDescMainConverter(this, currentConverter);
            }
            typeConverter = currentConverter;
            typeEditor    = currentEditor;
        }
Example #2
0
 /// <include file='doc\COM2PropertyDescriptor.uex' path='docs/doc[@for="Com2PropertyDescriptor.GetTypeConverterAndTypeEditor"]/*' />
 /// <devdoc>
 ///     Retrieves the value editor for the property.  If a value editor is passed
 ///     in as a TypeConverterAttribute, that value editor will be instantiated.
 ///     If no such attribute was found, a system value editor will be looked for.
 ///     See TypeConverter for a description of how system value editors are found.
 ///     If there is no system value editor, null is returned.  If the value editor found
 ///     takes an IEditorSite in its constructor, the parameter will be passed in.
 /// </devdoc>
 public void GetTypeConverterAndTypeEditor(ref TypeConverter typeConverter, Type editorBaseType, ref Object typeEditor) {
 
         // get the base editor and converter, attributes first
         TypeConverter localConverter = typeConverter;
         Object        localEditor    = typeEditor;
         
         if (localConverter == null) {
              localConverter = GetBaseTypeConverter();
         }
         
         if (localEditor == null) {
              localEditor = GetBaseTypeEditor(editorBaseType);
         }
         
         // if this is a object, get the value and attempt to create the correct value editor based on that value.
         // we don't do this if the state came from an attribute
         //
         if (0 == (refreshState & Com2PropertyDescriptorRefresh.TypeConverterAttr) && this.PropertyType == typeof(Com2Variant)) {
             Type editorType = PropertyType;
             Object value = GetValue(TargetObject);
             if (value != null) {
                 editorType = value.GetType();
             }
             ComNativeDescriptor.ResolveVariantTypeConverterAndTypeEditor(value, ref localConverter, editorBaseType, ref localEditor);
         }
         
         // now see if someone else would like to serve up a value editor
         //
         
         // unwrap the editor if it's one of ours.
         if (localConverter is Com2PropDescMainConverter) {
             localConverter = ((Com2PropDescMainConverter)localConverter).InnerConverter;
         }
          
         GetTypeConverterAndTypeEditorEvent e = new GetTypeConverterAndTypeEditorEvent(localConverter, localEditor);
         OnGetTypeConverterAndTypeEditor(e);
         localConverter = e.TypeConverter;
         localEditor    = e.TypeEditor;
         
         // just in case one of the handlers removed our editor...
         //
         if (localConverter == null) {
              localConverter = GetBaseTypeConverter();
         }
         
         if (localEditor == null) {
              localEditor = GetBaseTypeEditor(editorBaseType);
         } 
                        
         // wrap the value editor in our main value editor, but only if it isn't "TypeConverter" or already a Com2PropDescMainTypeConverter
         //
         Type localConverterType = localConverter.GetType();
         if (localConverterType != typeof(TypeConverter) && localConverterType != (typeof(Com2PropDescMainConverter))) {
             localConverter = new Com2PropDescMainConverter(this, localConverter);
         }
         
         // save the values back to the variables.
         //
         typeConverter = localConverter;
         typeEditor    = localEditor;
 }
 public void GetTypeConverterAndTypeEditor(ref TypeConverter typeConverter, System.Type editorBaseType, ref object typeEditor)
 {
     TypeConverter currentConverter = typeConverter;
     object currentEditor = typeEditor;
     if (currentConverter == null)
     {
         currentConverter = this.GetBaseTypeConverter();
     }
     if (currentEditor == null)
     {
         currentEditor = this.GetBaseTypeEditor(editorBaseType);
     }
     if (((this.refreshState & 0x2000) == 0) && (this.PropertyType == typeof(Com2Variant)))
     {
         System.Type propertyType = this.PropertyType;
         object propertyValue = this.GetValue(this.TargetObject);
         if (propertyValue != null)
         {
             propertyValue.GetType();
         }
         ComNativeDescriptor.ResolveVariantTypeConverterAndTypeEditor(propertyValue, ref currentConverter, editorBaseType, ref currentEditor);
     }
     if (currentConverter is Com2PropDescMainConverter)
     {
         currentConverter = ((Com2PropDescMainConverter) currentConverter).InnerConverter;
     }
     GetTypeConverterAndTypeEditorEvent e = new GetTypeConverterAndTypeEditorEvent(currentConverter, currentEditor);
     this.OnGetTypeConverterAndTypeEditor(e);
     currentConverter = e.TypeConverter;
     currentEditor = e.TypeEditor;
     if (currentConverter == null)
     {
         currentConverter = this.GetBaseTypeConverter();
     }
     if (currentEditor == null)
     {
         currentEditor = this.GetBaseTypeEditor(editorBaseType);
     }
     System.Type type = currentConverter.GetType();
     if ((type != typeof(TypeConverter)) && (type != typeof(Com2PropDescMainConverter)))
     {
         currentConverter = new Com2PropDescMainConverter(this, currentConverter);
     }
     typeConverter = currentConverter;
     typeEditor = currentEditor;
 }