The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024


[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

Re: Enumerating Block Contents (xAP Framework.NET)



On Thu, 23 Jun 2005 13:21:20 -0400, "Sullivan, Glenn"
<gsullivan@xxxxxxx> wrote:

>Is there an easy way to enumerate (separately) the value pairs of a xAP
>block, using xAP Framework.net?

That's an interesting question. This probably isn't as ideal or
obvious as it perhaps might be.

The answer is that both the message block object (of class
xAPMessageBlock) and a header (derived from class xAPHeaderBase)
inherit from DictionaryBase.

Thus you can foreach all the DictionaryEntry's in the block or header.
So to iterate the block contents (this is in C# rather than VB, sorry)

foreach (DictionaryEntry entry in event_args.Message.Body)
{
String keyword = (String)entry.Key;
xAPPairValue pair_value = (xAPPairValue)entry.Value;
}

This gives you the pair keyword and the pair value (which will either
be a xAPASCIIValue object if it's a plain "Name=Value" entry in
the
message, or a xAPBinaryValue).

Obtaining the value text from 'pair_value' is simple via the Value
property on the xAPPairValue object.

>Basically, is there a similar .Item(index as integer) property that I'm
>missing?

Sadly not I'm afraid. There's only message_block["PairName"]
which
returns the value part, and only when it's a "Name=Value" pair
(ASCII
vs Binary), it seems too. Hmmm.

I'll sort something out for the next release.

HTH,

S
--
Stuart Booth <stuart@xxxxxxx>
xAPFramework.NET - a xAP software development framework for .NET

http://www.xapautomation.org/ 
     http://www.xapframework.net/




xAP_Development Main Index | xAP_Development Thread Index | xAP_Development Home | Archives Home

Comments to the Webmaster are always welcomed, please use this contact form . Note that as this site is a mailing list archive, the Webmaster has no control over the contents of the messages. Comments about message content should be directed to the relevant mailing list.