|
Hi,
What is the easiest way to serialize an array of objects like the one in the following code example?
public void Test()
{
List<object> arObject = new List<object>();
arObject.Add(Color.Red);
arObject.Add(Color.Green);
arObject.Add(new string("Hello World!"));
arObject.Add(new MyObject());
}</object></object>
In my program the object array represents an array of property values which could be of any time. Custom objects implement the IXmlSerializable interface, and simple types like strings appear to work fine. So far I have found problems with the low-level types like System.Drawing.Color and the like. Is there a generic way of serializing objects which do not implement the IXmlSerializable interface?
At the moment I am not using the XmlSerializer class because I need extra control over how objects are serialized. So instead I am just using the XmlWriter class.
Any help would be greatly appreciated!
Lea Hayes
|
|
|
|
|
Hi!
Does it have to be XML? Otherwise the BinaryFormatter is a very easily to use alternative.
Or use the SoapFormatter (although I think it has a problem with generics IIRC).
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hi,
Unfortunately the BinaryFormatter will not do the trick because it is not easily edited by the user. I keep seeing SoapFormatter pop up here and there, I've not actually use this before so I think it is time to dig into some MSDN documentation and the brilliant selection of articles on CodeProject!
Thanks for your advice!
Lea Hayes
|
|
|
|
|
Hi!
Yes, the binary files created by BinaryFormatter cannot be edited easily by the user, but it's also a way to protect the integrity of your serialized data.
When users can play around, they will and then you'll have to deal with invalid XML files...
So depending on what you want the user to edit, creating a separate function to modify the serialized data could be a safer option.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hi
Can anyone help for me the following issue?
I have a windows form with Gridview control and other server controls.while form load i'm filling the Gridview control. but i dont want the Rowchanged event to be fired.
what i need to do to solve the above issue?
Thanks in advance
regards
sri
|
|
|
|
|
how could i affect a cell value based on other one in a datagrid?
I have a simple textbox in which the user can insert value, so i need when i leave the textbox run a specific function
i already created this code :
GridColumn = new DataGridTextBoxColumn();
GridColumn.MappingName="Row_Percentage";
GridColumn.Width=100;
GridColumn.HeaderText="Row_Percentage";
GridColumn.TextBox.Leave +=new EventHandler(GridColumn_Leave);
GridTableStyle.GridColumnStyles.Add(GridColumn);
the problem is i couldn't take the value of the current cell untill i leave the column not the "cell"!!
please if someone could help
|
|
|
|
|
Hi,
I have a PC with Multi IP address.
I would like to navigate with the WebBrowser to a URL but with the IP of my choice.
I tried a few things but nothing worked.
Any Ideas?
Thanks in advance.
-fEINT
|
|
|
|
|
browser.Navigate(theIpAddress) ?
|
|
|
|
|
The WebBrowser control in .NET 2.0 onward will use the same IP address as a Microsoft Internet Explorer window. The control it self doesn't provide for switching between IP's on the computer.
|
|
|
|
|
Any workaround I can use?
Any thoughts?
-fEINT
|
|
|
|
|
|
Hi,
I have a problem to make a CAB file for my project exe (create in Visual studio 2005, C#) into PocketPc 2003. When i execute a cab on a PDa with pocketpc 2003 I retrive an error: "It's not a valid CAB file for windows CE".
The CAB work perfectly on PDA with windows mobile 5.0.
Why? I can create a CAB file compatible with pocketpc2003?
Thanks a lot.
Alex
|
|
|
|
|
Please do not post in more than one forum the same message.
|
|
|
|
|
Can any one Help,
I have Create the weekday table in sql server 2005.
Total three field is there in weekday table.
1)DayOfTheWeek
2)OfficeOpenHours
3)OfficeCloseHours
I have enter the value Sunday to Friday in DayOfTheWeek field.
I have set the primarykey in DayOfTheWeek field.
When i set the primary key its automatically set the value in ascending order format.
Before Set the Primary key in DayOfTheWeek field value
*******************************************************
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
After Set the Primary key in DayOfTheWeek field value
*****************************************************
Friday
Monday
Saturday
Sunday
Thursday
Tuesday
Wednesday
C#
***
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con=new SqlConnection("connection string");
con.Open()
SqlCommand cmd1 = new SqlCommand("select * from Office_Hours", con);
SqlDataAdapter da=new SqlDataAdapter(cmd1);
DataSet ds=new DataSet()
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
How to display Sunday to Saturday format value from database using Gridview
|
|
|
|
|
bruze wrote: Total three field is there in weekday table.
1)DayOfTheWeek
2)OfficeOpenHours
3)OfficeCloseHours
You might have to add a new column (like sortorder) and display according to it.
*jaans
|
|
|
|
|
i wanna know that Application.Run only takes only from objects as a parameter like
Application.Run (new MYfrm1);
OR it can also take parameter other than windows form like Class Objects?
|
|
|
|
|
i wanna know that Application.Run only takes only from objects as a parameter like
Application.Run (new MYfrm1);
OR it can also take parameter other than windows form like Class Objects?
|
|
|
|
|
Why don't you have a look at the documentation[^]?
BTW, don't post your questions twice.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
saneng wrote: OR it can also take parameter other than windows form like Class Objects?
If you check you'll find that Form is a class. And instances of Form are objects.
|
|
|
|
|
I want to resign the assembly with a strong key but I get an error that the post build command exited with code 3?! Any idea what this means?
If I manually resign the assembly the operation is successful.
|
|
|
|
|
I have a routine that takes identifies a specific location on each line of HEX and highlights it. It works fine until it gets to a line that the sniffer did not capture any HEX. From that point on it is highlighting random spots in the file. How should I handle identifing the error, and then continue past it without causing it to randomize the locations?
Here is a sample of what I would normally see in the HEX (all one line);
2008/04/24 19:16:50 [128009]ARES_EINDICATION 010.050.082.101 103.2.01 (19d1) RX 68 bytes 19 D1 26 02 34 E8 AA 20 76 97 51 28 50 76 38 64 49 00 58 02 02 C7 88 01 C7 88 AA 50 76 38 64 49 20 76 97 51 28 D8 07 04 18 13 10 2F 00 00 10 0A 06 0A 06 06 0A 06 0A 06 06 06 06 06 06 06 06 73 74 69 9C F6
Here is a sample of the line with the error in it (all one line);
2008/04/24 19:16:51 [128009]ARES_EINDICATION 010.050.082.104 107.1.01 (1ac1) RX 68 bytes
This is the snippit of the code to find the sequence numbers;
private void findSequenceNumbers()
{
toolStripStatusLabel.Enabled = true;
toolStripStatusLabel.Visible = true;
//Find the ARES and ATCS L3 Sequence Numbers and change to Blue/BOLD color
int lineNum = 0;
bool startingNewLine = true;
FontStyle style = FontStyle.Bold;
string[] lines = rtbDoc.Lines;
string text = rtbDoc.Text;
rtbDoc.Enabled = false;
for (int i = 0; i < text.Length; i++)
{
if (startingNewLine)
{
//Find and highlight ARES EINDICATION Sequence Numbers
if (lines[lineNum].Contains("]ARES_EINDICATION"))
{
i += 154;
rtbDoc.Select(i, 2);
rtbDoc.SelectionFont = new Font(rtbDoc.SelectionFont, rtbDoc.SelectionFont.Style ^ style);
rtbDoc.SelectionColor = Color.Blue;
}
//Find and highlight ARES INDICATION Sequence Number
else if (lines[lineNum].Contains("]ARES_INDICATION"))
{
i += 154;
rtbDoc.Select(i, 2);
rtbDoc.SelectionFont = new Font(rtbDoc.SelectionFont, rtbDoc.SelectionFont.Style ^ style);
rtbDoc.SelectionColor = Color.Blue;
}
//Find and highlight CODELINE INDICATION MESSAGE L3 Sequence Number
else if (lines[lineNum].Contains("]CODELINE_INDICATION_MSG") && lines[lineNum].Contains("RX"))
{
i += 112;
rtbDoc.Select(i, 2);
rtbDoc.SelectionFont = new Font(rtbDoc.SelectionFont, rtbDoc.SelectionFont.Style ^ style);
rtbDoc.SelectionColor = Color.Blue;
}
//Find and highlight CODELINE CONTROL MESSAGE L3 Sequence Number
else if (lines[lineNum].Contains("]CODELINE_CONTROL_MSG"))
{
i += 160;
rtbDoc.Select(i, 2);
rtbDoc.SelectionFont = new Font(rtbDoc.SelectionFont, rtbDoc.SelectionFont.Style ^ style);
rtbDoc.SelectionColor = Color.Blue;
}
//Find and highlight RF L3 ACK L3 Sequence Numbers
else if (lines[lineNum].Contains("]RF_L3_ACK"))
{
i += 109;
rtbDoc.Select(i, 2);
rtbDoc.SelectionFont = new Font(rtbDoc.SelectionFont, rtbDoc.SelectionFont.Style ^ style);
rtbDoc.SelectionColor = Color.Blue;
}
//Find and highlight INT SERV SIG L3 Sequence Numbers
else if (lines[lineNum].Contains("]INT_SERV_SIG"))
{
i += 169;
rtbDoc.Select(i, 2);
rtbDoc.SelectionFont = new Font(rtbDoc.SelectionFont, rtbDoc.SelectionFont.Style ^ style);
rtbDoc.SelectionColor = Color.Yellow;
}
//Find and highlight INT L3 ATCS L3 Sequence Numbers
else if (lines[lineNum].Contains("]INT_L3_ATCS"))
{
i += 112;
rtbDoc.Select(i, 2);
rtbDoc.SelectionFont = new Font(rtbDoc.SelectionFont, rtbDoc.SelectionFont.Style ^ style);
rtbDoc.SelectionColor = Color.Blue;
}
else
{
i += lines[lineNum].Length - 1;
}
startingNewLine = false;
Application.DoEvents();
}
if (text[i] == '\n')
{
startingNewLine = true;
lineNum++;
}
}
toolStripStatusLabel.Visible = false;
toolStripStatusLabel.Enabled = false;
rtbDoc.Select(0, 0);
rtbDoc.ScrollToCaret();
rtbDoc.Enabled = true;
rtbDoc.Focus();
}
Thanks,
Brian
|
|
|
|
|
That's because it looks like you're not checking to make sure that the transmission is correct. If you are counting on fixed length transmissions, make sure that you actually have the right amount of bytes. I would tackle this with regular expressions. Are you running this when receiving a message?
Scott P
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
Good suggestion. I need to learn Regex regardless. No I am not running this real time. It is a static log that is opened after the fact. First I do a string collection and create a single line of the HEX, and put the RX/TX items at a specific location to facilitate finding the correct item in the HEX to highlight and simplfy pattern searching. Once it is in a single line format, then I look for the location to highlight, then color accordingly.
Here is the raw;
Correct format;
2008/04/24 19:16:50 [128009]ARES_EINDICATION 010.050.082.101 103.2.01 (19d1) RX 68 bytes
2008/04/24 19:16:50 [128009] 19 D1 26 02 34 E8 AA 20 76 97 51 28 50 76 38 64
2008/04/24 19:16:50 [128009] 49 00 58 02 02 C7 88 01 C7 88 AA 50 76 38 64 49
2008/04/24 19:16:50 [128009] 20 76 97 51 28 D8 07 04 18 13 10 2F 00 00 10 0A
2008/04/24 19:16:50 [128009] 06 0A 06 06 0A 06 0A 06 06 06 06 06 06 06 06 73
2008/04/24 19:16:50 [128009] 74 69 9C F6
Incorrect/missing format;
2008/04/24 19:16:51 [128009]ARES_EINDICATION 010.050.082.104 107.1.01 (1ac1) RX 68 bytes
Brian
|
|
|
|
|
So you have a file with line feeds that you make individual strings for, if I'm understanding you correctly. So all the items in the above example with the same timestamp are considered in the same transmission.
Assuming the headers are never broken (not so good) you could use the RX size to count the bytes to make sure of the correct sizing.
If you're considering everything between the header text (ARES_EIN---) to be one transmission, you could load a either a generic List<string> or array String[] to hold transmissions, then colorize by line without using the index in the long string in your output window.
Scott P
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
You are correct in your understanding. Same timestamp and same stationid e.g. [129008]. The information up to the end of the [] info is the same length. From that point on the length of the message is dictated by the type of message.
Thanks for the suggestions.
Brian
|
|
|
|