/// <summary> /// Returns a query option value by its name and removes the query option from the <paramref name="queryOptions"/> collection. /// Currently, it is only used by un-exposed syntatic tree parsing. /// </summary> /// <param name="queryOptions">The collection of query options.</param> /// <param name="queryOptionName">The name of the query option to get.</param> /// <returns>The value of the query option or null if no such query option exists.</returns> internal static string GetQueryOptionValueAndRemove(this List <CustomQueryOptionToken> queryOptions, string queryOptionName) { Debug.Assert(queryOptions != null, "queryOptions != null"); Debug.Assert(queryOptionName == null || queryOptionName.Length > 0, "queryOptionName == null || queryOptionName.Length > 0"); CustomQueryOptionToken option = null; for (int i = 0; i < queryOptions.Count; ++i) { if (queryOptions[i].Name == queryOptionName) { if (option == null) { option = queryOptions[i]; } else { throw new ODataException(Strings.QueryOptionUtils_QueryParameterMustBeSpecifiedOnce(queryOptionName)); } queryOptions.RemoveAt(i); i--; } } return(option == null ? null : option.Value); }
public void QueryOptionQueryTokenDefaultTest() { CustomQueryOptionToken queryOption = new CustomQueryOptionToken(null, null); this.Assert.AreEqual(QueryTokenKind.CustomQueryOption, queryOption.Kind, "The InternalKind property has an unexpected value."); this.Assert.IsNull(queryOption.Name, "The Name property should be null."); this.Assert.IsNull(queryOption.Value, "The Value property should be null."); }
/// <summary> /// Write the given queryOption as Uri part. /// </summary> /// <param name="queryOption">To write as URI part.</param> private void WriteQueryOption(CustomQueryOptionToken queryOption) { ExceptionUtils.CheckArgumentNotNull(queryOption, "queryOption"); this.builder.Append(queryOption.Name); this.builder.Append(ExpressionConstants.SymbolEqual); this.builder.Append(queryOption.Value); }
/// <summary> /// Returns a query option value by its name from the <paramref name="queryOptions"/> collection. /// </summary> /// <param name="queryOptions">The collection of query options.</param> /// <param name="queryOptionName">The name of the query option to get.</param> /// <returns>The value of the query option or null if no such query option exists.</returns> internal static string GetQueryOptionValue(this List <CustomQueryOptionToken> queryOptions, string queryOptionName) { Debug.Assert(queryOptions != null, "queryOptions != null"); Debug.Assert(queryOptionName == null || queryOptionName.Length > 0, "queryOptionName == null || queryOptionName.Length > 0"); CustomQueryOptionToken option = null; foreach (var queryOption in queryOptions) { if (queryOption.Name == queryOptionName) { if (option == null) { option = queryOption; } else { throw new ODataException(Strings.QueryOptionUtils_QueryParameterMustBeSpecifiedOnce(queryOptionName)); } } } return(option == null ? null : option.Value); }
private static void VerifyCustomQueryOptionQueryTokensAreEqual(CustomQueryOptionToken expected, CustomQueryOptionToken actual, AssertionHandler assert) { assert.AreEqual(expected.Name, actual.Name, "The Name of the query option token doesn't match the expected one."); assert.AreEqual(expected.Value, actual.Value, "The Value of the query option token doesn't match the expected one."); }
/// <summary> /// Visits a CustomQueryOptionToken /// </summary> /// <param name="tokenIn">The CustomQueryOptionToken to bind</param> /// <returns>A CustomQueryOptionNode bound to this CustomQueryOptionToken</returns> public virtual T Visit(CustomQueryOptionToken tokenIn) { throw new NotImplementedException(); }
public Expression Visit(CustomQueryOptionToken tokenIn) { throw new NotImplementedException(); }
public bool Visit(CustomQueryOptionToken tokenIn) { throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "QueryToken of type '{0}' is not supported.", tokenIn.Kind)); }