473,655 Members | 3,072 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Serializing some properties of a UserControl-derived class

I have a class derived from UserControl.
I need to serialize an object of this class, but only some properties
of it, as not all properties are serializable (some of the properties
coming from UserControl are like that). When serializing, how
could I ignore all the properties coming from the UserControl
class? I know there is XmlIgnoreAttrib ute, but how could I set it
to every property of UserControl, as it is not my class?

Thank you very much,
Chris

May 28 '07 #1
2 4396

Use IXmlSerializabl e interface to de-/serialize only some props.
[http://msdn2.microsoft.com/en-us/lib...alizable.aspx]

Regards,
Alex
http://devkids.blogspot.com
I have a class derived from UserControl.
I need to serialize an object of this class, but only some properties
of it, as not all properties are serializable (some of the properties
coming from UserControl are like that). When serializing, how
could I ignore all the properties coming from the UserControl
class? I know there is XmlIgnoreAttrib ute, but how could I set it
to every property of UserControl, as it is not my class?
Thank you very much,
Chris

May 28 '07 #2
Thank you, Alex! I've been trying to make it work, but there's a twist
in my situation which I haven't added yet:

My UserControl-derived class is called Basic, and I have some classes
derived from Basic. I never directly use Basic, only its child
classes. I need to serialize a List<Basic>, filled with objects of the
child classes, but I don't know in advance what kind of objects are
used. I found examples how this should be done (a simple example, no
IXmlSerializabl e interface involved). So when I serialize/deserialize,
I use the following constructor for XmlSerializer class:

public XmlSerializer(T ype type, Type[] extraTypes);
like this:
XmlSerializer ser = new XmlSerializer(t ypeof(List<Basi c>), new Type[]
{ typeof(BasicChi ld1), ..., typeof(BasicChi ldN) } );

In the simple example, I see that there is an xsi:type="Child Class"
attribute generated by the serializer. I guess serializer uses this
attribute to construct the object of the appropiate type when
deserializing.

Now the problem: How can I make this work with IXmlSerializabl e's
ReadXml?
I can generate the appropiate attribute in WriteXml with
XmlWriter.Write AttributeString , but ReadXml should do something with
this attribute, right?

Thank you again for anyone helping me!
Chris

Alex Meleta írta:
Use IXmlSerializabl e interface to de-/serialize only some props.
[http://msdn2.microsoft.com/en-us/lib...alizable.aspx]

Regards,
Alex
http://devkids.blogspot.com
I have a class derived from UserControl.
I need to serialize an object of this class, but only some properties
of it, as not all properties are serializable (some of the properties
coming from UserControl are like that). When serializing, how
could I ignore all the properties coming from the UserControl
class? I know there is XmlIgnoreAttrib ute, but how could I set it
to every property of UserControl, as it is not my class?
Thank you very much,
Chris
May 30 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
9374
by: james | last post by:
I cannot get my UserControl's browsable properties to show up in the designer properties panel. I have then public virtual bool TestProp { {get return testProp; } set { testProp = value; } } but it doesn't show up in the designer. By the way, this used to work in the 2002 version, now in 2003 I am getting all kinds of problems like this
0
1530
by: Peter Verburgh | last post by:
Hello, I'm using PropertyGrid control to show the properties of an control. There are standard properties for each usercontrol like "Cursor, Dock ,...ect" I don't want to show this properties in the Propertygrid control , but i want only show m custom made properties. How can i easy hide those properties ?
8
2258
by: David Lozzi | last post by:
Howdy, I have a user control that is a report to display data. On the page the control is inserted in, I have filter options to filter the report. When I try to do something like this, nothing happens. dim filt as string ... build filter string... UserControl.ReportFilter = filt
2
1674
by: Daniel Friend | last post by:
Hello, I have added a custom usercontrol programically and all works fine... I would like to change some custom properties that I have set in that usercontrol. Any help would be greatly appreciated!!!! Thanks,
0
1375
by: Daniel Friend | last post by:
Hello, I have added a custom usercontrol programically and all works fine... I would like to change some custom properties that I have set in that usercontrol. Any help would be greatly appreciated!!!! Here is a sample of What I am doing:
0
844
by: elziko | last post by:
I have a UserControl inside my project. When I click on the UserControl in the design view I get to also view all its properties in the property grid. I the change the AllowDrop property to True. However, when I then use this compiled UserControl in any other project AllowDrop defaults back to False. I assume this is by design but why? And is there anything I can do to change this behaviour?
3
1284
by: Jim Hubbard | last post by:
If I create a usercontrol that is a tab with a webbrowser control on it, by default the new control exposes no properties of the tab or webbrowser control. What is the easiest way to bubble the public properties, methods and functions up to the usercontrol interface?
0
813
by: Charlie | last post by:
For a Windows Form: A Label is added to a UserControl. A public property of type Label is added to the UserControl code to represent the Label. The property, LabelOne, provides a tree view in the Designer properties window for the UserControl. The Text property of LabelOne can be set via the properties window, but does not persist at runtime. How could I make such properties persist ?
5
3784
by: g6023 | last post by:
Hi All Newbie to C# I am afraid The array of panel dispays OK but I am having problems with accessing the controls within. My panels each have a number of label controls. How do I set, say, the Name.Text property in List<Panel> ListPanelArray
3
1649
by: segecko | last post by:
Hi I have a created a custom usercontrol which inherites an Excel like usercontrol. In this usercontrol I have a custom property called SpreadTemplate, which is an enum with (at the moment) two members called None and Pipeline. When I set this property at design time it sets up the activesheet with a number of columns, rows, headers etc. This is all fine and working as it is supposed to. The problem is that all this information gets
0
8380
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8296
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8710
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8497
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5627
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1928
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.