コード例 #1
0
ファイル: PropertySetting.cs プロジェクト: RichardHaggard/BDC
        public static RadProperty FindProperty(
            Type currentType,
            string propertyName,
            bool fallback)
        {
            if (string.IsNullOrEmpty(propertyName))
            {
                return((RadProperty)null);
            }
            string[] strArray = propertyName.Split('.');
            if (strArray.Length > 1)
            {
                propertyName = strArray[strArray.Length - 1];
            }
            RadProperty safe = RadProperty.FindSafe(currentType, propertyName);

            if (safe == null && fallback)
            {
                for (currentType = currentType.BaseType; (object)currentType != null && (object)currentType != (object)typeof(RadObject); currentType = currentType.BaseType)
                {
                    safe = RadProperty.FindSafe(currentType, propertyName);
                    if (safe == null && (currentType.Name == "LightVisualElement" || currentType.Name == "UIChartElement"))
                    {
                        safe = RadProperty.FindSafe(currentType, "Border" + propertyName);
                    }
                    if (safe != null)
                    {
                        break;
                    }
                }
            }
            return(safe);
        }
コード例 #2
0
        public static RadProperty Find(Type objectType, string propertyName)
        {
            RadProperty safe = RadProperty.FindSafe(objectType, propertyName);

            if (safe == null)
            {
                throw new RadPropertyNotFoundException(propertyName, objectType.FullName);
            }
            return(safe);
        }
コード例 #3
0
        public static RadProperty Find(string className, string propertyName)
        {
            RadProperty safe = RadProperty.FindSafe(className, propertyName);

            if (safe == null)
            {
                throw new RadPropertyNotFoundException(propertyName, className);
            }
            return(safe);
        }
コード例 #4
0
        private UITypeEditor GetActualEditor(ITypeDescriptorContext context)
        {
            if (context == null)
            {
                return(this.actualEditor);
            }
            XmlPropertySetting instance = (XmlPropertySetting)context.Instance;

            if (instance.Property == null)
            {
                this.actualEditor = (UITypeEditor)null;
                return((UITypeEditor)null);
            }
            string[] strArray = instance.Property.Split('.');
            if (strArray.Length > 1)
            {
                string      propertyName = strArray[strArray.Length - 1];
                string      className    = string.Join(".", strArray, 0, strArray.Length - 1);
                RadProperty safe         = RadProperty.FindSafe(className, propertyName);
                this.currProperty = safe;
                if (safe != null)
                {
                    TypeConverter converter = TypeDescriptor.GetConverter(safe.PropertyType);
                    this.actualPropertyType = safe.PropertyType;
                    if (converter == null || !converter.CanConvertFrom(typeof(string)) || !converter.CanConvertTo(typeof(string)))
                    {
                        if (!converter.CanConvertFrom(typeof(string)))
                        {
                            int num1 = (int)MessageBox.Show("Converter can't convert from string");
                        }
                        else if (!converter.CanConvertTo(typeof(string)))
                        {
                            int num2 = (int)MessageBox.Show("Converter can't convert to string");
                        }
                        else
                        {
                            int num3 = (int)MessageBox.Show("Converter for type not found");
                        }
                        this.actualEditor = (UITypeEditor)null;
                        return((UITypeEditor)null);
                    }
                    this.actualConverter = converter;
                    PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(safe.OwnerType).Find(safe.Name, false);
                    this.actualEditor = propertyDescriptor == null ? (UITypeEditor)TypeDescriptor.GetEditor(safe.PropertyType, typeof(UITypeEditor)) : (UITypeEditor)propertyDescriptor.GetEditor(typeof(UITypeEditor));
                    return(this.actualEditor);
                }
                int num = (int)MessageBox.Show("Can't find property " + instance.Property + ". Property " + propertyName + "not registered for RadObject" + className);
                this.actualEditor = (UITypeEditor)null;
                return((UITypeEditor)null);
            }
            int num4 = (int)MessageBox.Show("Invalid property name. Property consist of type FullName\".\"PropertyName.");

            this.actualEditor = (UITypeEditor)null;
            return((UITypeEditor)null);
        }
