示例#1
0
        protected IXtraPropertyCollection GetFilterProps(ColumnView view, string[] propertyNames)
        {
            var store = new XtraPropertyInfoCollection();

            if (propertyNames.Length > 0)
            {
                var propList = new ArrayList();
                PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(view);
                foreach (string propertyName in propertyNames)
                {
                    propList.Add(properties.Find(propertyName, false));
                }

                var        helper = new SerializeHelper();
                MethodInfo mi     = typeof(SerializeHelper).GetMethod("SerializeProperty",
                                                                      BindingFlags.NonPublic | BindingFlags.Instance);
                (view as IXtraSerializable).OnStartSerializing();
                foreach (PropertyDescriptor prop in propList)
                {
                    mi.Invoke(helper, new object[] { store, view, prop, XtraSerializationFlags.None, null });
                }
                (view as IXtraSerializable).OnEndSerializing();
            }
            return(store);
        }
示例#2
0
        private XtraPropertyInfoCollection GetFilterProps(ColumnView view)
        {
            var store    = new XtraPropertyInfoCollection();
            var propList = new ArrayList();
            PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(view);

            propList.Add(properties.Find("Columns", false));
            propList.Add(properties.Find("OptionsView", false));
            propList.Add(properties.Find("ActiveFilterEnabled", false));
            propList.Add(properties.Find("ActiveFilterString", false));
            propList.Add(properties.Find("MRUFilters", false));
            propList.Add(properties.Find("ActiveFilter", false));

            MethodInfo mi = typeof(SerializeHelper).GetMethod("SerializeProperty",
                                                              BindingFlags.NonPublic | BindingFlags.Instance);
            MethodInfo miGetXtraSerializableProperty = typeof(SerializeHelper).GetMethod(
                "GetXtraSerializableProperty", BindingFlags.NonPublic |
                BindingFlags.Instance);
            var helper = new SerializeHelper(view);

            (view as IXtraSerializable).OnStartSerializing();
            foreach (PropertyDescriptor prop in propList)
            {
                var newXtraSerializableProperty =
                    miGetXtraSerializableProperty.Invoke(helper, new object[] { view, prop })
                    as XtraSerializableProperty;
                var p = new SerializablePropertyDescriptorPair(prop, newXtraSerializableProperty);
                mi.Invoke(helper, new object[] { store, view, p, XtraSerializationFlags.None, null });
            }
            (view as IXtraSerializable).OnEndSerializing();
            return(store);
        }
示例#3
0
        private XtraPropertyInfoCollection GetFilterProps(ColumnView view)
        {
            var store = new XtraPropertyInfoCollection();
            var propList = new ArrayList();
            PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(view);
            propList.Add(properties.Find("Columns", false));
            propList.Add(properties.Find("OptionsView", false));
            propList.Add(properties.Find("ActiveFilterEnabled", false));
            propList.Add(properties.Find("ActiveFilterString", false));
            propList.Add(properties.Find("MRUFilters", false));
            propList.Add(properties.Find("ActiveFilter", false));

            MethodInfo mi = typeof (SerializeHelper).GetMethod("SerializeProperty",
                                                               BindingFlags.NonPublic | BindingFlags.Instance);
            MethodInfo miGetXtraSerializableProperty = typeof (SerializeHelper).GetMethod(
                "GetXtraSerializableProperty", BindingFlags.NonPublic |
                                               BindingFlags.Instance);
            var helper = new SerializeHelper(view);
            (view as IXtraSerializable).OnStartSerializing();
            foreach (PropertyDescriptor prop in propList)
            {
                var newXtraSerializableProperty =
                    miGetXtraSerializableProperty.Invoke(helper, new object[] {view, prop})
                    as XtraSerializableProperty;
                var p = new SerializablePropertyDescriptorPair(prop, newXtraSerializableProperty);
                mi.Invoke(helper, new object[] {store, view, p, XtraSerializationFlags.None, null});
            }
            (view as IXtraSerializable).OnEndSerializing();
            return store;
        }
