private HttpInfo GetHttpInfo() { HttpInfo httpInfo = new HttpInfo(); string url = txtBoxUrl.Text.Trim(); string name = txtBoxName.Text.Trim(); string password = txtBoxPass.Text.Trim(); string postData = txtBoxBody.Text.Trim(); bool isIdentifition = !((bool)radioBtnNoCache.IsChecked); HttpMethod method; if ((bool)radioBtnGet.IsChecked) { method = HttpMethod.GET; } else if ((bool)radioBtnPost.IsChecked) { method = HttpMethod.POST; } else { method = HttpMethod.GET; } HttpAuthenticationType authType = HttpAuthenticationType.Basic; if (isIdentifition) { if ((bool)radioBtnBasic.IsChecked) { authType = HttpAuthenticationType.Basic; } else { authType = HttpAuthenticationType.Digest; } } httpInfo.Url = url; httpInfo.Name = name; httpInfo.Password = password; httpInfo.DataBody = postData; httpInfo.IsIdentifition = isIdentifition; httpInfo.Method = method; httpInfo.Authentication = authType; return(httpInfo); }
internal static string ToSerializedValue(this HttpAuthenticationType value) { switch (value) { case HttpAuthenticationType.NotSpecified: return("NotSpecified"); case HttpAuthenticationType.ClientCertificate: return("ClientCertificate"); case HttpAuthenticationType.ActiveDirectoryOAuth: return("ActiveDirectoryOAuth"); case HttpAuthenticationType.Basic: return("Basic"); } return(null); }
/// <summary> /// Convert an enum of type HttpAuthenticationType to a string. /// </summary> /// <param name='value'> /// The value to convert to a string. /// </param> /// <returns> /// The enum value as a string. /// </returns> internal static string HttpAuthenticationTypeToString(HttpAuthenticationType value) { if (value == HttpAuthenticationType.NotSpecified) { return("NotSpecified"); } if (value == HttpAuthenticationType.ClientCertificate) { return("ClientCertificate"); } if (value == HttpAuthenticationType.ActiveDirectoryOAuth) { return("ActiveDirectoryOAuth"); } if (value == HttpAuthenticationType.Basic) { return("Basic"); } throw new ArgumentOutOfRangeException("value"); }