本文整理汇总了C#中Presence类的典型用法代码示例。如果您正苦于以下问题:C# Presence类的具体用法?C# Presence怎么用?C# Presence使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Presence类属于命名空间,在下文中一共展示了Presence类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_Create
public void Test_Create()
{
Presence p = new Presence(doc);
p.Type = PresenceType.available;
p.Status = "foo";
Assert.AreEqual("<presence><status>foo</status></presence>", p.ToString());
}
示例2: Acceptor
public Acceptor(Presence presence, Uri originatorUri, Uri[] learners) : base(presence)
{
this.originatorUri = originatorUri;
this.learners = learners;
Register<Propose>(OnPropose);
Register<Accept>(OnAccept);
}
示例3: GetPresenceDisplay
public static string GetPresenceDisplay(Presence presence)
{
if (presence.Type == PresenceType.available) {
if (!String.IsNullOrEmpty(presence.Show)) {
switch (presence.Show) {
case "away":
return "away";
case "chat":
return "free to chat";
case "dnd":
return "do not disturb";
case "xa":
return "extended away";
case "subscribed":
return "subscribed";
default:
return presence.Show;
}
} else {
return "available";
}
} else if (presence.Type == PresenceType.unavailable) {
return "offline";
} else {
throw new ArgumentException("presence type not supported: " + presence.Type);
}
}
示例4: Main
static void Main(string[] args)
{
var presence = new Presence("clusters/commerce", new Dictionary<string, string>
{
{"RavenDB-Url", new UriBuilder("http", Environment.MachineName, 8080).Uri.ToString()}
}, TimeSpan.FromSeconds(3));
presence.TopologyChanged += (sender, nodeMetadata) =>
{
switch (nodeMetadata.ChangeType)
{
case TopologyChangeType.MasterSelected:
Console.WriteLine("Master selected {0}", nodeMetadata.Uri);
break;
case TopologyChangeType.Discovered:
Console.WriteLine("Found {0}", nodeMetadata.Uri);
break;
case TopologyChangeType.Gone:
Console.WriteLine("Oh no, {0} is gone!", nodeMetadata.Uri);
break;
default:
throw new ArgumentOutOfRangeException();
}
};
presence.Start();
Console.WriteLine(presence.Address);
Console.WriteLine("Waiting...");
Console.ReadLine();
}
示例5: ContactsNotificationService
static ContactsNotificationService()
{
ContactsNotificationService.OfflinePresence = new Presence()
{
PresenceType = PresenceType.Offline
};
ContactsNotificationService.Contacts = new ConcurrentDictionary<string, ContactsNotificationService.JsFederatedDude>();
}
示例6: TestUserHost
public void TestUserHost()
{
PresenceManager pp = new PresenceManager();
Presence pres = new Presence(doc);
JID f = new JID("foo", "bar", null);
pres.From = f;
pp.AddPresence(pres);
Assert.AreEqual("[email protected]", pp[f.Bare].From.ToString());
}
示例7: Pet
public Pet(StatsDK dkstats, DeathKnightTalents t, BossOptions bo, Presence p)
{
m_BO = bo;
m_DKStats = dkstats;
m_Talents = t;
m_Presence = p;
AccumulateStats();
}
示例8: GetResourceDisplay
public static string GetResourceDisplay(Presence presence)
{
if (presence["ResourceDisplay"] != null && !String.IsNullOrEmpty(presence["ResourceDisplay"].InnerText))
return presence["ResourceDisplay"].InnerText;
else if (!String.IsNullOrEmpty(presence.From.Resource))
return presence.From.Resource;
else
return "Unknown";
}
示例9: InputArg
internal InputArg(InputArgType type, string name, object defaultValue, Presence presence, string helpString)
{
HasBeenSeen = false;
Type = type;
Name = name;
Value = defaultValue;
Presence = presence;
HelpString = helpString;
HasBeenSeen = false;
}
示例10: Proposer
public Proposer(Presence presence, Acceptor myAcceptor, Uri orignatorUri, Uri[] allAcceptors) : base(presence)
{
this.myAcceptor = myAcceptor;
this.orignatorUri = orignatorUri;
this.allAcceptors = allAcceptors;
ballotBase = base.GetHashCode()%25; // effectively a random choice
Register<Promise>(OnPromise);
Register<ProposalSubsumed>(OnProposalSubsumed);
Register<Accepted>(OnAccepted);
}
示例11: Test_Available
public void Test_Available()
{
Presence p = new Presence(doc);
Assert.AreEqual(PresenceType.available, p.Type);
Assert.AreEqual("", p.GetAttribute("type"));
p.Type = PresenceType.unavailable;
Assert.AreEqual(PresenceType.unavailable, p.Type);
Assert.AreEqual("unavailable", p.GetAttribute("type"));
p.Type = PresenceType.available;
Assert.AreEqual(PresenceType.available, p.Type);
Assert.AreEqual("", p.GetAttribute("type"));
}
示例12: Encoding
public Encoding()
{
_primitiveType = null;
_presence = Presence.Required;
_byteOrder = ByteOrder.LittleEndian;
_minValue = null;
_maxValue = null;
_nullValue = null;
_constValue = null;
_characterEncoding = null;
_epoch = null;
_timeUnit = null;
_semanticType = null;
}
示例13: TestAdd
public void TestAdd()
{
PresenceManager pp = new PresenceManager();
Presence pres = new Presence(doc);
JID f = new JID("foo", "bar", "baz");
pres.From = f;
pp.AddPresence(pres);
Assert.AreEqual("[email protected]/baz", pp[f].From.ToString());
f.Resource = null;
Assert.AreEqual("[email protected]/baz", pp[f].From.ToString());
pres = new Presence(doc);
pres.Status = "wandering";
pres.From = new JID("foo", "bar", "baz");
pp.AddPresence(pres);
Assert.AreEqual("wandering", pp[f].Status);
}
示例14: SetOnlineStateFromPresence
/// <summary>
/// Определение статуса юзера.
/// </summary>
/// <param name="pres"></param>
public void SetOnlineStateFromPresence(Presence pres)
{
if (pres.Type == Matrix.Xmpp.PresenceType.unavailable)
StatusOnline = Model.StatusOnline.Offline;
if (pres.Type == Matrix.Xmpp.PresenceType.available)
{
if (pres.Show == Matrix.Xmpp.Show.chat)
StatusOnline = Model.StatusOnline.Chat;
else if (pres.Show == Matrix.Xmpp.Show.away)
StatusOnline = Model.StatusOnline.Away;
else if (pres.Show == Matrix.Xmpp.Show.xa)
StatusOnline = Model.StatusOnline.ExtendedAway;
else if (pres.Show == Matrix.Xmpp.Show.dnd)
StatusOnline = Model.StatusOnline.DoNotDisturb;
else if (pres.Show == Matrix.Xmpp.Show.NONE)
StatusOnline = Model.StatusOnline.Online;
else
StatusOnline = Model.StatusOnline.Online;
}
//определяем в зависимости от статуса, какую иконку статуса отображать
switch (StatusOnline)
{
case StatusOnline.Online:
ImageStatus = @"ContactListSettings/StatusImage/online.png";
break;
case StatusOnline.Offline:
ImageStatus = @"ContactListSettings/StatusImage/offline.png";
break;
case StatusOnline.Away:
ImageStatus = @"ContactListSettings/StatusImage/away.png";
break;
case StatusOnline.ExtendedAway:
ImageStatus = @"ContactListSettings/StatusImage/extendedAway.png";
break;
case StatusOnline.DoNotDisturb:
ImageStatus = @"ContactListSettings/StatusImage/doNotDisturb.png";
break;
case StatusOnline.Chat:
ImageStatus = @"ContactListSettings/StatusImage/chat.png";
break;
}
}
示例15: GetRosterImageIndex
public static int GetRosterImageIndex(Presence pres)
{
if (pres.Type == PresenceType.Unavailable)
return 0;
switch (pres.Show)
{
case Show.Chat:
return 1;
case Show.Away:
return 2;
case Show.ExtendedAway:
return 2;
case Show.DoNotDisturb:
return 3;
default:
return 1;
}
}