Ejemplo n.º 1
0
        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            PropertyDescriptorCollection coll  = TypeDescriptor.GetProperties(this, attributes, true);
            List <PropertyDescriptor>    props = new List <PropertyDescriptor>();
            PropertyDescriptorStyles     setStyle;

            foreach (PropertyDescriptor pd in coll)
            {
                if (!pd.IsBrowsable)
                {
                    continue;
                }

                if (this.isNew)
                {
                    setStyle = PropertyDescriptorStyles.Add;
                }
                else
                {
                    switch (pd.Name)
                    {
                    case "Type":
                        setStyle = PropertyDescriptorStyles.AddReadOnly;
                        break;

                    case "IsUnique":
                    case "Name":
                        setStyle = (IsPrimary ? PropertyDescriptorStyles.AddReadOnly : PropertyDescriptorStyles.Add);
                        break;

                    case "FullText":
                        setStyle = (Spatial || String.Compare(table.Engine, "myisam", true) != 0 ? PropertyDescriptorStyles.AddReadOnly : PropertyDescriptorStyles.Skip);
                        break;

                    case "Spatial":
                        setStyle = (FullText || String.Compare(table.Engine, "myisam", true) != 0 ? PropertyDescriptorStyles.AddReadOnly : PropertyDescriptorStyles.Skip);
                        break;

                    default:
                        setStyle = PropertyDescriptorStyles.Add;
                        break;
                    }
                }

                switch (setStyle)
                {
                case PropertyDescriptorStyles.Add:
                    props.Add(pd);
                    break;

                case PropertyDescriptorStyles.AddReadOnly:
                    CustomPropertyDescriptor newPd = new CustomPropertyDescriptor(pd);
                    newPd.SetReadOnly(true);
                    props.Add(newPd);
                    break;
                    // when PropertyDescriptorStyles.Skip nothing is added to the props list.
                }
            }
            return(new PropertyDescriptorCollection(props.ToArray()));
        }
Ejemplo n.º 2
0
        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            PropertyDescriptorCollection coll =
                TypeDescriptor.GetProperties(this, attributes, true);

            List <PropertyDescriptor> props = new List <PropertyDescriptor>();

            foreach (PropertyDescriptor pd in coll)
            {
                if (!pd.IsBrowsable)
                {
                    continue;
                }

                if (pd.Name == "IsUnique" || pd.Name == "Name" || pd.Name == "Type")
                {
                    if (IsPrimary)
                    {
                        CustomPropertyDescriptor newPd = new CustomPropertyDescriptor(pd);
                        newPd.SetReadOnly(true);
                        props.Add(newPd);
                    }
                }
                else if (pd.Name == "FullText" && (Spatial ||
                                                   String.Compare(table.Engine, "myisam", true) != 0))
                {
                    CustomPropertyDescriptor newPd = new CustomPropertyDescriptor(pd);
                    newPd.SetReadOnly(true);
                    props.Add(newPd);
                }
                else if (pd.Name == "Spatial" && (FullText ||
                                                  String.Compare(table.Engine, "myisam", true) != 0))
                {
                    CustomPropertyDescriptor newPd = new CustomPropertyDescriptor(pd);
                    newPd.SetReadOnly(true);
                    props.Add(newPd);
                }
                else
                {
                    props.Add(pd);
                }
            }
            return(new PropertyDescriptorCollection(props.ToArray()));
        }
Ejemplo n.º 3
0
        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            PropertyDescriptorCollection coll =
                TypeDescriptor.GetProperties(this, attributes, true);

            List <PropertyDescriptor> props = new List <PropertyDescriptor>();

            foreach (PropertyDescriptor pd in coll)
            {
                if (!pd.IsBrowsable)
                {
                    continue;
                }

                if (pd.Name == "Precision" || pd.Name == "Scale")
                {
                    if (DataType != null &&
                        DataType.ToLowerInvariant() == "decimal")
                    {
                        props.Add(pd);
                    }
                }
                else if (pd.Name == "CharacterSet" || pd.Name == "Collation")
                {
                    CustomPropertyDescriptor newPd = new CustomPropertyDescriptor(pd);
                    newPd.SetReadOnly(DataType == null ||
                                      !Metadata.IsStringType(DataType));
                    props.Add(newPd);
                }
                else
                {
                    props.Add(pd);
                }
            }
            return(new PropertyDescriptorCollection(props.ToArray()));
        }
Ejemplo n.º 4
0
        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            PropertyDescriptorCollection coll = TypeDescriptor.GetProperties(this, attributes, true);

            List <PropertyDescriptor> props = new List <PropertyDescriptor>();

            string engine         = Engine.ToLowerInvariant();
            bool   engineIsMyIsam = engine == "myisam";

            foreach (PropertyDescriptor pd in coll)
            {
                if (!pd.IsBrowsable)
                {
                    continue;
                }

                if (pd.Name == "DataDirectory" || pd.Name == "IndexDirectory")
                {
                    CustomPropertyDescriptor newPd = new CustomPropertyDescriptor(pd);
                    newPd.SetReadOnly(!engineIsMyIsam);
                    props.Add(newPd);
                }
                else if ((pd.Name == "DelayKeyWrite" || pd.Name == "CheckSum" || pd.Name == "PackKeys") &&
                         !engineIsMyIsam)
                {
                }
                else if (pd.Name == "InsertMethod" && engine != "mrg_myisam")
                {
                }
                else
                {
                    props.Add(pd);
                }
            }
            return(new PropertyDescriptorCollection(props.ToArray()));
        }