コード例 #5
0
 private TypeConverter GetUnderlayingConverter(ITypeDescriptorContext context)
 {
     if (this.underlayingConverter == null || context != this.currContext)
     {
         this.currContext = context;
         if (context == null)
         {
             return(this.underlayingConverter);
         }
         XmlPropertySetting instance = (XmlPropertySetting)context.Instance;
         if (string.IsNullOrEmpty(instance.Property))
         {
             this.underlayingConverter = (TypeConverter)null;
             return((TypeConverter)null);
         }
         string[] strArray = instance.Property.Split('.');
         if (strArray.Length <= 1)
         {
             throw new Exception("Invalid property name. Property consist of type FullName \".\" and property name.");
         }
         string      propertyName = strArray[strArray.Length - 1];
         string      className    = string.Join(".", strArray, 0, strArray.Length - 1);
         RadProperty safe         = RadProperty.FindSafe(className, propertyName);
         if (safe != null)
         {
             TypeConverter converter = TypeDescriptor.GetConverter(safe.PropertyType);
             if (converter == null || !converter.CanConvertFrom(typeof(string)) || !converter.CanConvertTo(typeof(string)))
             {
                 if (!converter.CanConvertFrom(typeof(string)))
                 {
                     int num1 = (int)MessageBox.Show("Converter can't convert from string");
                 }
                 else if (!converter.CanConvertTo(typeof(string)))
                 {
                     int num2 = (int)MessageBox.Show("Converter can't convert to string");
                 }
                 else
                 {
                     int num3 = (int)MessageBox.Show("Converter for type not found");
                 }
             }
             this.hasEditor            = (UITypeEditor)TypeDescriptor.GetEditor(safe.PropertyType, typeof(UITypeEditor)) != null;
             this.underlayingConverter = converter;
         }
         else
         {
             int num = (int)MessageBox.Show("Can't find property " + instance.Property + ". Property " + propertyName + " not registered for " + className);
             this.underlayingConverter = (TypeConverter)null;
             return((TypeConverter)null);
         }
     }
     return(this.underlayingConverter);
 }
コード例 #6
0
ファイル: RadTypeResolver.cs プロジェクト: RichardHaggard/BDC
        public RadProperty GetRegisteredRadProperty(Type radOjectType, string propertyName)
        {
            RadProperty radProperty = (RadProperty)null;
            Type        objectType  = radOjectType;

            for (Type type = typeof(object); (object)objectType != (object)type; objectType = objectType.BaseType)
            {
                radProperty = RadProperty.FindSafe(objectType, propertyName);
                if (radProperty != null)
                {
                    break;
                }
            }
            return(radProperty);
        }
コード例 #7
0
ファイル: RadTypeResolver.cs プロジェクト: configare/hispeed
        internal RadProperty GetRegisteredRadProperty(Type radOjectType, string propertyName)
        {
            RadProperty result     = null;
            Type        currType   = radOjectType;
            Type        objectType = typeof(object);

            while (currType != objectType)
            {
                result = RadProperty.FindSafe(currType, propertyName);
                if (result != null)
                {
                    break;
                }

                currType = currType.BaseType;
            }

            return(result);
        }
コード例 #8
0
        private static RadProperty FindProperty(
            System.Type currentType,
            string propertyName,
            bool fallback)
        {
            RadProperty safe = RadProperty.FindSafe(currentType, propertyName);

            if (safe == null && fallback)
            {
                for (currentType = currentType.BaseType; (object)currentType != null && (object)currentType != (object)XmlPropertySetting.RadObjectType; currentType = currentType.BaseType)
                {
                    safe = RadProperty.FindSafe(currentType, propertyName);
                    if (safe != null)
                    {
                        break;
                    }
                }
            }
            return(safe);
        }
コード例 #9
0
        private static RadProperty FindProperty(Type currentType, string propertyName, bool fallback)
        {
            RadProperty radProperty = RadProperty.FindSafe(currentType, propertyName);

            if (radProperty == null && fallback)
            {
                //Provide Fallback mechanism - e.g. TreeNodeUI.BackColor should fallback to VisualElement.BackColor
                currentType = currentType.BaseType;
                while (currentType != null && currentType != RadObjectType)
                {
                    radProperty = RadProperty.FindSafe(currentType, propertyName);
                    if (radProperty != null)
                    {
                        break;
                    }

                    currentType = currentType.BaseType;
                }
            }

            return(radProperty);
        }
