예제 #1
0
        /// <summary>
        /// Construct a DataModel for the specified type.
        /// </summary>
        /// <param name="p_Type">Cell Type</param>
        /// <returns>
        /// If the Type support an <c>UITypeEditor</c> returns an <see cref="EditorUITypeEditor"/> else if the type has a StandardValues list return an <c>EditorComboBox</c>
        /// else if the type support string conversion returns an <see cref="EditorTextBox"/> otherwise returns <c>null</c>.
        /// </returns>
        public static DataModels.IDataModel CreateDataModel(Type p_Type)
        {
            System.ComponentModel.TypeConverter l_TypeConverter = System.ComponentModel.TypeDescriptor.GetConverter(p_Type);
            ICollection l_StandardValues          = null;
            bool        l_StandardValuesExclusive = false;

            if (l_TypeConverter != null)
            {
                l_StandardValues          = l_TypeConverter.GetStandardValues();
                l_StandardValuesExclusive = l_TypeConverter.GetStandardValuesExclusive();
            }
            object l_objUITypeEditor = System.ComponentModel.TypeDescriptor.GetEditor(p_Type, typeof(System.Drawing.Design.UITypeEditor));

            if (l_objUITypeEditor != null) // UITypeEditor founded
            {
                return(new DataModels.EditorUITypeEditor(p_Type, (System.Drawing.Design.UITypeEditor)l_objUITypeEditor));
            }
            else
            {
                if (l_StandardValues != null) // combo box
                {
                    return(new DataModels.EditorComboBox(p_Type, l_StandardValues, l_StandardValuesExclusive));
                }
                else if (l_TypeConverter != null && l_TypeConverter.CanConvertFrom(typeof(string)))//txtbox
                {
                    return(new DataModels.EditorTextBox(p_Type));
                }
                else // no editor found
                {
                    return(null);
                }
            }
        }
예제 #2
0
        public static bool _GetStandardValues_System_ComponentModel_TypeConverter_System_ComponentModel_ITypeDescriptorContext( )
        {
            //class object
            System.ComponentModel.TypeConverter _System_ComponentModel_TypeConverter = new System.ComponentModel.TypeConverter();

            //Parameters
            System.ComponentModel.ITypeDescriptorContext context = null;

            //ReturnType/Value
            System.ComponentModel.TypeConverter + StandardValuesCollection returnVal_Real        = null;
            System.ComponentModel.TypeConverter + StandardValuesCollection returnVal_Intercepted = null;

            //Exception
            System.Exception exception_Real        = null;
            System.Exception exception_Intercepted = null;

            InterceptionMaintenance.disableInterception( );

            try
            {
                returnVal_Real = _System_ComponentModel_TypeConverter.GetStandardValues(context);
            }

            catch (System.Exception e)
            {
                exception_Real = e;
            }


            InterceptionMaintenance.enableInterception( );

            try
            {
                returnVal_Intercepted = _System_ComponentModel_TypeConverter.GetStandardValues(context);
            }

            catch (System.Exception e)
            {
                exception_Intercepted = e;
            }


            return((exception_Real.Messsage == exception_Intercepted.Message) && (returnValue_Real == returnValue_Intercepted));
        }
        public static bool _GetStandardValues_System_ComponentModel_TypeConverter_System_ComponentModel_ITypeDescriptorContext( )
        {
            //class object
            System.ComponentModel.TypeConverter _System_ComponentModel_TypeConverter = new System.ComponentModel.TypeConverter();

               //Parameters
               System.ComponentModel.ITypeDescriptorContext context = null;

               //ReturnType/Value
               System.ComponentModel.TypeConverter+StandardValuesCollection returnVal_Real = null;
               System.ComponentModel.TypeConverter+StandardValuesCollection returnVal_Intercepted = null;

               //Exception
               System.Exception exception_Real = null;
               System.Exception exception_Intercepted = null;

               InterceptionMaintenance.disableInterception( );

               try
               {
              returnVal_Real = _System_ComponentModel_TypeConverter.GetStandardValues(context);
               }

               catch( System.Exception e )
               {
              exception_Real = e;
               }

               InterceptionMaintenance.enableInterception( );

               try
               {
              returnVal_Intercepted = _System_ComponentModel_TypeConverter.GetStandardValues(context);
               }

               catch( System.Exception e )
               {
              exception_Intercepted = e;
               }

               return( ( exception_Real.Messsage == exception_Intercepted.Message ) && ( returnValue_Real == returnValue_Intercepted ) );
        }
예제 #4
0
 public override StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context)
 {
     return(m_BaseTypeConverter.GetStandardValues(context));
 }