Exemplo n.º 1
0
		protected override void DeserializeObject(
			object obj,
			IXtraPropertyCollection store,
			OptionsLayoutBase options)
		{
			if (options == null)
				options = OptionsLayoutBase.FullLayout;
			if (store == null)
				return;
			var coll = new XtraPropertyCollection();
			coll.AddRange(store);
			var helper = new DeserializeHelper(obj, false);
			helper.DeserializeObject(obj, coll, options);
		}
        protected override void DeserializeObject(
            object obj,
            IXtraPropertyCollection store,
            OptionsLayoutBase options)
        {
            if (options == null)
            {
                options = OptionsLayoutBase.FullLayout;
            }
            if (store == null)
            {
                return;
            }
            var coll = new XtraPropertyCollection();

            coll.AddRange(store);
            var helper = new DeserializeHelper(obj, false);

            helper.DeserializeObject(obj, coll, options);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Nach dem internen Wiederherstellen des Layouts die benutzerdefinierte Layoutanpassung nochmal drüberlaufen lassen
 /// </summary>
 protected override void RestoreLayoutCore(XtraSerializer serializer, object path, OptionsLayoutBase options)
 {
     base.RestoreLayoutCore(serializer, path, options);
     this.InitializeLayout();
 }
Exemplo n.º 4
0
        protected override bool AllowProperty(SerializeHelperBase helper, object obj, PropertyDescriptor prop, OptionsLayoutBase options, bool isSerializing)
        {
            MyDeserializeHelper myHelper = helper as MyDeserializeHelper;

            if (myHelper == null || !(myHelper.RootObject is MyGridView))
            {
                return(base.AllowProperty(helper, obj, prop, options, isSerializing));
            }

            bool allow = base.AllowProperty(helper, obj, prop, options, isSerializing);

            if (customProperties == null || Array.IndexOf(customProperties, prop.Name) == -1)
            {
                return(allow);
            }

            PropertyInfo[] propInfos = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
            PropertyInfo   property  = Array.Find(propInfos, info => info.Name == prop.Name);

            return(property != null);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        protected override void RestoreLayoutCore(XtraSerializer serializer, object path, OptionsLayoutBase options)
        {
            if (serializer is XmlXtraSerializer)
            {
                serializer = new MyXmlXtraSerializer();
            }

            base.RestoreLayoutCore(serializer, path, options);
        }