private string ConvertResponsefieldsToString(HyvesThreadResponsefield responsefields) { StringBuilder responsefieldsBuilder = new StringBuilder(); if (responsefields == HyvesThreadResponsefield.All) { responsefieldsBuilder.Append(EnumHelper.GetAllValuesAsString <HyvesThreadResponsefield>()); } else { var responsefieldsValues = Enum.GetValues(typeof(HyvesThreadResponsefield)); foreach (HyvesThreadResponsefield responseField in responsefieldsValues) { if (EnumHelper.HasFlag(responsefields, responseField)) { responsefieldsBuilder.Append(string.Format("{0},", EnumHelper.GetDescription(responseField))); } } } responsefieldsBuilder = responsefieldsBuilder.Replace( string.Format("{0},", EnumHelper.GetDescription(HyvesThreadResponsefield.All)), string.Empty); string returnValue = responsefieldsBuilder.ToString(); return(returnValue.Substring(0, returnValue.Length - 1)); }
/// <summary> /// Gets the desired information about the specified thread. This corresponds to the /// threads.get Hyves method. /// </summary> /// <param name="threadIds">The requested threadIds.</param> /// <param name="responsefields">Get extra information from the thread.</param> /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param> /// <returns>The information about the specified thread; null if the call fails.</returns> public Collection<Thread> GetThreads(Collection<string> threadIds, HyvesThreadResponsefield responsefields, bool useFancyLayout) { if (threadIds == null || threadIds.Count == 0) { throw new ArgumentNullException("threadIds"); } StringBuilder threadIdBuilder = new StringBuilder(); if (threadIds != null) { foreach (string id in threadIds) { if (threadIdBuilder.Length != 0) { threadIdBuilder.Append(","); } threadIdBuilder.Append(id); } } HyvesRequest request = new HyvesRequest(this.session); request.Parameters["threadid"] = threadIdBuilder.ToString(); request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields); HyvesResponse response = request.InvokeMethod(HyvesMethod.ThreadsGet, useFancyLayout); if (response.Status == HyvesResponseStatus.Succeeded) { return response.ProcessResponse<Thread>("thread"); } return null; }
/// <summary> /// Gets the desired threads from the specified user. This corresponds to the /// threads.getByHub Hyves method. /// </summary> /// <param name="hubId">The requested user Id.</param> /// <param name="responsefields">Get extra information from the thread.</param> /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param> /// <returns>The information about the specified thread; null if the call fails.</returns> public Collection <Thread> GetThreadsByHub(string hubId, HyvesThreadResponsefield responsefields, bool useFancyLayout) { if (string.IsNullOrEmpty(hubId)) { throw new ArgumentException("hubId cannot be null or empty.", "hubId"); } HyvesRequest request = new HyvesRequest(this.session); request.Parameters["hubid"] = hubId; request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields); HyvesResponse response = request.InvokeMethod(HyvesMethod.ThreadsGetByHub, useFancyLayout); if (response.Status == HyvesResponseStatus.Succeeded) { return(response.ProcessResponse <Thread>("thread")); } return(null); }
/// <summary> /// Gets the desired information about the specified thread. This corresponds to the /// threads.get Hyves method. /// </summary> /// <param name="threadIds">The requested threadIds.</param> /// <param name="responsefields">Get extra information from the thread.</param> /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param> /// <returns>The information about the specified thread; null if the call fails.</returns> public Collection <Thread> GetThreads(Collection <string> threadIds, HyvesThreadResponsefield responsefields, bool useFancyLayout) { if (threadIds == null || threadIds.Count == 0) { throw new ArgumentNullException("threadIds"); } StringBuilder threadIdBuilder = new StringBuilder(); if (threadIds != null) { foreach (string id in threadIds) { if (threadIdBuilder.Length != 0) { threadIdBuilder.Append(","); } threadIdBuilder.Append(id); } } HyvesRequest request = new HyvesRequest(this.session); request.Parameters["threadid"] = threadIdBuilder.ToString(); request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields); HyvesResponse response = request.InvokeMethod(HyvesMethod.ThreadsGet, useFancyLayout); if (response.Status == HyvesResponseStatus.Succeeded) { return(response.ProcessResponse <Thread>("thread")); } return(null); }
/// <summary> /// Gets the desired information about the specified thread. This corresponds to the /// threads.get Hyves method. /// </summary> /// <param name="threadIds">The requested threadIds.</param> /// <param name="responsefields">Get extra information from the thread.</param> /// <returns>The information about the specified thread; null if the call fails.</returns> public Collection <Thread> GetThreads(Collection <string> threadIds, HyvesThreadResponsefield responsefields) { return(GetThreads(threadIds, responsefields, false)); }
/// <summary> /// Gets the desired threads from the specified user. This corresponds to the /// threads.getByHub Hyves method. /// </summary> /// <param name="hubId">The requested user Id.</param> /// <param name="responsefields">Get extra information from the thread.</param> /// <returns>The information about the specified thread; null if the call fails.</returns> public Collection <Thread> GetThreadsByHub(string hubId, HyvesThreadResponsefield responsefields) { return(GetThreadsByHub(hubId, responsefields, false)); }
/// <summary> /// Gets the desired information about the specified thread. This corresponds to the /// threads.get Hyves method. /// </summary> /// <param name="threadIds">The requested threadIds.</param> /// <param name="responsefields">Get extra information from the thread.</param> /// <returns>The information about the specified thread; null if the call fails.</returns> public Collection<Thread> GetThreads(Collection<string> threadIds, HyvesThreadResponsefield responsefields) { return GetThreads(threadIds, responsefields, false); }
private string ConvertResponsefieldsToString(HyvesThreadResponsefield responsefields) { StringBuilder responsefieldsBuilder = new StringBuilder(); if (responsefields == HyvesThreadResponsefield.All) { responsefieldsBuilder.Append(EnumHelper.GetAllValuesAsString<HyvesThreadResponsefield>()); } else { var responsefieldsValues = Enum.GetValues(typeof(HyvesThreadResponsefield)); foreach (HyvesThreadResponsefield responseField in responsefieldsValues) { if (EnumHelper.HasFlag(responsefields, responseField)) { responsefieldsBuilder.Append(string.Format("{0},", EnumHelper.GetDescription(responseField))); } } } responsefieldsBuilder = responsefieldsBuilder.Replace( string.Format("{0},", EnumHelper.GetDescription(HyvesThreadResponsefield.All)), string.Empty); string returnValue = responsefieldsBuilder.ToString(); return returnValue.Substring(0, returnValue.Length - 1); }
/// <summary> /// Gets the desired threads from the specified user. This corresponds to the /// threads.getByHub Hyves method. /// </summary> /// <param name="hubId">The requested user Id.</param> /// <param name="responsefields">Get extra information from the thread.</param> /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param> /// <returns>The information about the specified thread; null if the call fails.</returns> public Collection<Thread> GetThreadsByHub(string hubId, HyvesThreadResponsefield responsefields, bool useFancyLayout) { if (string.IsNullOrEmpty(hubId)) { throw new ArgumentException("hubId cannot be null or empty.", "hubId"); } HyvesRequest request = new HyvesRequest(this.session); request.Parameters["hubid"] = hubId; request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields); HyvesResponse response = request.InvokeMethod(HyvesMethod.ThreadsGetByHub, useFancyLayout); if (response.Status == HyvesResponseStatus.Succeeded) { return response.ProcessResponse<Thread>("thread"); } return null; }
/// <summary> /// Gets the desired threads from the specified user. This corresponds to the /// threads.getByHub Hyves method. /// </summary> /// <param name="hubId">The requested user Id.</param> /// <param name="responsefields">Get extra information from the thread.</param> /// <returns>The information about the specified thread; null if the call fails.</returns> public Collection<Thread> GetThreadsByHub(string hubId, HyvesThreadResponsefield responsefields) { return GetThreadsByHub(hubId, responsefields, false); }