本文整理汇总了C#中StreamType.HasFlag方法的典型用法代码示例。如果您正苦于以下问题:C# StreamType.HasFlag方法的具体用法?C# StreamType.HasFlag怎么用?C# StreamType.HasFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StreamType
的用法示例。
在下文中一共展示了StreamType.HasFlag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetActivityStreamAsync
/// <summary>
/// Gets an activity stream asynchronously.
/// </summary>
/// <param name="activityId">The Strava activity id.</param>
/// <param name="typeFlags">Specifies the type of stream.</param>
/// <param name="resolution">Specifies the resolution of the stream.</param>
/// <returns>The stream data.</returns>
public async Task<List<ActivityStream>> GetActivityStreamAsync(String activityId, StreamType typeFlags, StreamResolution resolution = StreamResolution.All)
{
StringBuilder types = new StringBuilder();
foreach (StreamType type in (StreamType[])Enum.GetValues(typeof(StreamType)))
{
if (typeFlags.HasFlag(type))
{
types.Append(type.ToString().ToLower());
types.Append(",");
}
}
types.Remove(types.ToString().Length - 1, 1);
String getUrl = String.Format("{0}/{1}/streams/{2}?{3}&access_token={4}",
Endpoints.Activity,
activityId,
types,
resolution != StreamResolution.All ? "resolution=" + resolution.ToString().ToLower() : "",
Authentication.AccessToken
);
String json = await WebRequest.SendGetAsync(new Uri(getUrl));
return Unmarshaller<List<ActivityStream>>.Unmarshal(json);
}