当前位置: 首页>>代码示例>>C#>>正文


C# SteamID.Select方法代码示例

本文整理汇总了C#中SteamID.Select方法的典型用法代码示例。如果您正苦于以下问题:C# SteamID.Select方法的具体用法?C# SteamID.Select怎么用?C# SteamID.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SteamID的用法示例。


在下文中一共展示了SteamID.Select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetUsersAsync

		/// <summary>
		/// (Async) (Requires <see cref="SteamSharp.Authenticators.APIKeyAuthenticator"/> or <see cref="SteamSharp.Authenticators.UserAuthenticator"/>)
		/// Returns basic profile information for a list of 64-bit Steam IDs.
		/// Throws <see cref="SteamRequestException"/> on failure.
		/// </summary>
		/// <param name="client"><see cref="SteamClient"/> instance to use.</param>
		/// <param name="steamIDs">List of 64 bit Steam IDs to return profile information for. If more than 100 is requested, requests will be executed in batches (API limit of 100 per call).</param>
		/// <returns>
		///	Returns a large amount of profile data for the requested users in the form of a <see cref="Player"/> object. 
		/// Some data associated with a Steam account may be hidden if the user has their profile visibility set to "Friends Only" or "Private". In that case, only public data will be returned.
		/// </returns>
		public async static Task<List<SteamUser>> GetUsersAsync( SteamClient client, SteamID[] steamIDs ) {

			client.IsAuthorizedCall( new Type[] {
				typeof( Authenticators.UserAuthenticator ),
				typeof( Authenticators.APIKeyAuthenticator )
			} );

			// GetUsers has an upper bound of 100 users per request, determine if aggregation is needed
			SteamID[][] chunks =
				steamIDs.Select( ( v, i ) => new { Value = v, Index = i } )
						.GroupBy( x => x.Index / 100 )
						.Select( group => group.Select( x => x.Value ).ToArray() )
						.ToArray();

			List<SteamUser> users = new List<SteamUser>();
			SteamRequest request;
			List<PlayerInfo> players;

			for( int i = 0; i < chunks.Length; i++ ) {

				if( client.Authenticator is Authenticators.UserAuthenticator ) {
					// ISteamUserOAuth provides a higher level of access (with User Authentication), assuming a personal relationship with the target user
					request = new SteamRequest( "ISteamUserOAuth", "GetUserSummaries", "v0001" );
					request.AddParameter( "steamids", String.Join<SteamID>( ",", steamIDs ) );
					players = VerifyAndDeserialize<GetPlayerSummariesContainer>( ( await client.ExecuteAsync( request ) ) ).Players;
				} else {
					request = new SteamRequest( "ISteamUser", "GetPlayerSummaries", "v0002" );
					request.AddParameter( "steamids", String.Join<SteamID>( ",", steamIDs ) );
					players = VerifyAndDeserialize<GetPlayerSummariesResponse>( ( await client.ExecuteAsync( request ) ) ).Response.Players;
				}

				foreach( var player in players ) {
					users.Add( new SteamUser {
						SteamID = player.SteamID,
						PlayerInfo = player
					} );
				}

			}

			return users;

		}
开发者ID:chaoscode,项目名称:SteamSharp,代码行数:54,代码来源:SteamCommunity.cs


注:本文中的SteamID.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。