コード例 #10
0
        private TypeConverter GetUnderlayingConverter(ITypeDescriptorContext context)
        {
            if (underlayingConverter == null || context != currContext)
            {
                currContext = context;
                if (context == null)
                {
                    return(underlayingConverter);
                }
                XmlPropertySetting setting = (XmlPropertySetting)context.Instance;
                //Find property
                //setting.Property
                //Find type converter
                //Convert value
                //Find corresponding UITypeEditor
                //Edit converted value

                if (string.IsNullOrEmpty(setting.Property))
                {
                    this.underlayingConverter = null;
                    return(null);
                }

                string[] propertyParts = setting.Property.Split('.');
                string   propertyName;
                string   className;
                if (propertyParts.Length > 1)
                {
                    propertyName = propertyParts[propertyParts.Length - 1];
                    className    = string.Join(".", propertyParts, 0, propertyParts.Length - 1);
                }
                else
                {
                    throw new Exception("Invalid property name. Property consist of type FullName \".\" and property name.");
                }

                RadProperty prop = RadProperty.FindSafe(className, propertyName);

                //this.actualProperty = prop;

                TypeConverter converter;

                if (prop != null)
                {
                    converter = TypeDescriptor.GetConverter(prop.PropertyType);
                }
                else
                {
                    MessageBox.Show("Can't find property " + setting.Property + ". Property " + propertyName + " not registered for " + className);
                    this.underlayingConverter = null;
                    return(null);
                }


                if (converter == null ||
                    !converter.CanConvertFrom(typeof(string)) ||
                    !converter.CanConvertTo(typeof(string)))
                {
                    if (!converter.CanConvertFrom(typeof(string)))
                    {
                        MessageBox.Show("Converter can't convert from string");
                    }
                    else
                    if (!converter.CanConvertTo(typeof(string)))
                    {
                        MessageBox.Show("Converter can't convert to string");
                    }
                    else
                    {
                        MessageBox.Show("Converter for type not found");
                    }
                }


                UITypeEditor editor = (UITypeEditor)TypeDescriptor.GetEditor(prop.PropertyType, typeof(UITypeEditor));
                hasEditor = editor != null;

                underlayingConverter = converter;
            }

            return(underlayingConverter);
        }
コード例 #11
0
        private UITypeEditor GetActualEditor(ITypeDescriptorContext context)
        {
            if (context == null)
            {
                return(actualEditor);
            }

            XmlPropertySetting setting = (XmlPropertySetting)context.Instance;

            //Find property
            //setting.Property
            //Find type converter
            //Convert value
            //Find corresponding UITypeEditor
            //Edit converted value

            if (setting.Property == null)
            {
                this.actualEditor = null;
                return(null);
            }

            string[] propertyParts = setting.Property.Split('.');
            string   propertyName;
            string   className;

            if (propertyParts.Length > 1)
            {
                propertyName = propertyParts[propertyParts.Length - 1];
                className    = string.Join(".", propertyParts, 0, propertyParts.Length - 1);
            }
            else
            {
                MessageBox.Show("Invalid property name. Property consist of type FullName\".\"PropertyName.");
                this.actualEditor = null;
                return(null);
            }

            RadProperty prop = RadProperty.FindSafe(className, propertyName);

            this.currProperty = prop;

            TypeConverter converter;

            if (prop != null)
            {
                converter = TypeDescriptor.GetConverter(prop.PropertyType);
            }
            else
            {
                MessageBox.Show("Can't find property " + setting.Property + ". Property " + propertyName + "not registered for RadObject" + className);
                this.actualEditor = null;
                return(null);
            }

            this.actualPropertyType = prop.PropertyType;

            if (converter == null ||
                !converter.CanConvertFrom(typeof(string)) ||
                !converter.CanConvertTo(typeof(string)))
            {
                if (!converter.CanConvertFrom(typeof(string)))
                {
                    MessageBox.Show("Converter can't convert from string");
                }
                else
                if (!converter.CanConvertTo(typeof(string)))
                {
                    MessageBox.Show("Converter can't convert to string");
                }
                else
                {
                    MessageBox.Show("Converter for type not found");
                }

                this.actualEditor = null;
                return(null);
            }

            this.actualConverter = converter;

            PropertyDescriptor actualProperty = TypeDescriptor.GetProperties(prop.OwnerType).Find(prop.Name, false);

            if (actualProperty != null)
            {
                this.actualEditor = (UITypeEditor)actualProperty.GetEditor(typeof(UITypeEditor));
            }
            else
            {
                this.actualEditor = (UITypeEditor)TypeDescriptor.GetEditor(prop.PropertyType, typeof(UITypeEditor));
            }


            return(actualEditor);
        }