|
leppie wrote:
Sounds like those files ASP.NET makes.
The XML serializer works by creating an Assembly at runtime that handles the serialization of the types to/from XML. Because it generates an Assembly, you wind up with the weird naming scheme.
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
|
I need to stop/preview the messages that child controls generate. Does anybody know if this can be achieved through subclassing?
For example, I have a textbox on a form, but I don't want the user to be able to set focus to it (So they can't edit and the caret doesn't appear). I want to absorb the msgs if possible or stop controls reacting to them.
Is this possible? or am I
|
|
|
|
|
OOOooh that horrid VB word again
Anyways the answer is yes. Just override the PreProcessMessage() in a derived (subclassed in VB) control. EG:
public class MyTextBox : TextBox {
public override bool PreProcessMessage(ref Message msg)
{
}
}
From MSDN:
All messages are sent to the WndProc method after getting filtered through the PreProcessMessage method.
The WndProc method corresponds to exactly to the Windows WindowProc function. For more information about processing Windows messages, see the WindowProc function documentation in the Windows Platform SDK reference located in the MSDN Library.
Notes to Inheritors: Inheriting controls should call the base class's WndProc method to process any messages that they don't handle.
Cheers
WebBoxes - Yet another collapsable control, but it relies on a "graphics server" for dynamic pretty rounded corners, cool arrows and unlimited font support.
|
|
|
|
|
Why is everyone taking the mick out of VB! I have 10 years experience of 'Application' development in VB. I'd love to move over to c# but unless I've got someone to hold my hand it's never gonna happen and I can't afford classes
I'm perfectly prepared to try and code under c# in a project with help, but there will be a lot of silly questions and I need to get my work done
|
|
|
|
|
LeeDaviesVBSource wrote:
lot of silly questions and I need to get my work done
Ask away! We may not always know what's going on...but somebody will (read: James T. Johnson).
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
Microsoft has reinvented the wheel, this time they made it round.
-Peterchen on VS.NET
|
|
|
|
|
I have this code snipet in my c# classs that generates a string containg xml data.
//build xml data
StringWriter xmlStringWriter = null;
XmlTextWriter xmlWriter = null;
string xmlString = "";
StringBuilder xmlStringBuilder = new StringBuilder();
try
{
xmlStringWriter = new StringWriter(xmlStringBuilder);
xmlWriter = new XmlTextWriter((xmlStringWriter);
xmlWriter.Formatting = Formatting.Indented;
xmlWriter.WriteStartDocument(); //start document
//populate xml
However, the generated xml string contains the header as:
Does anybody know of a way to use enconding "utf-8" when building an xmldoc inside a string?
|
|
|
|
|
|
Thanks leppie.
I tried this solution. I am however getting the error "Property or indexer 'System.IO.TextWriter.Encoding' cannot be assigned to -- it is read only".
Regards,
Andy
|
|
|
|
|
|
|
Hi leppie.
Unfortunately, this did not work either. I got two errors this time:
1. No overload for method 'UTF8StringWriter' takes '1' arguments
2. Property or indexer 'System.IO.TextWriter.Encoding' cannot be assigned to -- it is read only.
Thanks,
Andy
|
|
|
|
|
First of all, there is nothing wrong in getting an UTF-16 encoding (aka Unicode) since you are explicitely outputting a string content whose encoding is, by design, stored as Unicode (all string content in .NET is stored as unicode, like Java by the way).
Next to that, you have a System.Xml.TextWriter(string filename, Encoding enc) constructor ready to help you. Why don't you use it ? UTF-8 is the default encoding if you don't provide one. Then simply use your string content through WriteRaw(string) calls.
Just in case you don't want to tweak your current code, you can achieve what you need (again, that's bad use of the classes) by deriving the Xml.XmlTextWriter class and provide this constructor :
public XmlTextWriter_(TextWriter w, Encoding enc) {
this = new XmlTextWriter_();
this.textWriter = w;
this.encoding = enc;
this.xmlEncoder = new XmlTextEncoder(w, this.encoding);
this.xmlEncoder.QuoteChar = this.quoteChar;
}
PS : train[^] yourself with these free training courses.
|
|
|
|
|
|
Don't know if you are serious, or if you are playing a practical joke on this (on behalf on a semi-drunken state of mind. huh! )
That XmlTextWriter_ class is the derived class. To make it explicit :
public class XmlTextWriter_ : System.Xml.XmlTextWriter
{
...
}
Thus the fields I refer to, and tweak a little bit, are obviously those from the base class. No rocket science here.
|
|
|
|
|
|
You make a point here.
The entire XmlTextWriter class implementation must be rewritten.
Instead, as I pointed first, a better solution is to encode the string itself (whether it's hold by StringWriter, StringBuilder, or even String doesn't matter much) thanks to the Encoding derived classes (System.Text.UTF8Encoding, ...).
|
|
|
|
|
Hi,
I'm just wondering if there is a simple and straightforward way to serialize a class into an XML formatted file. Could somebody pls. point me into the right direction?
Any help is highly appreceated.
Matthias
In theory, there is no difference between theory and practice. In practice, however, there is.
(unknown author)
|
|
|
|
|
public class Class1
{
public int number;
public string name;
[STAThread]
static void Main(string[] args)
{
Class1 c = new Class1();
c.name = "Hello";
c.number = 1;
XmlSerializer xser = new XmlSerializer(c.GetType());
FileStream fs = File.Open("Class.xml", FileMode.OpenOrCreate);
xser.Serialize(fs, c);
fs.Close();
}
}
Make sure class is public and the properties you want is public and the class must have a default constructor.
And the output:
<?xml version="1.0"?>
<Class1 xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<number>1</number>
<name>Hello</name>
</Class1>
CHeers
WebBoxes - Yet another collapsable control, but it relies on a "graphics server" for dynamic pretty rounded corners, cool arrows and unlimited font support.
|
|
|
|
|
Thanks leppie!
Matthias
In theory, there is no difference between theory and practice. In practice, however, there is.
(unknown author)
|
|
|
|
|
Does anybody have any advice on how to 'Step-up' my programming skills.
I have been developing apps for years but would like to get a little more serious about my development.
How do you gurus go about delving into the background of controls and functions? I am mainly used to coding my own stuff from scratch, but then I see a 'system' way of doing it in about 3 lines of code.
Any ideas on how to start delving into the depths of development?
|
|
|
|
|
LeeDaviesVBSource wrote:
Does anybody have any advice on how to 'Step-up' my programming skills.
static void Main()
{
StringBuilder yourName = "LeeDaviesVBSource";
yourName.Remove("VB");
return;
}
Seriously though, if you can, I'd go out and buy Inside C# (Tom Archer), Applied .NET Framework Programming (Jeff Richter), Inside IL (Serge Lidin), and Programming Windows with C#(Charles Petzold). They're all from MSPress. Another book to check out would be Essential .NET (Don Box) from Addison Wesley. These are some great books. Otherwise, just experiment. Find something obscure that you want to look at and go for it.
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
Microsoft has reinvented the wheel, this time they made it round.
-Peterchen on VS.NET
|
|
|
|
|
What's the easiest way in C# to enumerate a systems
DSN settings ?
Thanks !!!!
|
|
|
|
|
hi,
beside a listbox,I put two buttons, one with up arrow icon, and one with down arrow icon.
I wish the selected item can be move up or down by pressing one of two buttons, for example,
there are 4 items in listbox, item1,item2,item3,item4, after selected item2, then press the up arrow button a time, the order become item2,item1,item3,item4, and if press the down arrow button three times,the order is
item1,item3,item4,item2.
and how can I do that?
thanks for any idea.
|
|
|
|
|