Esempio n. 1
0
        /// <summary>
        /// Gets the profile settings of a player. If no settings are given, it is assumed
        /// all are wanted.
        /// </summary>
        public async Task <ProfileSettings> GetProfileSettings(XboxLiveIdentityType type, string value, params ProfileSetting[] settings)
        {
            string[] strs = settings?.Any() == false
                                ? Enum.GetNames(typeof(ProfileSetting))
                                : settings.Select(ps => Enum.GetName(typeof(ProfileSetting), ps)).ToArray();

            var path  = string.Format(profileSettingsUrl, type.ToString(), value);
            var query = new Dictionary <string, string> {
                { "settings", string.Join(",", strs) }
            };

            return(await requestXboxLiveData <ProfileSettings>(_profileClient, 2, path, query, null));
        }
Esempio n. 2
0
        public async Task <XboxLiveIdentity> GetIdentity(XboxLiveIdentityType type, string value)
        {
            var key = $"{type.ToString().ToLower()}-{value.ToSlug()}";
            Task <XboxLiveIdentity> task = null;

            lock (_inProgressLookups)
            {
                _inProgressLookups.TryGetValue(key, out task);

                // There should never be a task in it's completed state in the dictionary,
                // but if there is it won't be good - so we double check.
                if (task == null || task.IsCompleted)
                {
                    _inProgressLookups.TryAdd(key, (task = getIdentity(type, value)));
                }
            }

            return(await task);
        }