本文整理汇总了C#中ApiClient.UsersFromUsername方法的典型用法代码示例。如果您正苦于以下问题:C# ApiClient.UsersFromUsername方法的具体用法?C# ApiClient.UsersFromUsername怎么用?C# ApiClient.UsersFromUsername使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiClient
的用法示例。
在下文中一共展示了ApiClient.UsersFromUsername方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Player
// C'tor
internal Player(DataNew.Entities.Game g, string name, byte id, ulong pkey, bool spectator, bool local)
{
// Cannot access Program.GameEngine here, it's null.
Task.Factory.StartNew(() =>
{
try
{
var c = new ApiClient();
var list = c.UsersFromUsername(new String[] { name });
var item = list.FirstOrDefault();
if (item != null)
{
this.DisconnectPercent = item.DisconnectPercent;
this.UserIcon = item.IconUrl;
}
}
catch (Exception e)
{
Log.Warn("Player() Error getting api stuff", e);
}
});
_spectator = spectator;
SetupPlayer(Spectator);
// Init fields
_name = name;
Id = id;
PublicKey = pkey;
if (Spectator == false)
{
all.Add(this);
}
else
{
spectators.Add(this);
}
// Assign subscriber status
_subscriber = SubscriptionModule.Get().IsSubscribed ?? false;
//Create the color brushes
SetPlayerColor(id);
// Create counters
_counters = new Counter[0];
if (g.Player.Counters != null)
_counters = g.Player.Counters.Select(x => new Counter(this, x)).ToArray();
// Create variables
Variables = new Dictionary<string, int>();
foreach (var varDef in g.Variables.Where(v => !v.Global))
Variables.Add(varDef.Name, varDef.Default);
// Create global variables
GlobalVariables = new Dictionary<string, string>();
foreach (var varD in g.Player.GlobalVariables)
GlobalVariables.Add(varD.Name, varD.Value);
// Create a hand, if any
if (g.Player.Hand != null)
_hand = new Hand(this, g.Player.Hand);
// Create groups
_groups = new Group[0];
if (g.Player.Groups != null)
{
var tempGroups = g.Player.Groups.ToArray();
_groups = new Group[tempGroups.Length + 1];
_groups[0] = _hand;
for (int i = 1; i < IndexedGroups.Length; i++)
_groups[i] = new Pile(this, tempGroups[i - 1]);
}
minHandSize = 250;
if (Spectator == false)
{
// Raise the event
if (PlayerAdded != null) PlayerAdded(null, new PlayerEventArgs(this));
Ready = false;
OnPropertyChanged("All");
OnPropertyChanged("AllExceptGlobal");
OnPropertyChanged("Count");
}
else
{
OnPropertyChanged("Spectators");
Ready = true;
}
CanKick = local == false && Program.IsHost;
}
示例2: GetModel
private UserProfileViewModel GetModel(ApiUser user)
{
UserProfileViewModel ret = null;
try
{
var client = new ApiClient();
ApiUser me;
me = client.UsersFromUsername(new[] { user.UserName }).FirstOrDefault();
ret = me == null ? new UserProfileViewModel(new ApiUser()) : new UserProfileViewModel(me);
}
catch (Exception ex)
{
Log.Warn("GetModel", ex);
}
return ret;
}
示例3: GetModel
private UserProfileViewModel GetModel(ApiUser user)
{
UserProfileViewModel ret = null;
var client = new ApiClient();
ApiUser me;
me = client.UsersFromUsername(new[] { user.UserName }).FirstOrDefault();
ret = me == null ? new UserProfileViewModel(new ApiUser()) : new UserProfileViewModel(me);
return ret;
}