/// <summary> /// Infrastructure method for retrieving the "dictionary" parameter, returning appropriate Audience-aware /// default values if dictionary is not otherwise set. /// </summary> /// <returns>The value of the "dictionary" parameter.</returns> protected DictionaryType GetDictionaryWithDefaults() { String rawValue = GetOptionalParameter("dictionary"); rawValue = Strings.Clean(rawValue, "Unknown"); DictionaryType val = ConvertEnum <DictionaryType> .Convert(rawValue, DictionaryType.Unknown); if (val == DictionaryType.Unknown) { // is dictionary is unknown, check Audience and set default value String audienceValue = GetOptionalParameter("audience"); audienceValue = Strings.Clean(audienceValue, "Unknown"); AudienceType audience = ConvertEnum <AudienceType> .Convert(audienceValue, AudienceType.Unknown); switch (audience) { case AudienceType.HealthProfessional: val = DictionaryType.NotSet; break; default: val = DictionaryType.term; break; } } return(val); }
static ScriptParm EnumToMeta(object meta, ConvertEnum enumConversionType) { switch (enumConversionType) { case ConvertEnum.ToLower: return(new ScriptParm { Category = (int)ScriptParmCategory.ScriptValue, Type = meta.GetType().ToString(), Value = meta.ToString().ToLower() }); case ConvertEnum.ToUpper: return(new ScriptParm { Category = (int)ScriptParmCategory.ScriptValue, Type = meta.GetType().ToString(), Value = meta.ToString().ToUpper() }); case ConvertEnum.Numeric: return(new ScriptParm { Category = (int)ScriptParmCategory.ScriptValue, Type = meta.GetType().ToString(), Value = (int)Enum.Parse(meta.GetType(), meta.ToString()) }); default: return(new ScriptParm { Category = (int)ScriptParmCategory.ScriptValue, Type = meta.GetType().ToString(), Value = meta }); } }
/// <summary> /// Infrastructure method for retrieving the "audience" parameter, returning appropriate Dictionary-aware /// default values if audience is not otherwise set. /// </summary> /// <returns>The value of the "audience" parameter.</returns> protected AudienceType GetAudienceWithDefaults() { String rawValue = GetOptionalParameter("audience"); rawValue = Strings.Clean(rawValue, "Unknown"); AudienceType val = ConvertEnum <AudienceType> .Convert(rawValue, AudienceType.Unknown); if (val == AudienceType.Unknown) { // is dictionary is unknown, check Audience and set default value String dictionaryValue = GetOptionalParameter("dictionary"); dictionaryValue = Strings.Clean(dictionaryValue, "Unknown"); DictionaryType dictionary = ConvertEnum <DictionaryType> .Convert(dictionaryValue, DictionaryType.Unknown); switch (dictionary) { case DictionaryType.NotSet: case DictionaryType.genetic: val = AudienceType.HealthProfessional; break; default: val = AudienceType.Patient; break; } } return(val); }
/// <summary> /// Infrastructure method for retrieving the "language" parameter. /// </summary> /// <returns>The value of the "language" parameter.</returns> protected Language GetLanguage() { String rawValue = GetRequiredParameter("language"); Language val = ConvertEnum <Language> .Convert(rawValue, Language.Unknown); if (val == Language.Unknown) { throw new ArgumentException(String.Format("Unknown language '{0}'.", val)); } return(val); }
/// <summary> /// Infrastructure method for retrieving the "dictionary" parameter. /// </summary> /// <returns>The value of the "dictionary" parameter.</returns> protected DictionaryType GetDictionary() { String rawValue = GetRequiredParameter("dictionary"); DictionaryType val = ConvertEnum <DictionaryType> .Convert(rawValue, DictionaryType.Unknown); if (val == DictionaryType.Unknown) { throw new ArgumentException(String.Format("Unknown dictionary type '{0}'.", val)); } return(val); }
/// <summary> /// Retrieves the global market cap for crypto currencies. /// </summary> /// <param name="convert">Convert the crypto volumes to the given Fiat currency.</param> /// <returns>A GlobalDataEntity with the requested information in the given currency.</returns> public async Task <GlobalDataEntity> GetGlobalDataAsync(ConvertEnum convert) { StringBuilder uri = new StringBuilder($"/v1/global/?"); uri.Append(ConvertEnum.USD != convert ? $"convert={convert.ToString()}" : ""); var response = await _client.GetStringAsync(uri.ToString()); var obj = JsonConvert.DeserializeObject <GlobalDataEntity>(response); return(obj); }
/// <summary> /// Infrastructure method for retrieving the "searchType" parameter. /// </summary> /// <returns>The value of the "searchType" parameter.</returns> protected SearchType GetSearchType() { String rawValue = GetRequiredParameter("searchType"); SearchType val = ConvertEnum <SearchType> .Convert(rawValue, SearchType.Unknown); if (val == SearchType.Unknown) { throw new ArgumentException(String.Format("Unknown searchType '{0}'.", val)); } return(val); }
/// <summary> /// Retrieves a list of Tickers. /// </summary> /// <param name="limit">Limit the amount of Tickers.</param> /// <param name="convert">Convert the crypto volumes to the given Fiat currency.</param> /// <returns>Returns the ticker list with their volumes.</returns> public async Task <List <TickerEntity> > GetTickerListAsync(int limit, ConvertEnum convert) { var uri = new StringBuilder("/v1/ticker/?"); uri.Append($"limit={limit}&"); uri.Append($"convert={convert.ToString()}"); var response = await _client.GetStringAsync(uri.ToString()); var obj = JsonConvert.DeserializeObject <List <TickerEntity> >(response); return(obj); }
/// <summary> /// Retrieves the Ticker for given cryptoCurrency value. /// </summary> /// <param name="cryptoCurrency">The Ticker name of the desired cryptoCurrency.</param> /// <param name="convert">Convert the crypto volumes to the given Fiat currency.</param> /// <returns>Returns the ticker.</returns> public async Task <TickerEntity> GetTickerAsync(string cryptoCurrency, ConvertEnum convert) { StringBuilder uri = new StringBuilder(); uri.Append($"/v1/ticker/{cryptoCurrency}/?"); uri.Append(ConvertEnum.USD != convert ? $"convert={convert.ToString()}" : ""); var response = await _client.GetStringAsync(uri.ToString()); var obj = JsonConvert.DeserializeObject <List <TickerEntity> >(response); return(obj.First()); }
static ScriptParm ParmToMetaData(object parm, ConvertEnum enumConversionType = ConvertEnum.Default) { ScriptParm scriptParm; // Let's handle null parameters // example of this is BrowserWindow.SetMenu(null) so the menu does not show if (parm == null) { scriptParm = new ScriptParm { Category = (int)ScriptParmCategory.ScriptValue, Type = "null", Value = parm } } ; else if (IsScriptObject(parm)) { scriptParm = ScriptObjectToMeta((ScriptObject)parm); } else if (IsScriptableType(parm)) { scriptParm = ScriptableTypeToMeta(parm); } else if (IsCallback(parm)) { scriptParm = CallBackToMeta(parm); } else if (IsArrayOfScriptableType(parm)) { scriptParm = ScriptableTypeArrayToMeta(parm); } else if (parm.GetType().IsEnum) { scriptParm = EnumToMeta(parm, enumConversionType); } else { scriptParm = new ScriptParm { Category = (int)ScriptParmCategory.ScriptValue, Type = parm.GetType().ToString(), Value = parm } }; return(scriptParm); }
/// <summary> /// Parse the inovked "service" path to determine which method is meant to /// be invoked. /// </summary> /// <param name="request">The current HTTP Request object.</param> /// <returns>An ApiMethodType method denoting the invoked web method.</returns> /// <remarks>Throws HttpParseException if an invalid path is supplied.</remarks> private ApiMethodType ParseApiMethod(HttpRequest request) { ApiMethodType method = ApiMethodType.Unknown; // Get the particular method being invoked by parsing context.Request.PathInfo if (string.IsNullOrEmpty(request.PathInfo)) { throw new HttpParseException("Request.Pathinfo is empty."); } String[] path = Strings.ToListOfTrimmedStrings(request.PathInfo, '/'); // path[0] -- version // path[1] -- Method if (path.Length != 2) { throw new HttpParseException("Unknown path format."); } // Only version 1 is presently supported. if (!string.Equals(path[0], "v1", StringComparison.CurrentCultureIgnoreCase)) { String msg = String.Format(errorVersionFormat, path[0]); log.Error(msg); throw new HttpParseException(msg); } // Attempt to retrieve the desired method. method = ConvertEnum <ApiMethodType> .Convert(path[1], ApiMethodType.Unknown); if (method == ApiMethodType.Unknown) { String msg = String.Format(errorMethodFormat, path[1]); log.Error(msg); throw new HttpParseException(msg); } return(method); }
public string SampleConversion(ConvertEnum convertvariables) { switch (convertvariables) { case ConvertEnum.mm: return("304.8 mm is a foot"); case ConvertEnum.cm: return("30.48 mm is a foot"); case ConvertEnum.inch: return("12 inch is a foot"); case ConvertEnum.m: return("0.3048 m is a foot"); case ConvertEnum.y: return("0.33333333333 yard is a foot"); default: return("nothing"); } }
public Task <TickerEntity> GetTickerAsync(string cryptoCurrency, ConvertEnum convert) { throw new NotImplementedException(); }
/// <summary> /// 获取请假类型 /// </summary> /// <returns></returns> public string GetLeaveTypeList() { return(ConvertEnum.GetEnumNameList <LeaveType>().ToJson()); }
/// <summary> /// Converts the given string (ideally from the 'dictionary' query parameter) to a DictionaryType enum. /// </summary> /// <param name="dictionary">The string parameter to convert.</param> /// <returns>The matching DictionaryType. Defaults to 'Unknown' if string is not recognized.</returns> private DictionaryType GetDictionaryType(string dictionary) { dictionary = Strings.Clean(dictionary, "Unknown"); return(ConvertEnum <DictionaryType> .Convert(dictionary, DictionaryType.Unknown)); }
/// <summary> /// Retrieves a list of Tickers. /// </summary> /// <param name="convert">Convert the crypto volumes to the given Fiat currency.</param> /// <returns>Returns all available tickers with their volumes.</returns> public async Task <List <TickerEntity> > GetTickerListAsync(ConvertEnum convert) => await this.GetTickerListAsync(0, convert).ConfigureAwait(false);
public Task <ApiResponse <List <GlobalData> > > GetGlobalDataAsync(ConvertEnum convert) { throw new NotImplementedException(); }