本文整理汇总了C#中Element.SetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# Element.SetAttribute方法的具体用法?C# Element.SetAttribute怎么用?C# Element.SetAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Element
的用法示例。
在下文中一共展示了Element.SetAttribute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XML
public void XML()
{
XmlDocument doc = new XmlDocument();
Element e = new Element("test", doc);
e.SetAttribute("bloo", EnumParser.ToString(bar.NONE));
Assert.AreEqual("", e.GetAttribute("bloo"));
e.SetAttribute("bloo", EnumParser.ToString(bar.bloo));
Assert.AreEqual("moo", e.GetAttribute("bloo"));
e.SetAttribute("bloo", EnumParser.ToString(bar.NONE));
Assert.AreEqual("", e.GetAttribute("bloo"));
}
示例2: Message2
private void Message2()
{
// transient message (will not be stored offline if the server support AMP)
/*
<message to='[email protected]'
from='[email protected]/elsinore'
type='chat'
id='chatty1'>
<body>Who's there?</body>
<amp xmlns='http://jabber.org/protocol/amp'>
<rule action='drop' condition='deliver' value='stored'/>
</amp>
</message>
*/
agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message();
msg.To = new Jid("[email protected]");
msg.From = new Jid("[email protected]/elsinore");
msg.Type = MessageType.chat;
msg.Id = "chatty1";
msg.Body = "Who's there?";
Element amp = new Element();
amp.TagName = "amp";
amp.Namespace = "http://jabber.org/protocol/amp";
Element rule = new Element();
rule.TagName = "rule";
rule.Namespace = "http://jabber.org/protocol/amp";
rule.SetAttribute("action", "drop");
rule.SetAttribute("condition", "deliver");
rule.SetAttribute("value", "stored");
amp.AddChild(rule);
msg.AddChild(amp);
Program.Print(msg);
}
示例3: SendOfflineMessages
private void SendOfflineMessages(XmppSession session)
{
if (!session.IsSignalRFake)
{
var domain = session.Stream.Domain;
foreach (var m in offlineStore.GetOfflineMessages(session.Jid))
{
var delay = new Element("delay");
delay.SetNamespace("urn:xmpp:delay");
delay.SetAttribute("From", domain);
delay.SetAttribute("stamp", Time.Date(m.XDelay.Stamp));
delay.Value = "Offline Storage";
m.AddChild(delay);
m.XDelay.From = new Jid(domain);
m.XDelay.Value = "Offline Storage";
sender.SendTo(session, m);
}
offlineStore.RemoveAllOfflineMessages(session.Jid);
}
}