2014-06-27 56 views
0

我添加一些自定义属性的天蓝BrokeredMessage检查是否一个蓝色的消息具有属性

如message.Properties [“StaffDealingWith”];

我在寻找一个消息是否包含某个属性(例如StaffDealingWIth)。

if (message.Properties.Contains("StaffDealingWith")) 
{ 
    tm.StaffDealingWith = (string)message.Properties["StaffDealingWith"]; 
} 

但是,这给了我一个编译错误。 '了System.Collections.Generic.ICollection>。载(System.Collections.Generic.KeyValuePair)' 具有一些无效参数C:\ CodeTfsArklePos \ Arkle \ RoboWeb.Azure \ MessageFetcher.cs 180 17 RoboWeb.Azure

的消息的类型是Microsoft.ServiceBus.Messaging.BrokeredMessage

回答

2

不指定message是什么类型的,但我会怀疑message.PropertiesDictionary<string, object>,所以你需要使用ContainsKey代替。

Dictionary<string, object> implements ICollection<KeyValuePair<string, object>>所以它也暴露了一个Contains方法!

+0

院长我刚编辑我的问题来指定类型。我想检查消息是否有“StaffDealingWith”属性或该属性是否存在。我对这个阶段的价值不感兴趣。 – DermFrench

+1

对,所以你想检查它是否包含关键'StaffDealingWith' - 使用'ContainsKey' ... –

+0

很酷,我现在就试试看,并接受为答案,至少编译。 – DermFrench

相关问题