[Banshee-devel-list] Mono.Upnp StateVariable initialization bug



Howdy again. I've also found a bug. An initial event goes out for
StateVariables with "" as the value. This is fine if your state
variable is a string, but it's not that fine if it's a ValueType of
some fashion.

The cause of this is because
ServiceControllerBuilder.BuildStateVariable doesn't have any method to
obtain an initial value for the data that is published immediately
after starting the Service. So it hasn't yet converted the real value
to a string. So it just writes out <null> from the EventServer. Which
gets represented as "" when it arrives on the client.

One possible solution to this would be to provide a method on
[UpnpStateVariable] that lets you specify the name of the property to
obtain the value from. This is lame.

Never fear, I have another idea!

Instead of implementing StateVariables as events, why not implement
the as properties? This makes a whole lot more sense. Now, I think I
know what the response might be, if I had a time machine: but how do
we know when the property changes? Well, that was a good question,
before INotifyPropertyChanged. But it looks as if that's been around
since 2.0.

I'm going to propose that UpnpStateVariable become supported on
properties. In addition to events. It can stay working exactly as it
has, with the addition of supporting this attribute on properties. If
the class happens to implement INotifyPropertyChanged, then it can
subscribe to that, exactly as it would otherwise subscribe to the
event. This should work nicely. In this case, we clearly can
initialize a default value from the property.

Any objections to this? It fixes a bug, and makes it a bit more .Netty.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]