|
Hi,
I'm having troubles with XML deserialization in C#. Here is my class:
[Serializable]
public class A : IDeserializationCallback
{
public A()
{
m_MyString1 = "Test";
m_MyString2 = "";
}
public string MyString1
{
get { return m_MyString1; }
set { m_MyString1 = value; }
}
public string MyString2
{
get { return m_MyString2; }
set { m_MyString2 = value; }
}
void IDeserializationCallback.OnDeserialization(Object sender)
{
m_MyString2 = m_MyString1 + m_MyString1;
}
private string m_MyString1;
private string m_MyString2;
}
m_MyString2 is always "" in my case. Do I have to do anything else than implementing the interface to ensure that the OnDeserialization() method gets called?
Thanks in advance,
Rainer
|
|
|
|
|
Hey, I'm just about to go into my final year of school.
I have to do a programming project and I have decided to start early because what I have chosen to do will require a lot of learning on my part and a lot of work.
The project I have decided to do is an Internet Radio. I am currently building the server which has to stream the audio to the listeners as well as be semi-controlled by DJ's that will have a seperate application (developed by my partner). The client has to be developed in Delphi as thats the language that is taught at our school.
I am writing my server in C# because I think it's much better and would like to learn more.
I have run into some problems....
The way I have it now, I have a mediaplayer object that plays the music and an WMEncoder object that broadcasts it.
Problem 1:
Where the encoder gets its source: SrcAud.SetInput("Default_Audio_Device", "Device", "RadioStream");
This makes it capture the audio from the recording channel of my sound card (which by default is microphone), I have to change the channel to "What you hear" for the music to get broadcasted. This causes problems as you can imagine because any sound that is played on my computer also gets broadcasted with it.
Problem2:
The client (in Delphi) needs to send the server a stream of the DJ's voice that needs to be mixed into the broadcasted stream.
I can get Delhpi to record audio to a file, but I have no clue as to how I'm going to get the audio streamed and mixed into the server's broadcast.
If anyone has any suggestions, it would be GREATLY appreciated!
Thanks in advance.
df
|
|
|
|
|
Can't help you. But I'm curious...What school gives project like these?
What are you?
|
|
|
|
|
Well, I wasn't GIVEN the project. I'm in South Africa. Im not sure what type of Programming you guys do in school, but I sure was getting bored with Delphi and the easy stuff.
I wanted something challenging. I chose the project myself. I want to learn C# before I get to university.
What am I? A martian invader from the planet Grazaplm in the universe Gepu.
df
|
|
|
|
|
makemoneyfast wrote:
I wanted something challenging. I chose the project myself. I want to learn C# before I get to university.
Learning C#/Java before going to university is indeed quite useful, but you chose a very ambitious project here. Most of our projects at university are way easier than your high school project
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I am ambitious. I know I've taken on a lot, my implementation most certainly wont be the most efficent and best way to do it, but I'm learning a great deal. I've already got my program to broadcast the music and a soap interface invokable by the DJ Client application to change the song etc. There's just a couple of things I'm having a problem with as outlined in my original post.
df
|
|
|
|
|
Hi,
I and nobody I know ever did any programming in school..
Regards,
Cormac
|
|
|
|
|
Two choices with the DJ voice. 1 you can merge it into the stream which is probably a little bit harder (and I have no idea other than saying look at your sound card api doc), the other option is to publish two streams. One for music, on for DJ. Both of which can be played at the same time.
Personally, if I was in Highschool, I would have picked an easier assignment(Actually, I did. I wrote a 2D space shooter in VB4). But since you didn't a good place to look would be the open source community, and source forge. They may not have code samples in your specific language but I think these tasks have been done before so you can follow the examples of others.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
Well, think of what sort of percentage I'm going to get if I complete the project
Thanks for your help.
In terms of the two streams, wouldn't that mean that the listener would have to open two media players to play the seperate streams?
df
|
|
|
|
|
That you were writing the down end player as well. If you are planning on using an existing player and playing from one stream ... hrmm, look into the Lame encoder?
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: That you were writing the down end player as well.
I am ambitious but not THAT ambitious!
Ennis Ray Lynch, Jr. wrote: hrmm, look into the Lame encoder?
I most certainly will.
Thanks.
df
|
|
|
|
|
I'm a bit confused at something...
Look at this code:
((ISupportInitialize)(this.trackBar)).EndInit();
There is no significance to this particular code, it's just an example.
trackBar is an object that implements the ISupportInitialize interface. That interface only defines BeginInit() and EndInit().
Questions:
1. trackBar does NOT implement these methods at all - how come this is allowed? Obviously ISupportInitialize doesn't implement them either, as it is an interface.
2. How can we cast from trackBar to ISupportInitialize and call a method with no implementation?
What is going on? Also, why cast at all if trackBar1 DID implement them?
Also, when you do cast from an object that implements interface X, does that new casted object only contain the methods that X defines?
I'm ashamed to not know this - and I'm sure it'll be very clear, but it's just going against the grain to what I know.
Thanks,
Cormac
|
|
|
|
|
Cormac M Redmond wrote: trackBar does NOT implement these methods at all - how come this is allowed?
I don't think it is allowed.
I would say it should throw you an InvalidCastException.
How does your TrackBar class declaration looks like?
Cormac M Redmond wrote: Also, when you do cast from an object that implements interface X, does that new casted object only contain the methods that X defines?
Yes. Boxing to a base class/interface hides the members of the derived class.
|
|
|
|
|
Hi,
It is allowed though - I found it it fully working code.
Here it is also:
http://msdn2.microsoft.com/en-us/library/system.componentmodel.isupportinitialize.aspx
It's really wrecking my head
Regards,
Cormac Redmond
|
|
|
|
|
Well... I thought that TrackBar is a class you created.
After finding out it's located in System.Windows.Forms I checked its base types.
If you open your Object Browser and do the same you'll see that TrackBar DOES implement ISupportInitialize .
Regards,
Shy.
|
|
|
|
|
That was a poor example then - the code I have in a project does NOT implement them.
And if you're write about TrackBar...why cast to the interface? Why not just call the methods?
Regards,
Cormac
|
|
|
|
|
imho you can cast an object to an interface even the methods aren't implemented. the code will compile. but if the runnig programm tries to execute this, you will get an System.InvalidCastException.
cheers
|
|
|
|
|
|
shyagam wrote: Yes. Boxing to a base class/interface hides the members of the derived class.
Boxing means accessing a value type via a reference. What you wanted to say is "casting". The two are different concepts, although boxing happens at the same time as a value type is cast to the base type.
|
|
|
|
|
Hmm... I see...
I'll remember that.
|
|
|
|
|
Cormac M Redmond wrote: trackBar does NOT implement these methods at all
What makes you think that? Here they are:
TrackBar.BeginInit[^]
TrackBar.EndInit[^]
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Cormac M Redmond wrote: Also, when you do cast from an object that implements interface X, does that new casted object only contain the methods that X defines?
The object doesn't change. After you cast an object it is still the same object. It is just the reference to it that is different.
|
|
|
|
|
Sorry....I knew that - not being very clear today.
|
|
|
|
|
No problem - we all have days like that from time to time.
Earlier this week I sent an email round the development team at work telling them about this work around I'd found to get around the fact that such-and-such menu item wasn't available in a certain project type in Visual Studio. One of the devs in our other office wrote back and said, "do you mean the 8th item on the so-and-so menu?". For a whole day I'd been ripping my hair out trying to figure it out and it was staring at me in the face. I replied the only thing I could reply: "This year I shall be mostly going slightly mad".
Also, in my uni' days I'd rip my hair out over compiler messages that I couldn't understand. I'd eventually find after several hours I'd missed a semi-colon. Luckily, today compilers are much better about point out missing semi-colons than the DOS version of Turbo C++ was.
|
|
|
|
|
((ISupportInitialize) this.pictureBox1).BeginInit();
Ok...there pictureBox1 is a PictureBox and does not implement those methods.
Can anyone explain?
My first example was a bad one.
Regards,
Cormac
|
|
|
|