示例#4
0
        protected override IXtraPropertyCollection SerializeObjectCore(object obj, XtraSerializationFlags parentFlags, OptionsLayoutBase options)
        {
            if (rootObject == null || !(rootObject is MyGridView))
            {
                return(base.SerializeObjectCore(obj, parentFlags, options));
            }

            XtraPropertyInfoCollection properties = base.SerializeObjectCore(obj, parentFlags, options) as XtraPropertyInfoCollection;

            for (int i = properties.Count - 1; i >= 0; i--)
            {
                AllowSerializePropertyEventArgs allowArgs = new AllowSerializePropertyEventArgs(obj, properties[i].Name, properties[i].PropertyType, properties[i].Value);
                ((MyGridView)rootObject).RaiseAllowSerialzeProperty(allowArgs);
                if (!allowArgs.SerializeProperty)
                {
                    properties.RemoveAt(i);
                }
            }

            SerializeCustomPropertiesEventArgs customArgs = new SerializeCustomPropertiesEventArgs(obj);

            ((MyGridView)rootObject).RaiseSerializeCustomProperties(customArgs);
            if (customArgs.PropertyNames == null || customArgs.PropertyNames.Length == 0)
            {
                return(properties);
            }

            for (int i = 0; i < customArgs.PropertyNames.Length; i++)
            {
                PropertyInfo[] propInfos     = obj.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
                PropertyInfo   property      = Array.Find(propInfos, info => info.Name == customArgs.PropertyNames[i]);
                object         propertyValue = null;
                if (property == null)
                {
                    CustomPropertyValueEventArgs args = new CustomPropertyValueEventArgs(obj, customArgs.PropertyNames[i]);
                    ((MyGridView)rootObject).RaiseSetCustomPropertyValue(args);
                    if (args.PropertyValue == null)
                    {
                        continue;
                    }

                    propertyValue = args.PropertyValue;
                }
                else
                {
                    propertyValue = property.GetValue(obj, null);
                    if (propertyValue == null)
                    {
                        continue;
                    }
                }

                properties.Add(new XtraPropertyInfo(customArgs.PropertyNames[i], propertyValue.GetType(), propertyValue));
            }

            return(properties);
        }
示例#5
0
        protected override void SerializeProperty(XtraPropertyInfoCollection store, object obj, SerializablePropertyDescriptorPair pair, XtraSerializationFlags parentFlags, DevExpress.Utils.OptionsLayoutBase options)
        {
            PropertyDescriptor       prop = pair.Property;
            XtraSerializableProperty attr = pair.Attribute;

            if (attr == null && prop.IsBrowsable && prop.ShouldSerializeValue(obj))
            {
                if (prop.PropertyType != typeof(string) && prop.PropertyType.IsClass)
                {
                    pair = new SerializablePropertyDescriptorPair(prop, new XtraSerializableProperty(XtraSerializationVisibility.Content));
                }
                else
                {
                    pair = new SerializablePropertyDescriptorPair(prop, new XtraSerializableProperty());
                }
            }
            base.SerializeProperty(store, obj, pair, parentFlags, options);
        }
示例#6
0
        protected IXtraPropertyCollection GetFilterProps(ColumnView view, string[] propertyNames)
        {
            var store = new XtraPropertyInfoCollection();
            if (propertyNames.Length > 0)
            {
                var propList = new ArrayList();
                PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(view);
                foreach (string propertyName in propertyNames)
                    propList.Add(properties.Find(propertyName, false));

                var helper = new SerializeHelper();
                MethodInfo mi = typeof (SerializeHelper).GetMethod("SerializeProperty",
                                                                   BindingFlags.NonPublic | BindingFlags.Instance);
                (view as IXtraSerializable).OnStartSerializing();
                foreach (PropertyDescriptor prop in propList)
                {
                    mi.Invoke(helper, new object[] {store, view, prop, XtraSerializationFlags.None, null});
                }
                (view as IXtraSerializable).OnEndSerializing();
            }
            return store;
        }